class HDLRuby::High::SystemI

Describes a high-level system instance.

Constants

High

High-level libraries for describing digital hardware.

Public Class Methods

new(name, systemT) click to toggle source

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

Calls superclass method HDLRuby::Low::SystemI::new
# File lib/HDLRuby/hruby_high.rb, line 1989
def initialize(name, systemT)
    # Initialize the system instance structure.
    super(name,systemT)

    # Sets the hdl-like access to the system instance.
    obj = self # For using the right self within the proc
    High.space_reg(name) { obj }
end

Public Instance Methods

call(*connects) click to toggle source

Connects signals of the system instance according to connects.

NOTE: connects can be a hash table where each entry gives the correspondance between a system's signal name and an external signal to connect to, or a list of signals that will be connected in the order of declaration.

# File lib/HDLRuby/hruby_high.rb, line 2020
def call(*connects)
    # Checks if it is a connection through is a hash.
    if connects.size == 1 and connects[0].respond_to?(:to_h) and
        !connects[0].is_a?(HRef) then
        # Yes, perform a connection by name
        connects = connects[0].to_h
        # Performs the connections.
        connects.each do |key,value|
            # Gets the signal corresponding to connect.
            signal = self.get_signal(key)
            # Check if it is an output.
            isout = self.get_output(key)
            # Convert it to a reference.
            ref = RefObject.new(self.to_ref,signal)
            # Make the connection.
            if isout then
                value <= ref
            else
                ref <= value
            end
        end
    else
        # No, perform a connection is order of declaration
        connects.each.with_index do |csig,i|
            csig = csig.to_expr
            # puts "csig=#{csig} i=#{i}"
            # puts "systemT inputs=#{systemT.each_input.to_a.size}"
            # Gets i-est signal to connect
            ssig = self.systemT.get_interface_with_included(i)
            # Check if it is an output.
            isout = self.systemT.get_output_with_included(ssig.name)
            # puts "ssig=#{ssig.name} isout=#{isout}"
            # Convert it to a reference.
            ssig = RefObject.new(self.to_ref,ssig)
            # Make the connection.
            if isout then
                csig <= ssig
            else
                ssig <= csig
            end
        end
    end
end
get_export(name) click to toggle source

Gets an exported element (signal or system instance) by name.

# File lib/HDLRuby/hruby_high.rb, line 2065
def get_export(name)
    return @systemT.get_export(name)
end
method_missing(m, *args, &ruby_block) click to toggle source

Missing methods are looked for in the public namespace of the system type.

# File lib/HDLRuby/hruby_high.rb, line 2086
def method_missing(m, *args, &ruby_block)
    # print "method_missing in class=#{self.class} with m=#{m}\n"
    self.public_namespace.send(m,*args,&ruby_block)
end
namespace() click to toggle source

Gets the private namespace.

# File lib/HDLRuby/hruby_high.rb, line 2100
def namespace
    # self.systemT.scope.namespace
    self.systemT.namespace
end
open(&ruby_block) click to toggle source

Opens for extension.

NOTE: actually executes ruby_block in the context of the

systemT.
# File lib/HDLRuby/hruby_high.rb, line 2074
def open(&ruby_block)
    # Extend the eigen system.
    @systemT.run(&ruby_block)
    # Update the methods.
    @systemT.eigenize(self)
    self.eigen_extend(@systemT.public_namespace)
end
public_namespace() click to toggle source

Gets the public namespace.

# File lib/HDLRuby/hruby_high.rb, line 2095
def public_namespace
    self.systemT.public_namespace
end
to_low(name = self.name) click to toggle source

Converts the instance to HDLRuby::Low and set its name.

# File lib/HDLRuby/hruby_high.rb, line 2107
def to_low(name = self.name)
    # puts "to_low with #{self} (#{self.name}) #{self.systemT}"
    # Converts the system of the instance to HDLRuby::Low
    systemTL = self.systemT.to_low
    # Creates the resulting HDLRuby::Low instance
    systemIL = HDLRuby::Low::SystemI.new(High.names_create(name),
                                     systemTL)
    # For debugging: set the source high object
    systemIL.properties[:low2high] = self.hdr_id
    self.properties[:high2low] = systemIL
    # Adds the other systemTs.
    self.each_systemT do |systemT|
        systemIL.add_systemT(systemT.to_low) unless systemT == self.systemT
    end
    return systemIL
end
to_ref() click to toggle source

Converts to a new reference.

# File lib/HDLRuby/hruby_high.rb, line 2004
def to_ref
    if self.name.empty? then
        # No name, happens if inside the systemI so use this.
        return this
    else
        # A name.
        return RefObject.new(this,self)
    end
end
type() click to toggle source

The type of a systemI: for now Void (may change in the future).

# File lib/HDLRuby/hruby_high.rb, line 1999
def type
    return void
end