Class: Origen::Pins::Pin
- Includes:
- PinCommon
- Defined in:
- lib/origen/pins/pin.rb
Constant Summary collapse
- FUNCTION_SCOPED_ATTRIBUTES =
Any attributes listed here will be looked up for the current function defined by the current mode and configuration context before falling back to a default
[:name, :direction, :option, :group, :ip_block, :meta]
- PACKAGE_SCOPED_ATTRIBUTES =
Any attributes listed here will be looked up for the current package context before falling back to a default
[:location, :dib_assignment]
- TYPES =
Pin Types
[:analog, :digital]
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns a hash containing the aliases associated with the given pin.
-
#ext_pulldown ⇒ Object
Boolean on whether pin has external pull-down.
-
#ext_pullup ⇒ Object
Boolean on whether pin has external pull-up.
-
#functions ⇒ Object
Returns a hash containing the functions associated with the given pin.
-
#invert ⇒ Object
Inverts pin states for drive and compare, can be useful if a timing set change requires clocks to drive low for example when all pattern logic has been set up to drive them high.
-
#open_drain ⇒ Object
Boolean on whether pin is open drain.
-
#order ⇒ Object
Returns the value of attribute order.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#port ⇒ Object
If the pin belongs to a port then this will return the port object.
-
#repeat_previous ⇒ Object
Attribute used to generate vectors where the pin state is assigned the repeat_previous opcode, used by Tester#repeat_previous.
-
#rtl_name ⇒ Object
Pin RTL name, short term solution for products that do not get full HDL path for pins.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#supply ⇒ Object
Internal power supply pin is connected to.
-
#type ⇒ Object
Pin type, either :analog or :digital.
Instance Method Summary collapse
-
#<=>(other_pin) ⇒ Object
When sorting pins do it by ID.
-
#add_alias(id, options = {}) ⇒ Object
Add an alias to the given pin.
-
#add_dib_assignment(str, options = {}) ⇒ Object
(also: #add_dib_info, #add_channel)
Add a Device Interface Board (e.g. probecard at wafer probe or loadboard at final package test) assignment to the pin.
-
#add_function(id, options = {}) ⇒ Object
Add a function to the pin.
- #add_function_attributes(options = {}) ⇒ Object
-
#add_location(str, options = {}) ⇒ Object
(also: #add_locn)
Add a location identifier to the pin, this is a free format field which can be a pin number or BGA co-ordinate for example.
-
#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 (also: #compare!, #expect!)
-
#assert_hi(_options = {}) ⇒ Object
(also: #expect_hi, #compare_hi)
Set the pin to expect a 1 on future cycles.
- #assert_hi! ⇒ Object (also: #expect_hi!, #compare_hi!)
-
#assert_lo(_options = {}) ⇒ Object
(also: #expect_lo, #compare_lo)
Set the pin to expect a 0 on future cycles.
- #assert_lo! ⇒ Object (also: #expect_lo!, #compare_lo!)
- #assert_midband ⇒ Object (also: #compare_midband, #expect_midband)
- #assert_midband! ⇒ Object (also: #compare_midband!, #expect_midband!)
-
#belongs_to_a_port? ⇒ Boolean
(also: #belongs_to_a_pin_group?)
Returns true if the pin belongs to a port.
-
#capture ⇒ Object
(also: #store)
Mark the (data) from the pin to be captured.
-
#capture! ⇒ Object
(also: #store!)
Mark the (data) from the pin to be captured and trigger a cycle.
-
#comparing? ⇒ Boolean
Returns true if the pin is currently in a compare state.
-
#comparing_mem? ⇒ Boolean
Returns true if the pin is currently in a compare mem state.
-
#comparing_midband? ⇒ Boolean
Returns true if the pin is currently in a compare state.
-
#cycle ⇒ Object
:nodoc:.
-
#delete! ⇒ Object
Delete this pin (self).
- #describe(options = {}) ⇒ Object
-
#direction=(val) ⇒ Object
Sets the default direction of the pin, :input, :output or :io (default).
- #disable_clock(options = {}) ⇒ Object
-
#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
Returns true if the pin is currently in a drive state.
-
#driving_mem? ⇒ Boolean
Returns true if the pin is currently in a drive mem state.
- #enable_clock(options = {}) ⇒ Object
- #expect_mem ⇒ Object
- #expect_mem! ⇒ Object
- #function_scoped_name ⇒ Object
-
#groups ⇒ Object
(also: #ports, #pin_groups)
Returns a hash containing the pin groups that the given pin is a member of.
- #half_period ⇒ Object
-
#has_alias?(id, options = {}) ⇒ Boolean
Returns true if the pin has the given alias within the given or current context.
-
#high_voltage? ⇒ Boolean
Returns true if pin is in high voltage state.
-
#initialize(id, owner, options = {}) ⇒ Pin
constructor
Should be instantiated through the HasPins macros.
- #inspect ⇒ Object
- #invalidate_group_cache ⇒ Object
- #invalidate_vector_cache ⇒ Object private
-
#inverted? ⇒ Boolean
Returns the state of invert.
- #is_a_clock? ⇒ Boolean
- #is_a_running_clock? ⇒ Boolean
-
#is_alias_of?(name) ⇒ Boolean
Returns true if the pin is an alias of the given pin name.
- #is_not_a_clock? ⇒ Boolean
-
#name(options = {}) ⇒ Object
Returns the name of the pin, if a name has been specifically assigned by the application (via name=) then this will be returned, otherwise the name of the current function if present will be returned, and then as a last resort the ID of the pin.
- #name=(val) ⇒ Object
- #next_edge ⇒ Object
- #repeat_previous? ⇒ Boolean
-
#restore ⇒ Object
:nodoc:.
-
#restore_state ⇒ Object
Restores the state of the pin at the end of the given block to the state it was in at the start of the block.
-
#resume ⇒ Object
Will resume compares on this pin.
- #sanitize_direction(val) ⇒ Object
-
#save ⇒ Object
:nodoc:.
- #set_state(state) ⇒ Object
- #set_value(val) ⇒ Object (also: #data=)
-
#sites ⇒ Object
Returns the number of test sites enabled for the pin.
- #start_clock(options = {}) ⇒ Object (also: #resume_clock)
- #state ⇒ Object
- #state=(value) ⇒ Object
- #stop_clock(options = {}) ⇒ Object (also: #pause_clock)
- #suspend ⇒ Object
- #suspended? ⇒ Boolean
-
#to_be_captured? ⇒ Boolean
(also: #to_be_stored?, #is_to_be_stored?, #is_to_be_captured?)
Returns true if the (data) from the pin is marked to be captured.
-
#to_vector ⇒ Object
Returns the value held by the pin as a string formatted to the current tester’s pattern syntax.
- #toggle ⇒ Object
- #toggle! ⇒ Object
- #toggle_clock ⇒ Object
- #update_clock ⇒ Object
- #value ⇒ Object (also: #data)
-
#vector_formatted_value=(val) ⇒ Object
Set the pin value and state from a string formatted to the current tester’s pattern syntax, this is the opposite of the to_vector method.
Methods included from PinCommon
#add_configuration, #add_mode, #add_package, #enabled?, #enabled_in_configuration?, #enabled_in_mode?, #enabled_in_package?, #finalize, #id=, #to_sym
Constructor Details
#initialize(id, owner, options = {}) ⇒ Pin
Should be instantiated through the HasPins macros
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/origen/pins/pin.rb', line 45 def initialize(id, owner, = {}) # :nodoc: = { reset: :dont_care, invert: false, direction: :io, open_drain: false, ext_pullup: false, ext_pulldown: false, rtl_name: nil }.merge() @aliases = {} @functions = {} @direction = sanitize_direction([:direction]) @invert = [:invert] @reset = [:reset] @id = id @name = [:name] @rtl_name = [:rtl_name] @suspend = false @order = [:order] @supply = [:supply] @open_drain = [:open_drain] @ext_pullup = [:ext_pullup] @ext_pulldown = [:ext_pulldown] @type = [:type] @dib_assignment = [] # Array to handle multi-site testing @size = 1 @value = 0 @clock = nil on_init(owner, ) # Assign the initial state from the method so that any inversion is picked up... send(@reset) end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns a hash containing the aliases associated with the given pin
28 29 30 |
# File 'lib/origen/pins/pin.rb', line 28 def aliases @aliases end |
#ext_pulldown ⇒ Object
Boolean on whether pin has external pull-down
38 39 40 |
# File 'lib/origen/pins/pin.rb', line 38 def ext_pulldown @ext_pulldown end |
#ext_pullup ⇒ Object
Boolean on whether pin has external pull-up
36 37 38 |
# File 'lib/origen/pins/pin.rb', line 36 def ext_pullup @ext_pullup end |
#functions ⇒ Object
Returns a hash containing the functions associated with the given pin
30 31 32 |
# File 'lib/origen/pins/pin.rb', line 30 def functions @functions end |
#invert ⇒ Object
Inverts pin states for drive and compare, can be useful if a timing set change requires clocks to drive low for example when all pattern logic has been set up to drive them high.
19 20 21 |
# File 'lib/origen/pins/pin.rb', line 19 def invert @invert end |
#open_drain ⇒ Object
Boolean on whether pin is open drain
34 35 36 |
# File 'lib/origen/pins/pin.rb', line 34 def open_drain @open_drain end |
#order ⇒ Object
Returns the value of attribute order.
17 18 19 |
# File 'lib/origen/pins/pin.rb', line 17 def order @order end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
23 24 25 |
# File 'lib/origen/pins/pin.rb', line 23 def owner @owner end |
#port ⇒ Object
If the pin belongs to a port then this will return the port object
26 27 28 |
# File 'lib/origen/pins/pin.rb', line 26 def port @port end |
#repeat_previous ⇒ Object
Attribute used to generate vectors where the pin state is assigned the repeat_previous opcode, used by Tester#repeat_previous
22 23 24 |
# File 'lib/origen/pins/pin.rb', line 22 def repeat_previous @repeat_previous end |
#rtl_name ⇒ Object
Pin RTL name, short term solution for products that do not get full HDL path for pins
42 43 44 |
# File 'lib/origen/pins/pin.rb', line 42 def rtl_name @rtl_name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
24 25 26 |
# File 'lib/origen/pins/pin.rb', line 24 def size @size end |
#supply ⇒ Object
Internal power supply pin is connected to
32 33 34 |
# File 'lib/origen/pins/pin.rb', line 32 def supply @supply end |
#type ⇒ Object
Pin type, either :analog or :digital
40 41 42 |
# File 'lib/origen/pins/pin.rb', line 40 def type @type end |
Instance Method Details
#<=>(other_pin) ⇒ Object
When sorting pins do it by ID
80 81 82 |
# File 'lib/origen/pins/pin.rb', line 80 def <=>(other_pin) @id <=> other_pin.id end |
#add_alias(id, options = {}) ⇒ Object
Add an alias to the given pin.
If the options contain a package, mode or configuration reference then the alias will only work under that context.
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/origen/pins/pin.rb', line 403 def add_alias(id, = {}) obj = .delete(:obj) || self if aliases[id] aliases[id][:packages] += resolve_packages() aliases[id][:modes] += resolve_modes() aliases[id][:configurations] += resolve_configurations() aliases[id][:packages].uniq! aliases[id][:modes].uniq! aliases[id][:configurations].uniq! else aliases[id] = { packages: resolve_packages(), modes: resolve_modes(), configurations: resolve_configurations() } Origen.pin_bank.register_alias(id, obj, ) end end |
#add_dib_assignment(str, options = {}) ⇒ Object Also known as: add_dib_info, add_channel
Add a Device Interface Board (e.g. probecard at wafer probe or loadboard at final package test) assignment to the pin. Some refer to this as a channel but API name is meant to be generic.
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/origen/pins/pin.rb', line 307 def add_dib_assignment(str, = {}) = { site: 0 }.merge() packages = resolve_packages() if packages.empty? @dib_assignment[[:site]] = str add_alias str.to_s.symbolize, package: :all, mode: :all, configuration: :all else packages.each do |package_id| package_id = package_id.respond_to?(:id) ? package_id.id : package_id self.packages[package_id] ||= {} self.packages[package_id][:dib_assignment] ||= [] self.packages[package_id][:dib_assignment][[:site]] = str add_alias str.to_s.symbolize, package: package_id, mode: :all, configuration: :all end end end |
#add_function(id, options = {}) ⇒ Object
Add a function to the pin.
359 360 361 362 363 364 |
# File 'lib/origen/pins/pin.rb', line 359 def add_function(id, = {}) id = id.to_sym add_function_attributes(.merge(name: id, id: id.to_sym)) f = FunctionProxy.new(id, self) add_alias id, packages: :all, obj: f end |
#add_function_attributes(options = {}) ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/origen/pins/pin.rb', line 366 def add_function_attributes( = {}) id = .delete(:id) modes = resolve_modes() configurations = resolve_configurations() [:direction] = sanitize_direction([:direction]) if [:direction] if modes.empty? modes = [:all] end if configurations.empty? configurations = [:all] end # Supports newer attribute lookup by function ID if id functions[:ids] ||= {} if functions[:ids][id] functions[:ids][id] = functions[:ids][id].merge!() else functions[:ids][id] = .dup end end # Supports older attribute lookup by mode context modes.each do |mode| configurations.each do |configuration| functions[mode.to_sym] ||= {} if functions[mode.to_sym][configuration.to_sym] functions[mode.to_sym][configuration.to_sym] = functions[mode.to_sym][configuration.to_sym].merge!() else functions[mode.to_sym][configuration.to_sym] = end end end end |
#add_location(str, options = {}) ⇒ Object Also known as: add_locn
Add a location identifier to the pin, this is a free format field which can be a pin number or BGA co-ordinate for example.
289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/origen/pins/pin.rb', line 289 def add_location(str, = {}) packages = resolve_packages() if packages.empty? @location = str add_alias str.to_s.symbolize, package: :all, mode: :all, configuration: :all else packages.each do |package_id| package_id = package_id.respond_to?(:id) ? package_id.id : package_id self.packages[package_id] ||= {} self.packages[package_id][:location] = str add_alias str.to_s.symbolize, package: package_id, mode: :all, configuration: :all end 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
657 658 659 660 |
# File 'lib/origen/pins/pin.rb', line 657 def assert(value, = {}) set_state(:compare) set_value(value) end |
#assert!(*args) ⇒ Object Also known as: compare!, expect!
664 665 666 667 |
# File 'lib/origen/pins/pin.rb', line 664 def assert!(*args) assert(*args) cycle end |
#assert_hi(_options = {}) ⇒ Object Also known as: expect_hi, compare_hi
Set the pin to expect a 1 on future cycles
588 589 590 591 |
# File 'lib/origen/pins/pin.rb', line 588 def assert_hi( = {}) set_state(:compare) set_value(1) end |
#assert_hi! ⇒ Object Also known as: expect_hi!, compare_hi!
595 596 597 598 |
# File 'lib/origen/pins/pin.rb', line 595 def assert_hi! assert_hi cycle end |
#assert_lo(_options = {}) ⇒ Object Also known as: expect_lo, compare_lo
Set the pin to expect a 0 on future cycles
603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/origen/pins/pin.rb', line 603 def assert_lo( = {}) set_state(:compare) set_value(0) # Planning to add the active load logic to the tester instead... # options = { :active => false #if active true means to take tester active load capability into account # }.merge(options) # unless state_to_be_inverted? # self.state = ($tester.active_loads || !options[:active]) ? $tester.pin_state(:expect_lo) : $tester.pin_state(:dont_care) # else # self.state = ($tester.active_loads || !options[:active]) ? $tester.pin_state(:expect_hi) : $tester.pin_state(:dont_care) # end end |
#assert_lo! ⇒ Object Also known as: expect_lo!, compare_lo!
618 619 620 621 |
# File 'lib/origen/pins/pin.rb', line 618 def assert_lo! assert_lo cycle end |
#assert_midband ⇒ Object Also known as: compare_midband, expect_midband
671 672 673 |
# File 'lib/origen/pins/pin.rb', line 671 def assert_midband set_state(:compare_midband) end |
#assert_midband! ⇒ Object Also known as: compare_midband!, expect_midband!
677 678 679 680 |
# File 'lib/origen/pins/pin.rb', line 677 def assert_midband! assert_midband cycle end |
#belongs_to_a_port? ⇒ Boolean Also known as: belongs_to_a_pin_group?
Returns true if the pin belongs to a port.
add_port :jtag, :size => 6
add_pin :done
add_pin_alias :fail, :jtag, :pin => 4
pin(:done).belongs_to_a_port? # => false
pin(:fail).belongs_to_a_port? # => true
464 465 466 |
# File 'lib/origen/pins/pin.rb', line 464 def belongs_to_a_port? !groups.empty? end |
#capture ⇒ Object Also known as: store
Mark the (data) from the pin to be captured
737 738 739 |
# File 'lib/origen/pins/pin.rb', line 737 def capture set_state(:capture) end |
#capture! ⇒ Object Also known as: store!
Mark the (data) from the pin to be captured and trigger a cycle
743 744 745 746 |
# File 'lib/origen/pins/pin.rb', line 743 def capture! capture cycle end |
#comparing? ⇒ Boolean
Returns true if the pin is currently in a compare state
690 691 692 693 |
# File 'lib/origen/pins/pin.rb', line 690 def comparing? !@suspend && state == :compare end |
#comparing_mem? ⇒ Boolean
Returns true if the pin is currently in a compare mem state
696 697 698 699 |
# File 'lib/origen/pins/pin.rb', line 696 def comparing_mem? !@suspend && state == :expect_mem end |
#comparing_midband? ⇒ Boolean
Returns true if the pin is currently in a compare state
702 703 704 705 |
# File 'lib/origen/pins/pin.rb', line 702 def comparing_midband? !@suspend && state == :compare_midband end |
#cycle ⇒ Object
:nodoc:
522 523 524 |
# File 'lib/origen/pins/pin.rb', line 522 def cycle # :nodoc: Origen.tester.cycle end |
#delete! ⇒ Object
Delete this pin (self). Used bang in method name to keep same for pins and pin collections. Pin collections already had a delete method which deletes a pin from the collection. Needed delete! to indicate it is deleting the actual pin or pin group calling the method.
842 843 844 |
# File 'lib/origen/pins/pin.rb', line 842 def delete! owner.delete_pin(self) end |
#describe(options = {}) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/origen/pins/pin.rb', line 194 def describe( = {}) desc = ['********************'] desc << "Pin id: #{id}" func_aliases = [] unless functions.empty? desc << '' desc << 'Functions' desc << '---------' functions.each do |mode, configurations| unless mode == :ids configurations.each do |configuration, attrs| a = ":#{attrs[:name]}".ljust(30) func_aliases << attrs[:name] unless mode == :all a += ":modes => [#{[mode].flatten.map { |id| ':' + id.to_s }.join(', ')}]" prev = true end unless configuration == :all a += ' ; ' if prev a += ":configurations => [#{[configuration].flatten.map { |id| ':' + id.to_s }.join(', ')}]" end desc << a end end end end unless aliases.empty? desc << '' desc << 'Aliases' desc << '-------' aliases.each do |name, context| unless func_aliases.include?(name) a = ":#{name}".ljust(30) unless context[:packages].empty? || context[:packages] == [:all] a += ":packages => [#{context[:packages].map { |id| ':' + id.to_s }.join(', ')}]" prev = true end unless context[:modes].empty? || context[:modes] == [:all] a += ' ; ' if prev a += ":modes => [#{context[:modes].map { |id| ':' + id.to_s }.join(', ')}]" prev = true end unless context[:configurations].empty? || context[:configurations] == [:all] a += ' ; ' if prev a += ":configurations => [#{context[:configurations].map { |id| ':' + id.to_s }.join(', ')}]" end desc << a end end end unless Origen.top_level.modes.empty? desc << '' desc << 'Modes' desc << '-------' Origen.top_level.modes.each do |name| unless option(mode: name).nil? a = ":#{name}".ljust(30) + ":mode => #{option(mode: name)}" desc << a end end end unless groups.empty? desc << '' desc << 'Groups' desc << '------' desc << groups.map { |name, _group| ':' + name.to_s }.join(', ') end desc << '********************' if [:return] desc else puts desc.join("\n") end end |
#direction=(val) ⇒ Object
Sets the default direction of the pin, :input, :output or :io (default). If a function specific direction has been specified that will override this value.
350 351 352 |
# File 'lib/origen/pins/pin.rb', line 350 def direction=(val) @direction = sanitize_direction(val) end |
#disable_clock(options = {}) ⇒ Object
805 806 807 808 |
# File 'lib/origen/pins/pin.rb', line 805 def disable_clock( = {}) @clock.stop_clock() @clock = nil end |
#dont_care ⇒ Object
Set the pin to X on future cycles
626 627 628 |
# File 'lib/origen/pins/pin.rb', line 626 def dont_care set_state(:dont_care) end |
#dont_care! ⇒ Object
630 631 632 633 |
# File 'lib/origen/pins/pin.rb', line 630 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
641 642 643 644 |
# File 'lib/origen/pins/pin.rb', line 641 def drive(value) set_state(:drive) set_value(value) end |
#drive!(value) ⇒ Object
646 647 648 649 |
# File 'lib/origen/pins/pin.rb', line 646 def drive!(value) drive(value) cycle end |
#drive_hi ⇒ Object
Set the pin to drive a 1 on future cycles
536 537 538 539 |
# File 'lib/origen/pins/pin.rb', line 536 def drive_hi set_state(:drive) set_value(1) end |
#drive_hi! ⇒ Object
541 542 543 544 |
# File 'lib/origen/pins/pin.rb', line 541 def drive_hi! drive_hi cycle end |
#drive_lo ⇒ Object
Set the pin to drive a 0 on future cycles
559 560 561 562 |
# File 'lib/origen/pins/pin.rb', line 559 def drive_lo set_state(:drive) set_value(0) end |
#drive_lo! ⇒ Object
564 565 566 567 |
# File 'lib/origen/pins/pin.rb', line 564 def drive_lo! drive_lo cycle end |
#drive_mem ⇒ Object
569 570 571 |
# File 'lib/origen/pins/pin.rb', line 569 def drive_mem set_state(:drive_mem) end |
#drive_mem! ⇒ Object
573 574 575 576 |
# File 'lib/origen/pins/pin.rb', line 573 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”
548 549 550 551 |
# File 'lib/origen/pins/pin.rb', line 548 def drive_very_hi set_state(:drive_very_hi) set_value(1) end |
#drive_very_hi! ⇒ Object
553 554 555 556 |
# File 'lib/origen/pins/pin.rb', line 553 def drive_very_hi! drive_very_hi cycle end |
#driving? ⇒ Boolean
Returns true if the pin is currently in a drive state
708 709 710 711 |
# File 'lib/origen/pins/pin.rb', line 708 def driving? !@suspend && (state == :drive || state == :drive_very_hi) end |
#driving_mem? ⇒ Boolean
Returns true if the pin is currently in a drive mem state
714 715 716 717 |
# File 'lib/origen/pins/pin.rb', line 714 def driving_mem? !@suspend && state == :drive_mem end |
#enable_clock(options = {}) ⇒ Object
801 802 803 |
# File 'lib/origen/pins/pin.rb', line 801 def enable_clock( = {}) @clock = PinClock.new(self, ) end |
#expect_mem ⇒ Object
578 579 580 |
# File 'lib/origen/pins/pin.rb', line 578 def expect_mem set_state(:expect_mem) end |
#expect_mem! ⇒ Object
582 583 584 585 |
# File 'lib/origen/pins/pin.rb', line 582 def expect_mem! expect_mem cycle end |
#function_scoped_name ⇒ Object
144 |
# File 'lib/origen/pins/pin.rb', line 144 alias_method :function_scoped_name, :name |
#groups ⇒ Object Also known as: ports, pin_groups
Returns a hash containing the pin groups that the given pin is a member of
270 271 272 273 274 275 |
# File 'lib/origen/pins/pin.rb', line 270 def groups # Origen.pin_bank.all_pin_groups.select do |name, group| @groups ||= Origen.pin_bank.pin_groups.select do |_name, group| group.include?(self) end end |
#half_period ⇒ Object
829 830 831 |
# File 'lib/origen/pins/pin.rb', line 829 def half_period @clock.cycles_per_half_period end |
#has_alias?(id, options = {}) ⇒ Boolean
Returns true if the pin has the given alias within the given or current context
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/origen/pins/pin.rb', line 423 def has_alias?(id, = {}) if aliases[id] if [:ignore_context] true else packages = resolve_packages() modes = resolve_modes() configurations = resolve_configurations() begin aliases[id][:packages].include?(:all) || aliases[id][:packages].empty? || packages.any? { |package| aliases[id][:packages].include?(package) } end && begin aliases[id][:modes].include?(:all) || aliases[id][:modes].empty? || modes.any? { |mode| aliases[id][:modes].include?(mode) } end && begin aliases[id][:configurations].include?(:all) || aliases[id][:configurations].empty? || configurations.any? { |config| aliases[id][:configurations].include?(config) } end end else false end end |
#high_voltage? ⇒ Boolean
Returns true if pin is in high voltage state
720 721 722 723 |
# File 'lib/origen/pins/pin.rb', line 720 def high_voltage? !@suspend && state == :drive_very_hi end |
#inspect ⇒ Object
190 191 192 |
# File 'lib/origen/pins/pin.rb', line 190 def inspect "<#{self.class}:#{object_id}>" end |
#invalidate_group_cache ⇒ Object
279 280 281 |
# File 'lib/origen/pins/pin.rb', line 279 def invalidate_group_cache @groups = nil end |
#invalidate_vector_cache ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
167 168 169 170 |
# File 'lib/origen/pins/pin.rb', line 167 def invalidate_vector_cache @vector_formatted_value = nil groups.each { |_name, group| group.invalidate_vector_cache } end |
#inverted? ⇒ Boolean
Returns the state of invert
685 686 687 |
# File 'lib/origen/pins/pin.rb', line 685 def inverted? @invert end |
#is_a_clock? ⇒ Boolean
793 794 795 |
# File 'lib/origen/pins/pin.rb', line 793 def is_a_clock? !(@clock.nil?) end |
#is_a_running_clock? ⇒ Boolean
797 798 799 |
# File 'lib/origen/pins/pin.rb', line 797 def is_a_running_clock? @clock.running? end |
#is_alias_of?(name) ⇒ Boolean
Returns true if the pin is an alias of the given pin name
448 449 450 451 452 453 454 |
# File 'lib/origen/pins/pin.rb', line 448 def is_alias_of?(name) if Origen.pin_bank.find(name) Origen.pin_bank.find(name).id == Origen.pin_bank.find(self).id else false end end |
#is_not_a_clock? ⇒ Boolean
789 790 791 |
# File 'lib/origen/pins/pin.rb', line 789 def is_not_a_clock? @clock.nil? end |
#name(options = {}) ⇒ Object
Returns the name of the pin, if a name has been specifically assigned by the application (via name=) then this will be returned, otherwise the name of the current function if present will be returned, and then as a last resort the ID of the pin
149 150 151 152 |
# File 'lib/origen/pins/pin.rb', line 149 def name( = {}) # Return a specifically assigned name in preference to a function name (.empty? ? @name : nil) || function_scoped_name() || @id end |
#name=(val) ⇒ Object
84 85 86 |
# File 'lib/origen/pins/pin.rb', line 84 def name=(val) @name = val end |
#next_edge ⇒ Object
825 826 827 |
# File 'lib/origen/pins/pin.rb', line 825 def next_edge @clock.next_edge end |
#repeat_previous? ⇒ Boolean
494 495 496 |
# File 'lib/origen/pins/pin.rb', line 494 def repeat_previous? @repeat_previous end |
#restore ⇒ Object
:nodoc:
780 781 782 783 784 785 786 787 |
# File 'lib/origen/pins/pin.rb', line 780 def restore # :nodoc: invalidate_vector_cache @state = @_saved_state @value = @_saved_value @suspend = @_saved_suspend @invert = @_saved_invert @repeat_previous = @_saved_repeat_previous end |
#restore_state ⇒ Object
Restores the state of the pin at the end of the given block to the state it was in at the start of the block
pin(:invoke).driving? # => true
pin(:invoke).restore_state do
pin(:invoke).dont_care
pin(:invoke).driving? # => false
end
pin(:invoke).driving? # => true
766 767 768 769 770 |
# File 'lib/origen/pins/pin.rb', line 766 def restore_state save yield restore end |
#resume ⇒ Object
Will resume compares on this pin
484 485 486 487 |
# File 'lib/origen/pins/pin.rb', line 484 def resume invalidate_vector_cache @suspend = false end |
#sanitize_direction(val) ⇒ Object
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/origen/pins/pin.rb', line 333 def sanitize_direction(val) if val val = val.to_s.downcase.gsub(/\//, '') if val =~ /i.*o/ :io elsif val =~ /^i/ :input elsif val =~ /^o/ :output else fail "Unknown pin direction: #{val}" end end end |
#save ⇒ Object
:nodoc:
772 773 774 775 776 777 778 |
# File 'lib/origen/pins/pin.rb', line 772 def save # :nodoc: @_saved_state = @state @_saved_value = @value @_saved_suspend = @suspend @_saved_invert = @invert @_saved_repeat_previous = @repeat_previous end |
#set_state(state) ⇒ Object
498 499 500 501 502 |
# File 'lib/origen/pins/pin.rb', line 498 def set_state(state) invalidate_vector_cache @repeat_previous = false @state = state end |
#set_value(val) ⇒ Object Also known as: data=
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/origen/pins/pin.rb', line 504 def set_value(val) invalidate_vector_cache # If val is a data bit extract the value of it val = val.respond_to?(:data) ? val.data : val # Assume driving/asserting a nil value means 0 val = 0 unless val if val > 1 fail "Attempt to set a value of #{val} on pin #{name}" end @repeat_previous = false if inverted? @value = val == 0 ? 1 : 0 else @value = val end end |
#sites ⇒ Object
Returns the number of test sites enabled for the pin
329 330 331 |
# File 'lib/origen/pins/pin.rb', line 329 def sites dib_assignment.size end |
#start_clock(options = {}) ⇒ Object Also known as: resume_clock
814 815 816 817 |
# File 'lib/origen/pins/pin.rb', line 814 def start_clock( = {}) enable_clock() if self.is_not_a_clock? @clock.start_clock() end |
#state ⇒ Object
526 527 528 |
# File 'lib/origen/pins/pin.rb', line 526 def state @state end |
#state=(value) ⇒ Object
530 531 532 533 |
# File 'lib/origen/pins/pin.rb', line 530 def state=(value) invalidate_vector_cache @state = value end |
#stop_clock(options = {}) ⇒ Object Also known as: pause_clock
820 821 822 |
# File 'lib/origen/pins/pin.rb', line 820 def stop_clock( = {}) @clock.stop_clock() end |
#suspend ⇒ Object
474 475 476 477 |
# File 'lib/origen/pins/pin.rb', line 474 def suspend invalidate_vector_cache @suspend = true end |
#suspended? ⇒ Boolean
479 480 481 |
# File 'lib/origen/pins/pin.rb', line 479 def suspended? @suspend 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 pin is marked to be captured
750 751 752 |
# File 'lib/origen/pins/pin.rb', line 750 def to_be_captured? state == :capture end |
#to_vector ⇒ Object
Returns the value held by the pin as a string formatted to the current tester’s pattern syntax
162 163 164 |
# File 'lib/origen/pins/pin.rb', line 162 def to_vector @vector_formatted_value ||= Origen.tester.format_pin_state(self) end |
#toggle ⇒ Object
725 726 727 728 729 |
# File 'lib/origen/pins/pin.rb', line 725 def toggle unless state == :dont_care set_value(value == 0 ? 1 : 0) end end |
#toggle! ⇒ Object
731 732 733 734 |
# File 'lib/origen/pins/pin.rb', line 731 def toggle! toggle cycle end |
#toggle_clock ⇒ Object
833 834 835 836 |
# File 'lib/origen/pins/pin.rb', line 833 def toggle_clock fail "ERROR: Clock on #{@owner.name} not running." unless is_a_running_clock? @clock.toggle end |
#update_clock ⇒ Object
810 811 812 |
# File 'lib/origen/pins/pin.rb', line 810 def update_clock @clock.update_clock end |
#value ⇒ Object Also known as: data
469 470 471 |
# File 'lib/origen/pins/pin.rb', line 469 def value @value end |
#vector_formatted_value=(val) ⇒ Object
Set the pin value and state from a string formatted to the current tester’s pattern syntax, this is the opposite of the to_vector method
183 184 185 186 187 188 |
# File 'lib/origen/pins/pin.rb', line 183 def vector_formatted_value=(val) unless @vector_formatted_value == val Origen.tester.update_pin_from_formatted_state(self, val) @vector_formatted_value = val end end |