Method: HDLRuby::High::Scope#include

Defined in:
lib/HDLRuby/hruby_high.rb

#include(system, *args) ⇒ Object

Include a +system+ type with possible +args+ instanciation arguments.



1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
# File 'lib/HDLRuby/hruby_high.rb', line 1143

def include(system,*args)
    if @includes.key?(system.name) then
        raise AnyError, "Cannot include twice the same system."
    end
    # puts "Include system=#{system.name}"
    # Save the name of the included system, it will serve as key
    # for looking for the included expanded version.
    include_name = system.name
    # Expand the system to include
    system = system.expand(:"",*args)
    # Add the included system interface to the current one.
    if self.parent.is_a?(SystemT) then
        space = self.namespace
        # Interface signals
        # puts "i_name=#{i_name} @to_includes=#{@to_includes.size}"
        system.each_signal_with_included do |signal|
            # puts "signal=#{signal.name}"
            space.send(:define_singleton_method,signal.name) do
                signal
            end
        end
        # Exported objects
        system.each_export do |export|
            # puts "export=#{export.name}"
            space.send(:define_singleton_method,export.name) do
                export
            end
        end
        # Adds the task to execute on the instance.
        system.each_on_instance do |task|
            self.parent.on_instance(&task)
        end
    end
    # Adds it the list of includeds
    @includes[include_name] = system
    
end