Class: Origen::Pins::PinClock

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/pins/pin_clock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @owner = owner
  @running = false

  @clock_period_in_ns = 0
  @tester_period_in_ns = 0

  update_clock_period(options)
  update_tester_period_local
  update_clock_parameters
end

Instance Attribute Details

#cycles_per_dutyObject (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_edgeObject (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_edgeObject (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_periodObject

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_clockObject



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

Returns:

  • (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(options = {})
  # 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(options)
  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(options = {})
  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

#toggleObject



60
61
62
63
# File 'lib/origen/pins/pin_clock.rb', line 60

def toggle
  @owner.toggle
  update_edges
end

#update_clockObject



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