class HDLRuby::High::SignalI

Describes a high-level signal.

Constants

DIRS

The valid bounding directions.

High

High-level libraries for describing digital hardware.

Attributes

can_read[R]

Tells if the signal can be read.

can_write[R]

Tells if the signal can be written.

dir[R]

The bounding direction.

Public Class Methods

new(name,type,dir,value = nil) click to toggle source

Creates a new signal named name typed as type with dir as bounding direction and possible value.

NOTE: dir can be :input, :output, :inout or :inner

Calls superclass method HDLRuby::Low::SignalI::new
# File lib/HDLRuby/hruby_high.rb, line 3407
def initialize(name,type,dir,value =  nil)
    # Check the value.
    value = value.to_expr.match_type(type) if value
    # 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,
                            SignalI.new(name,type.get_type(name),dir))
            end
        end
    end

    # Check and set the bound.
    self.dir = dir

    # Set the read and write authorisations.
    @can_read = 1.to_expr
    @can_write = 1.to_expr
end

Public Instance Methods

can_read=(condition) click to toggle source

Sets the condition when the signal can be read.

# File lib/HDLRuby/hruby_high.rb, line 3439
def can_read=(condition)
    @can_read = condition.to_expr
end
can_write=(condition) click to toggle source

Sets the condition when the signal can be write.

# File lib/HDLRuby/hruby_high.rb, line 3444
def can_write=(condition)
    @can_write = condition.to_expr
end
coerce(obj) click to toggle source

Coerce by converting signal to an expression.

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

Sets the direction to dir.

# File lib/HDLRuby/hruby_high.rb, line 3449
def dir=(dir)
    unless DIRS.include?(dir) then
        raise AnyError, "Invalid bounding for signal #{self.name} direction: #{dir}."
    end
    @dir = dir
end
edge() click to toggle source

Creates an edge event from the signal.

# File lib/HDLRuby/hruby_high.rb, line 3467
def edge
    return Event.new(:edge,self.to_ref)
end
negedge() click to toggle source

Creates a negative edge event from the signal.

# File lib/HDLRuby/hruby_high.rb, line 3462
def negedge
    return Event.new(:negedge,self.to_ref)
end
posedge() click to toggle source

Creates a positive edge event from the signal.

# File lib/HDLRuby/hruby_high.rb, line 3457
def posedge
    return Event.new(:posedge,self.to_ref)
end
to_expr() click to toggle source

Converts to a new expression.

# File lib/HDLRuby/hruby_high.rb, line 3477
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 3487
def to_low(name = self.name)
    # return HDLRuby::Low::SignalI.new(name,self.type.to_low)
    signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low)
    # For debugging: set the source high object
    signalIL.properties[:low2high] = self.hdr_id
    self.properties[:high2low] = signalIL
    return signalIL
end
to_ref() click to toggle source

Converts to a new reference.

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