Class: HDLRuby::Low::SystemI

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Hparent, Low2Symbol
Defined in:
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2sym.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_resolve.rb,
lib/HDLRuby/hruby_low_skeleton.rb,
lib/HDLRuby/hruby_low_with_var.rb,
lib/HDLRuby/hruby_low_with_port.rb,
lib/HDLRuby/hruby_low_without_namespace.rb

Overview

Describes a system instance.

NOTE: an instance can actually represented muliple layers of systems, the first one being the one actually instantiated in the final RTL code. This layering can be used for describing software or partial (re)configuration.

Direct Known Subclasses

High::SystemI

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary collapse

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#hierarchy, #no_parent!, #scope

Constructor Details

#initialize(name, systemT) ⇒ SystemI

Creates a new system instance of system type +systemT+ named +name+.



2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
# File 'lib/HDLRuby/hruby_low.rb', line 2754

def initialize(name, systemT)
    # Set the name as a symbol.
    @name = name.to_sym
    # Check and set the systemT.
    if !systemT.is_a?(SystemT) then
        raise AnyError, "Invalid class for a system type: #{systemT.class}"
    end
    # Sets the instantiated system.
    @systemT = systemT

    # Initialize the list of system layers, the first one
    # being the instantiated system.
    @systemTs = [ @systemT ]
end

Instance Attribute Details

#nameObject

The name of the instance if any.



2748
2749
2750
# File 'lib/HDLRuby/hruby_low.rb', line 2748

def name
  @name
end

#systemTObject (readonly)

The instantiated system.



2751
2752
2753
# File 'lib/HDLRuby/hruby_low.rb', line 2751

def systemT
  @systemT
end

Instance Method Details

#add_systemT(systemT) ⇒ Object

Adds a system configuration.



2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
# File 'lib/HDLRuby/hruby_low.rb', line 2806

def add_systemT(systemT)
    # puts "add_systemT #{systemT.name} to systemI #{self.name}"
    # Check and add the systemT.
    if !systemT.is_a?(SystemT) then
        raise AnyError, "Invalid class for a system type: #{systemT.class}"
    end
    # Set the base configuration of the added system.
    systemT.wrapper = self.systemT
    # Add it.
    @systemTs << systemT
end

#each_arrow_deepObject

See Also:

  • SystemT#each_arrow_deep


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_behaviorObject

See Also:

  • SystemT#each_behavior


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_behavior_deepObject

See Also:

  • SystemT#each_behavior_deep


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_block_deepObject

See Also:

  • SystemT#each_block_deep


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_connectionObject

See Also:

  • SystemT#each_connection


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_connection_deepObject

See Also:

  • SystemT#each_connection_deep


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_deep(&ruby_block) ⇒ Object

Iterates over each object deeply.

Returns an enumerator if no ruby block is given.



2775
2776
2777
2778
2779
2780
2781
2782
2783
# File 'lib/HDLRuby/hruby_low.rb', line 2775

def each_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
    
    # Do not recurse on the systemTs since necesarily processed
    # before!
end

#each_innerObject

See Also:

  • SystemT#each_inner


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_inoutObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_inputObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_outputObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_sensitive_deepObject

See Also:

  • SystemT#each_sensitive_deep


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_signalObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_signal_deepObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_statement_deepObject

See Also:

  • SystemT#each_statement_deep


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_systemIObject

See Also:

  • SystemT#each_systemI


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#each_systemT(&ruby_block) ⇒ Object

Iterates over the system layers.



2819
2820
2821
2822
2823
2824
# File 'lib/HDLRuby/hruby_low.rb', line 2819

def each_systemT(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_systemT) unless ruby_block
    # A ruby block? Apply it on the system layers.
    @systemTs.each(&ruby_block)
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


2786
2787
2788
2789
2790
2791
# File 'lib/HDLRuby/hruby_low.rb', line 2786

def eql?(obj)
    return false unless obj.is_a?(SystemI)
    return false unless @name.eql?(obj.name)
    return false unless @systemT.eql?(obj.systemT)
    return true
end

#get_by_name(name) ⇒ Object

Find an inner object by +name+. NOTE: return nil if not found.



80
81
82
83
# File 'lib/HDLRuby/hruby_low_resolve.rb', line 80

def get_by_name(name)
    # Look into the eigen system.
    return self.systemT.get_by_name(name)
end

#get_innerObject

See Also:

  • SystemT#get_inner


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#get_inoutObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#get_inputObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#get_outputObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#get_signalObject



2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#get_systemIObject

See Also:

  • SystemT#get_systemI


2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
# File 'lib/HDLRuby/hruby_low.rb', line 2873

def_delegators :@systemT,
:each_input, :each_output, :each_inout, :each_inner,
:each_signal, :each_signal_deep,
:get_input, :get_output, :get_inout, :get_inner,
:get_signal, :get_interface,
:each_systemI, :get_systemI,
:each_connection, :each_connection_deep,
:each_statement_deep, :each_arrow_deep,
:each_behavior, :each_behavior_deep, :each_block_deep,
:each_sensitive_deep

