Class: Origen::Pins::PinClock
Instance Attribute Summary collapse
-
#cycles_per_duty ⇒ Object
readonly
Returns the value of attribute cycles_per_duty.
-
#last_edge ⇒ Object
readonly
Returns the value of attribute last_edge.
-
#next_edge ⇒ Object
readonly
Returns the value of attribute next_edge.
Instance Method Summary collapse
-
#cycles_per_half_period ⇒ Object
The only caller to this should be legacy support so just force 50% duty cycle.
-
#initialize(owner, options = {}) ⇒ PinClock
constructor
A new instance of PinClock.
- #restart_clock ⇒ Object
- #running? ⇒ Boolean
- #start_clock(options = {}) ⇒ Object
- #stop_clock(options = {}) ⇒ Object
- #toggle ⇒ Object
- #update_clock ⇒ Object
Constructor Details
#initialize(owner, options = {}) ⇒ PinClock
Returns a new instance of PinClock.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/origen/pins/pin_clock.rb', line 6 def initialize(owner, = {}) @owner = owner @running = false @clock_period_in_ns = 0 @tester_period_in_ns = 0 update_clock_period() update_tester_period_local update_clock_parameters end |
Instance Attribute Details
#cycles_per_duty ⇒ Object (readonly)
Returns the value of attribute cycles_per_duty.
4 5 6 |
# File 'lib/origen/pins/pin_clock.rb', line 4 def cycles_per_duty @cycles_per_duty end |
#last_edge ⇒ Object (readonly)
Returns the value of attribute last_edge.
4 5 6 |
# File 'lib/origen/pins/pin_clock.rb', line 4 def last_edge @last_edge end |
#next_edge ⇒ Object (readonly)
Returns the value of attribute next_edge.
4 5 6 |
# File 'lib/origen/pins/pin_clock.rb', line 4 def next_edge @next_edge end |
Instance Method Details
#cycles_per_half_period ⇒ Object
The only caller to this should be legacy support so just force 50% duty cycle
66 67 68 |
# File 'lib/origen/pins/pin_clock.rb', line 66 def cycles_per_half_period @cycles_per_duty.min end |
#restart_clock ⇒ Object
42 43 44 45 46 |
# File 'lib/origen/pins/pin_clock.rb', line 42 def restart_clock stop_clock update_clock start_clock end |
#running? ⇒ Boolean
56 57 58 |
# File 'lib/origen/pins/pin_clock.rb', line 56 def running? @running end |
#start_clock(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/origen/pins/pin_clock.rb', line 18 def start_clock( = {}) # Throw error if this pin is already a running clock if running? fail "PIN CLOCK ERROR: Clock on #{@owner.name} already running." end clock_updated = update_clock_period() tester_updated = update_tester_period_local if clock_updated || tester_updated update_clock_parameters end cc "[PinClock] Start #{@owner.name}.clock at #{Origen.tester.cycle_count}: period=#{@clock_period_in_ns}ns, cycles=#{cycles_per_period}, duty=#{duty_str}" update_edges Origen.tester.push_running_clock(@owner) unless running? @running = true end |
#stop_clock(options = {}) ⇒ Object
36 37 38 39 40 |
# File 'lib/origen/pins/pin_clock.rb', line 36 def stop_clock( = {}) cc "[PinClock] Stop #{@owner.name}.clock: stop_cycle=#{Origen.tester.cycle_count}" if running? Origen.tester.pop_running_clock(@owner) if running? @running = false end |
#toggle ⇒ Object
60 61 62 63 |
# File 'lib/origen/pins/pin_clock.rb', line 60 def toggle @owner.toggle update_edges end |
#update_clock ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/origen/pins/pin_clock.rb', line 48 def update_clock if update_tester_period_local update_clock_parameters cc "[PinClock] Update #{@owner.name}.clock at #{Origen.tester.cycle_count}: period=#{@clock_period_in_ns}ns, cycles=#{cycles_per_period}, duty=#{duty_str}" update_edges end end |