Class: Origen::Pins::Port
- Includes:
- Origen::Pins
- Defined in:
- lib/origen/pins/port.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#order ⇒ Object
Returns the value of attribute order.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #[](ix) ⇒ Object
- #add_pins(options) ⇒ Object
-
#assert(value, _options = {}) ⇒ Object
(also: #compare, #expect)
Pass in 0 or 1 to have the pin expect_lo or expect_hi respectively.
- #assert!(*args) ⇒ Object
-
#assert_hi(_options = {}) ⇒ Object
(also: #compare_hi, #expect_hi)
Set the pin to expect a 1 on future cycles.
- #assert_hi! ⇒ Object (also: #compare_hi!, #expect_hi!)
-
#assert_lo(_options = {}) ⇒ Object
(also: #compare_lo, #expect_lo)
Set the pin to expect a 0 on future cycles.
- #assert_lo! ⇒ Object (also: #compare_lo!, #expect_lo!)
-
#capture ⇒ Object
(also: #store)
Mark the (data) from the port to be captured.
-
#capture! ⇒ Object
(also: #store!)
Mark the (data) from the port to be captured and trigger a cycle.
- #comparing? ⇒ Boolean
- #comparing_mem? ⇒ Boolean
-
#cycle ⇒ Object
:nodoc:.
-
#data ⇒ Object
(also: #value)
Returns the data value currently assigned to the port.
-
#data=(val) ⇒ Object
Set the data assigned to the port.
-
#data_b ⇒ Object
(also: #value_b)
Returns the inverse of the data value currently assigned to the port.
-
#dont_care ⇒ Object
Set the pin to X on future cycles.
- #dont_care! ⇒ Object
-
#drive(value) ⇒ Object
Pass in 0 or 1 to have the pin drive_lo or drive_hi respectively.
- #drive!(value) ⇒ Object
-
#drive_hi ⇒ Object
Set the pin to drive a 1 on future cycles.
- #drive_hi! ⇒ Object
-
#drive_lo ⇒ Object
Set the pin to drive a 0 on future cycles.
- #drive_lo! ⇒ Object
- #drive_mem ⇒ Object
- #drive_mem! ⇒ Object
-
#drive_very_hi ⇒ Object
Set the pin to drive a high voltage on future cycles (if the tester supports it).
- #drive_very_hi! ⇒ Object
- #driving? ⇒ Boolean
- #driving_mem? ⇒ Boolean
- #expect_mem ⇒ Object
- #expect_mem! ⇒ Object
- #high_voltage? ⇒ Boolean
-
#initialize(id, owner, options = {}) ⇒ Port
constructor
A new instance of Port.
- #inspect ⇒ Object
- #repeat_previous=(bool) ⇒ Object
-
#restore_state ⇒ Object
Restores the state of the port at the end of the given block to the state it was in at the start of the block.
-
#to_be_captured? ⇒ Boolean
(also: #to_be_stored?, #is_to_be_stored?, #is_to_be_captured?)
Returns true if the (data) from the port is marked to be captured.
- #toggle ⇒ Object
- #toggle! ⇒ Object
Methods included from Origen::Pins
#add_ground_pin, #add_ground_pin_group, #add_pin, #add_pin_alias, #add_pin_group, #add_pin_group_alias, #add_pin_object, #add_port, #add_power_pin, #add_power_pin_group, #all_ground_pins, #all_pins, #all_power_pins, #clean_pin_arg, clear_pin_aliases, #delete_all_pins, #delete_pin, #ground_pin_groups, #ground_pins, #has_ground_pin?, #has_pin?, #has_power_pin?, #pin_aliases, pin_aliases, #pin_groups, #pin_order, #pin_order_block, #pin_pattern_exclude, #pin_pattern_order, #pins, #power_pin_groups, #power_pins, #range_to_array, #resolve_pin
Constructor Details
#initialize(id, owner, options = {}) ⇒ Port
Returns a new instance of Port.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/origen/pins/port.rb', line 12 def initialize(id, owner, = {}) = { name: id.to_s, endian: :big, add_pins: true }.merge() @endian = .delete(:endian) @size = .delete(:size) @name = .delete(:name) @order = .delete(:order) @id = id @owner = owner add_pins() if [:add_pins] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/origen/pins/port.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/origen/pins/port.rb', line 4 def name @name end |
#order ⇒ Object
Returns the value of attribute order.
8 9 10 |
# File 'lib/origen/pins/port.rb', line 8 def order @order end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
6 7 8 |
# File 'lib/origen/pins/port.rb', line 6 def owner @owner end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/origen/pins/port.rb', line 7 def size @size end |
Instance Method Details
#[](ix) ⇒ Object
170 171 172 |
# File 'lib/origen/pins/port.rb', line 170 def [](ix) pins[ix] end |
#add_pins(options) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/origen/pins/port.rb', line 35 def add_pins() size.times do |i| ix = @endian == :big ? @size - i - 1 : i pin = add_pin(ix, ) pin.port = self end end |
#assert(value, _options = {}) ⇒ Object Also known as: compare, expect
Pass in 0 or 1 to have the pin expect_lo or expect_hi respectively. This is useful when programatically setting the pin state.
Example
[0,1,1,0].each do |level|
$pin(:d_in).assert(level)
end
157 158 159 160 161 |
# File 'lib/origen/pins/port.rb', line 157 def assert(value, = {}) size.times do |i| pins[i].expect(value[i]) end end |
#assert!(*args) ⇒ Object
165 166 167 168 |
# File 'lib/origen/pins/port.rb', line 165 def assert!(*args) assert(*args) cycle end |
#assert_hi(_options = {}) ⇒ Object Also known as: compare_hi, expect_hi
Set the pin to expect a 1 on future cycles
97 98 99 |
# File 'lib/origen/pins/port.rb', line 97 def assert_hi( = {}) pins.each { |_ix, pin| pin.assert_hi } end |
#assert_hi! ⇒ Object Also known as: compare_hi!, expect_hi!
103 104 105 106 |
# File 'lib/origen/pins/port.rb', line 103 def assert_hi! assert_hi cycle end |
#assert_lo(_options = {}) ⇒ Object Also known as: compare_lo, expect_lo
Set the pin to expect a 0 on future cycles
111 112 113 |
# File 'lib/origen/pins/port.rb', line 111 def assert_lo( = {}) pins.each { |_ix, pin| pin.assert_lo } end |
#assert_lo! ⇒ Object Also known as: compare_lo!, expect_lo!
117 118 119 120 |
# File 'lib/origen/pins/port.rb', line 117 def assert_lo! assert_lo cycle end |
#capture ⇒ Object Also known as: store
Mark the (data) from the port to be captured
232 233 234 |
# File 'lib/origen/pins/port.rb', line 232 def capture pins.each { |_ix, pin| pin.capture } end |
#capture! ⇒ Object Also known as: store!
Mark the (data) from the port to be captured and trigger a cycle
238 239 240 241 |
# File 'lib/origen/pins/port.rb', line 238 def capture! capture cycle end |
#comparing? ⇒ Boolean
207 208 209 |
# File 'lib/origen/pins/port.rb', line 207 def comparing? pins.any? { |_ix, pin| pin.comparing? } end |
#comparing_mem? ⇒ Boolean
211 212 213 |
# File 'lib/origen/pins/port.rb', line 211 def comparing_mem? pins.any? { |_ix, pin| pin.comparing_mem? } end |
#cycle ⇒ Object
:nodoc:
43 44 45 |
# File 'lib/origen/pins/port.rb', line 43 def cycle # :nodoc: Origen.tester.cycle end |
#data ⇒ Object Also known as: value
Returns the data value currently assigned to the port
175 176 177 178 179 180 181 |
# File 'lib/origen/pins/port.rb', line 175 def data d = 0 size.times do |i| d |= pins[i].data << i end d end |
#data=(val) ⇒ Object
Set the data assigned to the port
192 193 194 195 196 |
# File 'lib/origen/pins/port.rb', line 192 def data=(val) size.times do |i| pins[i].data = val[i] end end |
#data_b ⇒ Object Also known as: value_b
Returns the inverse of the data value currently assigned to the port
185 186 187 188 |
# File 'lib/origen/pins/port.rb', line 185 def data_b # (& operation takes care of Bignum formatting issues) ~data & ((1 << size) - 1) end |
#dont_care ⇒ Object
Set the pin to X on future cycles
125 126 127 |
# File 'lib/origen/pins/port.rb', line 125 def dont_care pins.each { |_ix, pin| pin.dont_care } end |
#dont_care! ⇒ Object
129 130 131 132 |
# File 'lib/origen/pins/port.rb', line 129 def dont_care! dont_care cycle end |
#drive(value) ⇒ Object
Pass in 0 or 1 to have the pin drive_lo or drive_hi respectively. This is useful when programatically setting the pin state.
Example
[0,1,1,0].each do |level|
$pin(:d_in).drive(level)
end
140 141 142 143 144 |
# File 'lib/origen/pins/port.rb', line 140 def drive(value) size.times do |i| pins[i].drive(value[i]) end end |
#drive!(value) ⇒ Object
146 147 148 149 |
# File 'lib/origen/pins/port.rb', line 146 def drive!(value) drive(value) cycle end |
#drive_hi ⇒ Object
Set the pin to drive a 1 on future cycles
66 67 68 |
# File 'lib/origen/pins/port.rb', line 66 def drive_hi pins.each { |_ix, pin| pin.drive_hi } end |
#drive_hi! ⇒ Object
70 71 72 73 |
# File 'lib/origen/pins/port.rb', line 70 def drive_hi! drive_hi cycle end |
#drive_lo ⇒ Object
Set the pin to drive a 0 on future cycles
87 88 89 |
# File 'lib/origen/pins/port.rb', line 87 def drive_lo pins.each { |_ix, pin| pin.drive_lo } end |
#drive_lo! ⇒ Object
91 92 93 94 |
# File 'lib/origen/pins/port.rb', line 91 def drive_lo! drive_lo cycle end |
#drive_mem ⇒ Object
47 48 49 |
# File 'lib/origen/pins/port.rb', line 47 def drive_mem pins.each { |_ix, pin| pin.drive_mem } end |
#drive_mem! ⇒ Object
51 52 53 54 |
# File 'lib/origen/pins/port.rb', line 51 def drive_mem! drive_mem cycle end |
#drive_very_hi ⇒ Object
Set the pin to drive a high voltage on future cycles (if the tester supports it). For example on a J750 high-voltage channel the pin state would be set to “2”
77 78 79 |
# File 'lib/origen/pins/port.rb', line 77 def drive_very_hi pins.each { |_ix, pin| pin.drive_very_hi } end |
#drive_very_hi! ⇒ Object
81 82 83 84 |
# File 'lib/origen/pins/port.rb', line 81 def drive_very_hi! drive_very_hi cycle end |
#driving? ⇒ Boolean
215 216 217 |
# File 'lib/origen/pins/port.rb', line 215 def driving? pins.any? { |_ix, pin| pin.driving? } end |
#driving_mem? ⇒ Boolean
219 220 221 |
# File 'lib/origen/pins/port.rb', line 219 def driving_mem? pins.any? { |_ix, pin| pin.driving_mem? } end |
#expect_mem ⇒ Object
56 57 58 |
# File 'lib/origen/pins/port.rb', line 56 def expect_mem pins.each { |_ix, pin| pin.expect_mem } end |
#expect_mem! ⇒ Object
60 61 62 63 |
# File 'lib/origen/pins/port.rb', line 60 def expect_mem! expect_mem cycle end |
#high_voltage? ⇒ Boolean
223 224 225 |
# File 'lib/origen/pins/port.rb', line 223 def high_voltage? pins.any? { |_ix, pin| pin.high_voltage? } end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/origen/pins/port.rb', line 31 def inspect "<#{self.class}:#{object_id}>" end |
#repeat_previous=(bool) ⇒ Object
227 228 229 |
# File 'lib/origen/pins/port.rb', line 227 def repeat_previous=(bool) pins.each { |_ix, pin| pin.repeat_previous = bool } end |
#restore_state ⇒ Object
Restores the state of the port at the end of the given block to the state it was in at the start of the block
port(:a).driving? # => true
port(:a).restore_state do
port(:a).dont_care
port(:a).driving? # => false
end
port(:a).driving? # => true
261 262 263 264 265 |
# File 'lib/origen/pins/port.rb', line 261 def restore_state pins.each { |_ix, pin| pin.save } yield pins.each { |_ix, pin| pin.restore } end |
#to_be_captured? ⇒ Boolean Also known as: to_be_stored?, is_to_be_stored?, is_to_be_captured?
Returns true if the (data) from the port is marked to be captured
245 246 247 |
# File 'lib/origen/pins/port.rb', line 245 def to_be_captured? pins.any? { |_ix, pin| pin.to_be_captured? } end |
#toggle ⇒ Object
198 199 200 |
# File 'lib/origen/pins/port.rb', line 198 def toggle self.data = data_b end |
#toggle! ⇒ Object
202 203 204 205 |
# File 'lib/origen/pins/port.rb', line 202 def toggle! toggle cycle end |