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

name[R]

The name of the instance if any.

systemT[R]

The instantiated system.

Public Class Methods

new(name, systemT) click to toggle source

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

Calls superclass method
# 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

add_systemT(systemT) click to toggle source

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
each_deep(&ruby_block) click to toggle source

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
each_systemT(&ruby_block) click to toggle source

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
eql?(obj) click to toggle source

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
get_by_name(name) click to toggle source

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() click to toggle source

Hash function.

# File lib/HDLRuby/hruby_low.rb, line 2545
def hash
    return [@name,@systemT].hash
end
name=(name) click to toggle source

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
replace_names!(former,nname) click to toggle source

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
set_name!(name) click to toggle source

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
set_systemT(systemT) click to toggle source

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
to_c(level = 0) click to toggle source

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
to_ch() click to toggle source

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
to_hdr(level = 0) click to toggle source

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
to_high() click to toggle source

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
to_vhdl(level = 0) click to toggle source

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
with_port!() click to toggle source
# File lib/HDLRuby/hruby_low_with_port.rb, line 161
def with_port!
    self.systemT.with_port!
    return self
end
with_var!() click to toggle source

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