Class: HDLRuby::High::Event

Inherits:
Low::Event
  • Object
show all
Defined in:
lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/std/clocks.rb

Overview

Enhnace the events with multiply operator.

Constant Summary

Constants included from Low::Low2Symbol

Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable

Instance Attribute Summary

Attributes inherited from Low::Event

#ref, #type

Attributes included from Low::Hparent

#parent

Instance Method Summary collapse

Methods inherited from Low::Event

#each_deep, #eql?, #hash, #initialize, #on_edge?, #reassign_expressions!, #set_ref!, #set_type!, #to_c, #to_hdr, #to_high

Methods included from Low::Low2Symbol

#to_sym

Methods included from Low::Hparent

#hierarchy, #scope

Constructor Details

This class inherits a constructor from HDLRuby::Low::Event

Instance Method Details

#*(times) ⇒ Object

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



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# 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

#invertObject

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.



3286
3287
3288
3289
3290
3291
3292
3293
3294
# File 'lib/HDLRuby/hruby_high.rb', line 3286

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_eventObject

Converts to a new event.



3279
3280
3281
# File 'lib/HDLRuby/hruby_high.rb', line 3279

def to_event
    return Event.new(self.type,self.ref.to_ref)
end

#to_lowObject

Converts the event to HDLRuby::Low.



3297
3298
3299
3300
3301
3302
3303
3304
# File 'lib/HDLRuby/hruby_high.rb', line 3297

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