class HDLRuby::Low::SystemI
Describes a system instance.
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 layring can be used for describing software or partial reconfiguration.
Extends the SystemI
class with generation of C text.
Extends the SystemI
class with generation of hdr text.
Add the conversion to high.
Extends the SystemI
class with conversion to symbol.
Extends the SystemI
class with generation of HDLRuby::High
text.
Describes a system instance.
Extends SystemI
with the capability of finding one of its inner object by name.
Extends SystemT
with generation of port wires.
Extends the SystemI
class with separation between signals and variables.
Extends the SystemI
class with functionality for moving the declarations to the upper namespace.
Attributes
The name of the instance if any.
The instantiated system.
Public Class Methods
Creates a new system instance of system type systemT
named name
.
# File lib/HDLRuby/hruby_db.rb, line 248 def initialize(name, systemT) # Ensures systemT is from Low::SystemT systemT = SystemT.get(systemT) # Initialize the system instance structure. super(name,systemT) end
Public Instance Methods
Adds a system layer.
# File lib/HDLRuby/hruby_low.rb, line 2557 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 @systemTs << systemT end
Iterates over each object deeply.
Returns an enumerator if no ruby block is given.
# File lib/HDLRuby/hruby_low.rb, line 2526 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
Iterates over the system layers.
# File lib/HDLRuby/hruby_low.rb, line 2567 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
Comparison for hash: structural comparison.
# File lib/HDLRuby/hruby_low.rb, line 2537 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
Find an inner object by name
. NOTE: return nil if not found.
# File lib/HDLRuby/hruby_low_resolve.rb, line 64 def get_by_name(name) # Look into the eigen system. return self.systemT.get_by_name(name) end
Hash
function.
# File lib/HDLRuby/hruby_low.rb, line 2545 def hash return [@name,@systemT].hash end
Rename with name
NOTE: use with care since it can jeopardise the lookup structures.
# File lib/HDLRuby/hruby_low.rb, line 2552 def name=(name) @name = name.to_sym end
Replaces recursively former
name by nname
until it is redeclared.
# File lib/HDLRuby/hruby_low_without_namespace.rb, line 414 def replace_names!(former,nname) # Replace owns name if required. if self.name == former then self.set_name!(nname) end # Recurse on the system type. self.systemT.replace_names!(former,nname) end
Sets the name.
# File lib/HDLRuby/hruby_low_mutable.rb, line 511 def set_name!(name) # Set the name as a symbol. @name = name.to_sym end
Sets the systemT.
# File lib/HDLRuby/hruby_low_mutable.rb, line 517 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
Generates the C text of the equivalent HDLRuby
code. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2c.rb, line 865 def to_c(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)" + "#{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" # 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
Generates the content of the h file.
# File lib/HDLRuby/hruby_low2c.rb, line 913 def to_ch 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
Generates the text of the equivalent hdr text. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2hdr.rb, line 315 def to_hdr(level = 0) return Low2HDR.hdr_call_name(self.systemT.name, ":" + Low2HDR.hdr_decl_name(self.name)) end
Creates a new high system instance.
# File lib/HDLRuby/hruby_low2high.rb, line 199 def to_high return HDLRuby::High::SystemI.new(self.name,self.systemT.to_high) end
Generates the text of the equivalent HDLRuby::High
code. level
is the hierachical level of the object.
# File lib/HDLRuby/hruby_low2vhd.rb, line 878 def to_vhdl(level = 0) # Should never be here. raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}" end
# File lib/HDLRuby/hruby_low_with_port.rb, line 161 def with_port! self.systemT.with_port! return self end
Converts to a variable-compatible system.
NOTE: the result is the same systemT.
# File lib/HDLRuby/hruby_low_with_var.rb, line 33 def with_var! self.systemT.with_var! return self end