Class: HDLRuby::High::Std::ReconfT

Inherits:
Object
  • Object
show all
Defined in:
lib/HDLRuby/std/reconf.rb

Overview

Describes a high-level reconfigurable component type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &ruby_block) ⇒ ReconfT

Creates a new reconfigurable type with +name+ built whose instances are created from +ruby_block+.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/HDLRuby/std/reconf.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.
    obj = self
    HDLRuby::High.space_reg(@name) do |*args|
        obj.instantiate(*args)
    end
end

Instance Attribute Details

#nameObject (readonly)

The name of the reconfigurable component type.



12
13
14
# File 'lib/HDLRuby/std/reconf.rb', line 12

def name
  @name
end

Instance Method Details

#instantiate(*args) ⇒ Object Also known as: call

Intantiates a reconfigurable component.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/HDLRuby/std/reconf.rb', line 29

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 ReconfT.new(:"") do
            HDLRuby::High.top_user.instance_exec(*args,&ruby_block)
        end
    end
    # Generates the reconfigurable components.
    args.each do |nameI|
        # puts "for #{nameI} ruby_block=#{@ruby_block}"
        reconfI = ReconfI.new(name,&@ruby_block)
        HDLRuby::High.space_reg(nameI) { reconfI }
        reconfI
    end
end