Class: Origen::Tester::Vector
Overview
A simple class to model a vector
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#cycle_number ⇒ Object
Returns the value of attribute cycle_number.
-
#dont_compress ⇒ Object
Returns the value of attribute dont_compress.
-
#microcode ⇒ Object
Returns the value of attribute microcode.
-
#number ⇒ Object
Returns the value of attribute number.
-
#pin_vals ⇒ Object
Returns the value of attribute pin_vals.
-
#repeat ⇒ Object
Since repeat 0 is non-intuitive every vector implicitly has a repeat of 1.
-
#timeset ⇒ Object
Returns the value of attribute timeset.
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #has_microcode? ⇒ Boolean
-
#initialize(attrs = {}) ⇒ Vector
constructor
A new instance of Vector.
- #ordered_pins ⇒ Object
- #update(attrs = {}) ⇒ Object
-
#update_pin_val(pin) ⇒ Object
Updates the pin values to reflect the value currently held by the given pin.
Constructor Details
#initialize(attrs = {}) ⇒ Vector
Returns a new instance of Vector.
9 10 11 12 13 |
# File 'lib/origen/tester/vector.rb', line 9 def initialize(attrs = {}) attrs.each do |attribute, value| send("#{attribute}=", value) end end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def comments @comments end |
#cycle_number ⇒ Object
Returns the value of attribute cycle_number.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def cycle_number @cycle_number end |
#dont_compress ⇒ Object
Returns the value of attribute dont_compress.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def dont_compress @dont_compress end |
#microcode ⇒ Object
Returns the value of attribute microcode.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def microcode @microcode end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def number @number end |
#pin_vals ⇒ Object
Returns the value of attribute pin_vals.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def pin_vals @pin_vals end |
#repeat ⇒ Object
Since repeat 0 is non-intuitive every vector implicitly has a repeat of 1
67 68 69 |
# File 'lib/origen/tester/vector.rb', line 67 def repeat @repeat end |
#timeset ⇒ Object
Returns the value of attribute timeset.
5 6 7 |
# File 'lib/origen/tester/vector.rb', line 5 def timeset @timeset end |
Instance Method Details
#==(obj) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/origen/tester/vector.rb', line 75 def ==(obj) if obj.is_a?(Vector) self.has_microcode? == obj.has_microcode? && timeset == obj.timeset && pin_vals == obj.pin_vals else super obj end end |
#has_microcode? ⇒ Boolean
71 72 73 |
# File 'lib/origen/tester/vector.rb', line 71 def has_microcode? @microcode && !@microcode.empty? end |
#ordered_pins ⇒ Object
54 55 56 |
# File 'lib/origen/tester/vector.rb', line 54 def ordered_pins Origen.app.pin_map.sort_by { |_id, pin| pin.order }.map { |_id, pin| pin } end |
#update(attrs = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/origen/tester/vector.rb', line 19 def update(attrs = {}) attrs.each do |attribute, value| send("#{attribute}=", value) end end |
#update_pin_val(pin) ⇒ Object
Updates the pin values to reflect the value currently held by the given pin
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/origen/tester/vector.rb', line 26 def update_pin_val(pin) vals = pin_vals.split(' ') if pin.belongs_to_a_pin_group? && !pin.is_a?(Origen::Pins::PinCollection) port = nil pin.groups.each { |i| port = i[1] if port.nil? && Origen.tester.ordered_pins.include?(i[1]) } # see if group is included in ordered pins if port ix = Origen.tester.ordered_pins.index(port) # find index of port i = port.index(pin) else ix = Origen.tester.ordered_pins.index(pin) i = 0 end else ix = Origen.tester.ordered_pins.index(pin) i = 0 end if Origen.pin_bank.pin_groups.keys.include? pin.id val = pin.map { |p| Origen.tester.format_pin_state(p) }.join('') vals[ix] = val else val = Origen.tester.format_pin_state(pin) vals[ix][i] = val end self.pin_vals = vals.join(' ') end |