Class: OrigenTesters::Timing::Timeset
- Inherits:
-
Object
- Object
- OrigenTesters::Timing::Timeset
- Defined in:
- lib/origen_testers/timing/timeset.rb
Instance Attribute Summary collapse
-
#called ⇒ Object
Returns the value of attribute called.
-
#cycled ⇒ Object
Returns the value of attribute cycled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#period_in_ns ⇒ Object
Returns the value of attribute period_in_ns.
Instance Method Summary collapse
- #_period_in_ns_=(p) ⇒ Object private
-
#called? ⇒ true, false
Indicates whether this timeset is or has been set as the current timeset.
-
#current_timeset? ⇒ true, false
Indicates whether this timeset is the current timeset.
-
#cycled? ⇒ true, false
Returns true if
tester.cycle
has been called while this timeset was the current timeset. - #dut_timeset ⇒ Object
-
#id ⇒ Object
Alias for the #name attr_reader.
-
#initialize(attrs = {}) ⇒ Timeset
constructor
A new instance of Timeset.
-
#lock! ⇒ true, false
(also: #lock_period!, #lock_period_in_ns!)
Locks the current value of the timeset's period_in_ns.
-
#locked? ⇒ Boolean
(also: #period_in_ns_locked?, #period_locked?, #locked)
Returns true if this timeset does not allow changes to its period_in_ns.
- #method_missing(m, *args, &block) ⇒ Object
-
#period_in_ns? ⇒ true, false
Indicates whether a period_in_ns has been defined for this timeset.
-
#period_in_secs ⇒ Float
(also: #period_in_seconds)
Returns the current timeset in seconds.
-
#shorter_period_than?(timeset) ⇒ Boolean
Returns true if the timeset has a shorter period than the supplied timeset.
Constructor Details
#initialize(attrs = {}) ⇒ Timeset
Returns a new instance of Timeset.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/origen_testers/timing/timeset.rb', line 10 def initialize(attrs = {}) @cycled = false @locked = false @called = false attrs.each do |name, value| send("#{name}=", value) end self.period_in_ns = attrs[:period_in_ns] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/origen_testers/timing/timeset.rb', line 107 def method_missing(m, *args, &block) if dut_timeset && (dut_timeset.methods.include?(m) || dut_timeset.private_methods.include?(m)) dut_timeset.send(m, *args, &block) else super end end |
Instance Attribute Details
#called ⇒ Object
Returns the value of attribute called.
7 8 9 |
# File 'lib/origen_testers/timing/timeset.rb', line 7 def called @called end |
#cycled ⇒ Object
Returns the value of attribute cycled.
7 8 9 |
# File 'lib/origen_testers/timing/timeset.rb', line 7 def cycled @cycled end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/origen_testers/timing/timeset.rb', line 7 def name @name end |
#period_in_ns ⇒ Object
Returns the value of attribute period_in_ns.
8 9 10 |
# File 'lib/origen_testers/timing/timeset.rb', line 8 def period_in_ns @period_in_ns end |
Instance Method Details
#_period_in_ns_=(p) ⇒ 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.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/origen_testers/timing/timeset.rb', line 116 def _period_in_ns_=(p) if locked? Origen.app.fail( exception_class: InvalidModification, message: "Timeset :#{@name}'s period_in_ns is locked to #{@period_in_ns} ns!" ) end # Adding this causes examples in Origen (not OrigenTesters) to fail. # Needs further discussion and potentially an Origen examples change. # if cycled? && p != period_in_ns # Origen.app!.fail( # exception_class: InvalidModification, # message: [ # "Timeset :#{name}'s period_in_ns cannot be changed after a cycle has occurred using this timeset!", # " period_in_ns change occurred at #{caller[0]}", # " Attempted to change period from #{@period_in_ns} to #{p}" # ].join("\n") # ) # end @period_in_ns = p @period_in_ns end |
#called? ⇒ true, false
Indicates whether this timeset is or has been set as the current timeset.
94 95 96 |
# File 'lib/origen_testers/timing/timeset.rb', line 94 def called? @called end |
#current_timeset? ⇒ true, false
Indicates whether this timeset is the current timeset.
88 89 90 |
# File 'lib/origen_testers/timing/timeset.rb', line 88 def current_timeset? OrigenTesters::Timing.timeset == self end |
#cycled? ⇒ true, false
Returns true if tester.cycle
has been called while this timeset was the current timeset.
30 31 32 |
# File 'lib/origen_testers/timing/timeset.rb', line 30 def cycled? @cycled end |
#dut_timeset ⇒ Object
103 104 105 |
# File 'lib/origen_testers/timing/timeset.rb', line 103 def dut_timeset dut.timesets[id] end |
#id ⇒ Object
Alias for the #name attr_reader.
99 100 101 |
# File 'lib/origen_testers/timing/timeset.rb', line 99 def id name.to_sym end |
#lock! ⇒ true, false Also known as: lock_period!, lock_period_in_ns!
Locks the current value of the timeset's period_in_ns. Attempts to further adjust the period_in_ns will results in an exception.
45 46 47 |
# File 'lib/origen_testers/timing/timeset.rb', line 45 def lock! @locked = true end |
#locked? ⇒ Boolean Also known as: period_in_ns_locked?, period_locked?, locked
Returns true if this timeset does not allow changes to its period_in_ns
35 36 37 |
# File 'lib/origen_testers/timing/timeset.rb', line 35 def locked? @locked end |
#period_in_ns? ⇒ true, false
Indicates whether a period_in_ns has been defined for this timeset.
73 74 75 |
# File 'lib/origen_testers/timing/timeset.rb', line 73 def period_in_ns? !@period_in_ns.nil? end |
#period_in_secs ⇒ Float Also known as: period_in_seconds
Returns the current timeset in seconds
79 80 81 82 83 |
# File 'lib/origen_testers/timing/timeset.rb', line 79 def period_in_secs if period_in_ns period_in_ns * (10**-9) end end |
#shorter_period_than?(timeset) ⇒ Boolean
Returns true if the timeset has a shorter period than the supplied timeset
23 24 25 |
# File 'lib/origen_testers/timing/timeset.rb', line 23 def shorter_period_than?(timeset) period_in_ns < timeset.period_in_ns end |