class Origen::Pins::Timing::Wave
Constants
- VALID_COMPARE_DATA
- VALID_DRIVE_DATA
Attributes
code[R]
Returns the pattern code value associated with the wave. By default this will return nil if no code was given at the time the wave was defined, which means it is the wave that will be applied for the conventional code values of 0, 1, H, L.
events[R]
index[R]
timeset[R]
Public Class Methods
new(timeset, options = {})
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 14 def initialize(timeset, options = {}) @code = options[:code] @code = nil if [0, 1, 'H', 'L', :H, :L].include?(@code) @timeset = timeset @events = [] end
Public Instance Methods
compare(data, options)
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 55 def compare(data, options) self.type = :compare validate_data(data) do |d| validate_time(options) do |t| events << [t, d] end end end
Also aliased as: compare_edge
compare?()
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 81 def compare? @type == :compare end
dont_care(options)
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 65 def dont_care(options) self.type = :drive validate_time(options) do |t| events << [t, :x] end end
Also aliased as: highz
drive(data, options)
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 46 def drive(data, options) self.type = :drive validate_data(data) do |d| validate_time(options) do |t| events << [t, d] end end end
drive?()
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 77 def drive? @type == :drive end
evaluated_events()
click to toggle source
Returns the events array but with any formula based times evaluated. Note that this does not raise an error if the period is not currently set, in that case any events that reference it will have nil for their time.
# File lib/origen/pins/timing/wave.rb, line 26 def evaluated_events if dut.current_timeset_period events.map { |e| [calc.evaluate(e[0], period: dut.current_timeset_period).ceil, e[1]] } else fail 'The current timeset period has not been set' end end
pin_ids()
click to toggle source
Returns an array containing all dut pin_ids
that are assigned to this wave by the parent timeset
# File lib/origen/pins/timing/wave.rb, line 36 def pin_ids @pins_ids ||= timeset.send(:pin_ids_for, self) end
pins()
click to toggle source
Returns an array containing all dut pin objects that are assigned to this wave by the parent timeset
# File lib/origen/pins/timing/wave.rb, line 42 def pins @pins ||= pin_ids.map { |id| dut.pin(id) } end
type()
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 73 def type @type ||= :drive end
Private Instance Methods
calc()
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 106 def calc return @calc if @calc require 'dentaku' @calc = Dentaku::Calculator.new end
clear_cache()
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 87 def clear_cache @pin_ids = nil @pins = nil end
index=(val)
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 92 def index=(val) @index = val end
type=(t)
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 113 def type=(t) if @type if @type != t fail 'Timing waves cannot both drive and compare within a cycle period!' end else @type = t end end
validate_data(data) { |data| ... }
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 96 def validate_data(data) valid = drive? ? VALID_DRIVE_DATA : VALID_COMPARE_DATA data = :data if :data == :pattern unless valid.include?(data) fail "Uknown data value #{data}, only these are valid: #{valid.join(', ')}" end yield data end
validate_time(options) { |t| ... }
click to toggle source
# File lib/origen/pins/timing/wave.rb, line 123 def validate_time(options) unless options[:at] fail 'When defining a wave event you must supply the time via the option :at' end t = options[:at] if t.is_a?(String) d = calc.dependencies(t) - %w(period period_in_ns) unless d.empty? fail "Wave time formulas can only include the variable 'period' (or 'period_in_ns'), this variable is not allowed: #{d}" end t = t.gsub('period_in_ns', 'period') unless calc.evaluate(t, period: 100) fail "There appears to be an error in the formula: #{t}" end yield t return elsif t.is_a?(Numeric) yield t return end fail 'The :at option in a wave event definition must be either a number or a string' end