class HDLRuby::High::Std::ChannelT
Describes a high-level channel type.
Attributes
name[R]
The name of the channel type.
Public Class Methods
new(name,&ruby_block)
click to toggle source
Creates a new channel type with name
built whose instances are created from ruby_block
.
# File lib/HDLRuby/std/channel.rb, line 16 def initialize(name,&ruby_block) # Checks and sets the name. @name = name.to_sym # Sets the block for instantiating a channel. @ruby_block = ruby_block # Sets the instantiation procedure if named. return if @name.empty? obj = self HDLRuby::High.space_reg(@name) do |*args| obj.instantiate(*args) end end
Public Instance Methods
instantiate(*args)
click to toggle source
Intantiates a channel
# File lib/HDLRuby/std/channel.rb, line 30 def instantiate(*args) obj = self # No argument, so not an instantiation but actually # an access to the channel type. return obj if args.empty? # Process the case of generic channel. if @ruby_block.arity > 0 then # Actually the arguments are generic arguments, # generates a new channel type with these arguments # fixed. ruby_block = @ruby_block return ChannelT.new(:"") do HDLRuby::High.top_user.instance_exec(*args,&ruby_block) end end # Generates the channels. channelI = nil args.each do |nameI| # puts "nameI=#{nameI}" channelI = ChannelI.new(nameI,&@ruby_block) # Already registered! # HDLRuby::High.space_reg(nameI) { channelI } end channelI end
Also aliased as: call