Class: Origen::Pins::Port

Inherits:
Object show all
Includes:
Origen::Pins
Defined in:
lib/origen/pins/port.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  options = {
    name:     id.to_s,
    endian:   :big,
    add_pins: true
  }.merge(options)
  @endian = options.delete(:endian)
  @size = options.delete(:size)
  @name = options.delete(:name)
  @order = options.delete(:order)
  @id = id
  @owner = owner
  add_pins(options) if options[:add_pins]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/origen/pins/port.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/origen/pins/port.rb', line 4

def name
  @name
end

#orderObject

Returns the value of attribute order.



8
9
10
# File 'lib/origen/pins/port.rb', line 8

def order
  @order
end

#ownerObject (readonly)

Returns the value of attribute owner.



6
7
8
# File 'lib/origen/pins/port.rb', line 6

def owner
  @owner
end

#sizeObject (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(options)
  size.times do |i|
    ix = @endian == :big ? @size - i - 1 : i
    pin = add_pin(ix, options)
    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, _options = {})
  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(_options = {})
  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(_options = {})
  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

#captureObject 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

Returns:

  • (Boolean)


207
208
209
# File 'lib/origen/pins/port.rb', line 207

def comparing?
  pins.any? { |_ix, pin| pin.comparing? }
end

#comparing_mem?Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/origen/pins/port.rb', line 211

def comparing_mem?
  pins.any? { |_ix, pin| pin.comparing_mem? }
end

#cycleObject

:nodoc:



43
44
45
# File 'lib/origen/pins/port.rb', line 43

def cycle # :nodoc:
  Origen.tester.cycle
end

#dataObject 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_bObject 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_careObject

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_hiObject

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_loObject

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_memObject



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_hiObject

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

Returns:

  • (Boolean)


215
216
217
# File 'lib/origen/pins/port.rb', line 215

def driving?
  pins.any? { |_ix, pin| pin.driving? }
end

#driving_mem?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/origen/pins/port.rb', line 219

def driving_mem?
  pins.any? { |_ix, pin| pin.driving_mem? }
end

#expect_memObject



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

Returns:

  • (Boolean)


223
224
225
# File 'lib/origen/pins/port.rb', line 223

def high_voltage?
  pins.any? { |_ix, pin| pin.high_voltage? }
end

#inspectObject



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_stateObject

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

Returns:

  • (Boolean)


245
246
247
# File 'lib/origen/pins/port.rb', line 245

def to_be_captured?
  pins.any? { |_ix, pin| pin.to_be_captured? }
end

#toggleObject



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