class HDLRuby::High::Event

Describes a high-level event.

Enhnace the events with multiply operator.

Public Instance Methods

*(times) click to toggle source

Creates a new event activated every times occurences of the current event.

# File lib/HDLRuby/std/clocks.rb, line 143
def *(times)
    # The event must be an edge
    unless (self.type == :posedge or self.type == :negedge) then
        raise "Only posedge or negedge events can be multiplied."
    end
    # +times+ must be a value.
    times = times.to_value
    # Creates the clock for the new event.
    clock = nil
    # There are two cases: times is even or times is odd.
    if times.even? then
        # Even case: make a clock inverted every times/2 occurance of
        # current event.
        clock = HDLRuby::High::Std::make_clock(self,times/2)
    else
        # Odd case: make a clock raised every times occurance using
        # both event and inverted event
        clock = HDLRuby::High::Std::make_2edge_clock(self,times)
    end
    # Use the clock to create the new event.
    return clock.posedge
end
invert() click to toggle source

Inverts the event: create a negedge if posedge, a posedge if negedge.

NOTE: raise an execption if the event is neigther pos nor neg edge.

# File lib/HDLRuby/hruby_high.rb, line 3226
def invert
    if self.type == :posedge then
        return Event.new(:negedge,self.ref.to_ref)
    elsif self.type == :negedge then
        return Event.new(:posedge,self.ref.to_ref)
    else
        raise AnyError, "Event cannot be inverted: #{self.type}"
    end
end
to_event() click to toggle source

Converts to a new event.

# File lib/HDLRuby/hruby_high.rb, line 3219
def to_event
    return Event.new(self.type,self.ref.to_ref)
end
to_low() click to toggle source

Converts the event to HDLRuby::Low.

# File lib/HDLRuby/hruby_high.rb, line 3237
def to_low
    # return HDLRuby::Low::Event.new(self.type,self.ref.to_low)
    eventL = HDLRuby::Low::Event.new(self.type,self.ref.to_low)
    # For debugging: set the source high object
    eventL.properties[:low2high] = self.hdr_id
    self.properties[:high2low] = eventL
    return eventL
end