Class: Origen::Tester::Vector

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/tester/vector.rb

Overview

A simple class to model a vector

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commentsObject

Returns the value of attribute comments.



5
6
7
# File 'lib/origen/tester/vector.rb', line 5

def comments
  @comments
end

#cycle_numberObject

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_compressObject

Returns the value of attribute dont_compress.



5
6
7
# File 'lib/origen/tester/vector.rb', line 5

def dont_compress
  @dont_compress
end

#microcodeObject

Returns the value of attribute microcode.



5
6
7
# File 'lib/origen/tester/vector.rb', line 5

def microcode
  @microcode
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/origen/tester/vector.rb', line 5

def number
  @number
end

#pin_valsObject

Returns the value of attribute pin_vals.



5
6
7
# File 'lib/origen/tester/vector.rb', line 5

def pin_vals
  @pin_vals
end

#repeatObject

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

#timesetObject

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

Returns:

  • (Boolean)


71
72
73
# File 'lib/origen/tester/vector.rb', line 71

def has_microcode?
  @microcode && !@microcode.empty?
end

#ordered_pinsObject



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