class HDLRuby::High::SignalC

Describes a high-level constant signal.

Constants

High

High-level libraries for describing digital hardware.

Public Class Methods

new(name,type,value) click to toggle source

Creates a new constant signal named name typed as type and value.

Calls superclass method HDLRuby::Low::SignalI::new
# File lib/HDLRuby/hruby_high.rb, line 3507
def initialize(name,type,value)
    # Check the value is a constant.
    value = value.to_expr.match_type(type)
    unless value.constant? then
        raise AnyError,"Non-constant value assignment to constant."
    end
    # Initialize the type structure.
    super(name,type,value)

    unless name.empty? then
        # Named signal, set the hdl-like access to the signal.
        obj = self # For using the right self within the proc
        High.space_reg(name) { obj }
    end

    # Hierarchical type allows access to sub references, so generate
    # the corresponding methods.
    if type.struct? then
        type.each_name do |name|
            self.define_singleton_method(name) do
                RefObject.new(self.to_ref,
                            SignalC.new(name,type.get_type(name),
                                        value[name]))
            end
        end
    end
end

Public Instance Methods

coerce(obj) click to toggle source

Coerce by converting signal to an expression.

# File lib/HDLRuby/hruby_high.rb, line 3546
def coerce(obj)
    return [obj,self.to_expr]
end
to_expr() click to toggle source

Converts to a new expression.

# File lib/HDLRuby/hruby_high.rb, line 3541
def to_expr
    return self.to_ref
end
to_low(name = self.name) click to toggle source

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

# File lib/HDLRuby/hruby_high.rb, line 3551
def to_low(name = self.name)
    # return HDLRuby::Low::SignalC.new(name,self.type.to_low,
    #                                  self.value.to_low)
    signalCL = HDLRuby::Low::SignalC.new(name,self.type.to_low,
                                     self.value.to_low)
    # For debugging: set the source high object
    signalCL.properties[:low2high] = self.hdr_id
    self.properties[:high2low] = signalCL
    return signalCL
end
to_ref() click to toggle source

Converts to a new reference.

# File lib/HDLRuby/hruby_high.rb, line 3536
def to_ref
    return RefObject.new(this,self)
end