class HDLRuby::Low::Event

Describes an event.

Describes an event.

Extends the Event class with generation of C text.

Extends the Event class with generation of hdr text.

Add the conversion to high.

Extends the Event class with conversion to symbol.

Extends the Event class with generation of HDLRuby::High text.

Describes an event.

Attributes

ref[R]

The reference of the event.

type[R]

The type of event.

Public Class Methods

new(type,ref) click to toggle source

Creates a new type sort of event on signal refered by ref.

# File lib/HDLRuby/hruby_low.rb, line 2339
def initialize(type,ref)
    # Check and set the type.
    @type = type.to_sym
    # Check and set the reference.
    unless ref.is_a?(Ref)
        raise AnyError, "Invalid class for a reference: #{ref.class}"
    end
    @ref = ref
    # And set the parent of ref.
    ref.parent = self
end

Public Instance Methods

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 2377
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)
    # Then apply on the type.
    self.type.each_deep(&ruby_block)
    # Then apply on the reference.
    self.ref.each_deep(&ruby_block)
end
eql?(obj) click to toggle source

Comparison for hash: structural comparison.

# File lib/HDLRuby/hruby_low.rb, line 2355
def eql?(obj)
    return false unless obj.is_a?(Event)
    return false unless @type.eql?(obj.type)
    return false unless @ref.eql?(obj.ref)
    return true
end
hash() click to toggle source

Hash function.

# File lib/HDLRuby/hruby_low.rb, line 2363
def hash
    return [@type,@ref].hash
end
on_edge?() click to toggle source

Tells if there is a positive or negative edge event.

NOTE: checks if the event type is :posedge or :negedge

# File lib/HDLRuby/hruby_low.rb, line 2370
def on_edge?
    return (@type == :posedge or @type == :negedge)
end
reassign_expressions!(node2reassign) click to toggle source

Replace node by corresponding replacement from node2reassign that is a table whose entries are: node the node to replace rep the replacement of the node ref the reference where to reassign the node.

# File lib/HDLRuby/hruby_low_mutable.rb, line 444
def reassign_expressions!(node2reassign)
    # Build the replacement table.
    node2rep = node2reassign.map {|n,r| [n,r[0]] }.to_h

    # Performs the replacement.
    node2rep_done = {} # The performed replacements.
    # Replace on the sons of the reference.
    node2rep_done.merge!(self.ref.replace_expressions!(node2rep))
    # Shall we replace the ref?
    rep = node2rep[self.ref]
    if rep then
        # Yes, do it.
        rep = rep.clone
        node = self.ref
        # node.set_parent!(nil)
        self.set_ref!(rep)
        node2rep_done[node] = rep
    end

    # Assign the replaced nodes.
    node2rep_done.each do |node,rep|
        reassign = node2reassign[node][1].clone
        self.parent.parent.
            add_connection(Connection.new(reassign,node.clone))
    end
end
set_ref!(ref) click to toggle source

Sets the reference to ref.

# File lib/HDLRuby/hruby_low_mutable.rb, line 431
def set_ref!(ref)
    # Check and set the reference.
    unless ref.is_a?(Ref)
        raise AnyError, "Invalid class for a reference: #{ref.class}"
    end
    @ref = ref
end
set_type!(type) click to toggle source

Sets the type.

# File lib/HDLRuby/hruby_low_mutable.rb, line 425
def set_type!(type)
    # Check and set the type.
    @type = type.to_sym
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 732
def to_c(level = 0)
    edge = "ANYEDGE"
    edge = "POSEDGE" if self.type == :posedge
    edge = "NEGEDGE" if self.type == :negedge
    return "make_event(#{edge}," +
           "#{self.ref.resolve.to_c_signal(level+1)})"
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 293
def to_hdr(level = 0)
    return self.ref.to_hdr(level) + ".#{self.type}"
end
to_high() click to toggle source

Creates a new high event.

# File lib/HDLRuby/hruby_low2high.rb, line 156
def to_high
    return HDLRuby::High::Event.new(self.type.to_high,self.ref.to_high)
end