#hashObject

Hash function.



2794
2795
2796
# File 'lib/HDLRuby/hruby_low.rb', line 2794

def hash
    return [@name,@systemT].hash
end

#replace_names!(former, nname) ⇒ Object

Replaces recursively +former+ name by +nname+ until it is redeclared.



428
429
430
431
432
433
434
435
436
# File 'lib/HDLRuby/hruby_low_without_namespace.rb', line 428

def replace_names!(former,nname)
    # Replace owns name if required.
    if self.name == former then
        self.set_name!(nname)
    end
    # Not needed since treated through scope and systemT.
    # # Recurse on the system type.
    # self.systemT.replace_names!(former,nname)
end

#set_name!(name) ⇒ Object

Sets the name.



502
503
504
505
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 502

def set_name!(name)
    # Set the name as a symbol.
    @name = name.to_sym
end

#set_systemT(systemT) ⇒ Object

Sets the systemT.



508
509
510
511
512
513
514
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 508

def set_systemT(systemT)
    # Check and set the systemT.
    if !systemT.is_a?(SystemT) then
        raise AnyError, "Invalid class for a system type: #{systemT.class}"
    end
    @systemT = systemT
end

#to_c(res, level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby code. +level+ is the hierachical level of the object. def to_c(level = 0)



1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
# File 'lib/HDLRuby/hruby_low2c.rb', line 1098

def to_c(res,level = 0)
    # The resulting string.
    # res = ""

    # Declare the global variable holding the signal.
    res << "SystemI " << Low2C.obj_name(self) << ";\n\n"

    # The header of the signal generation.
    res << " " * level*3
    res << "SystemI " << Low2C.make_name(self) << "() {\n"
    res << " " * (level+1)*3
    res << "SystemI systemI = malloc(sizeof(SystemIS));\n"
    res << " " * (level+1)*3
    res << "systemI->kind = SYSTEMI;\n";

    # Sets the global variable of the system instance.
    res << "\n"
    res << " " * (level+1)*3
    res << Low2C.obj_name(self) << " = systemI;\n"

    # Set the owner if any.
    if self.parent then
        res << " " * (level+1)*3
        res << "systemI->owner = (Object)"
        res << Low2C.obj_name(self.parent) << ";\n"
    else
        res << "systemI->owner = NULL;\n"
    end

    # Set the name
    res << " " * (level+1)*3
    res << "systemI->name = \"#{self.name}\";\n"
    # # Set the type.
    # res << " " * (level+1)*3
    # res << "systemI->system = " << Low2C.obj_name(self.systemT) << ";\n"
    # Set the systems.
    num_sys = self.each_systemT.to_a.size
    res << " " * (level+1)*3
    res << "systemI->num_systems = #{num_sys};\n"
    res << " " * (level+1)*3
    res << "systemI->systems = calloc(sizeof(SystemT), #{num_sys});\n"
    self.each_systemT.with_index do |sysT,i|
        res << " " * (level+1)*3
        res << "systemI->systems[#{i}] = #{Low2C.obj_name(sysT)};\n"
    end

    # Configure the instance to current systemT.
    res << (" " * (level*3)) << "configure(systemI,0);\n"

    # Generate the return of the signal.
    res << "\n"
    res << " " * (level+1)*3
    res << "return systemI;\n"

    # Close the signal.
    res << " " * level*3
    res << "};\n\n"
    return res
end

#to_ch(res) ⇒ Object

Generates the content of the h file. def to_ch



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
# File 'lib/HDLRuby/hruby_low2c.rb', line 1160

def to_ch(res)
    # res = ""
    # Declare the global variable holding the signal.
    res << "extern SystemI " << Low2C.obj_name(self) << ";\n\n"

    # Generate the access to the function making the systemT. */
    res << "extern SystemI " << Low2C.make_name(self) << "();\n\n"

    return res
end

#to_hdr(level = 0) ⇒ Object

Generates the text of the equivalent hdr text. +level+ is the hierachical level of the object.



320
321
322
323
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 320

def to_hdr(level = 0)
    return Low2HDR.hdr_call_name(self.systemT.name,
           ":" + Low2HDR.hdr_decl_name(self.name))
end

#to_highObject

Creates a new high system instance.



214
215
216
# File 'lib/HDLRuby/hruby_low2high.rb', line 214

def to_high
    return HDLRuby::High::SystemI.new(self.name,self.systemT.to_high)
end

#to_vhdl(level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object.

Raises:



888
889
890
891
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 888

def to_vhdl(level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}"
end

#with_port!Object

Extends SystemT with generation of port wires.



176
177
178
179
# File 'lib/HDLRuby/hruby_low_with_port.rb', line 176

def with_port!
    self.systemT.with_port!
    return self
end

#with_var!Object

Converts to a variable-compatible system.

NOTE: the result is the same systemT.



39
40
41
42
# File 'lib/HDLRuby/hruby_low_with_var.rb', line 39

def with_var!
    self.systemT.with_var!
    return self
end