Class: Origen::Pins::Pin
- Inherits:
-
Object
- Object
- Origen::Pins::Pin
- Defined in:
- lib/origen_sim/origen/pins/pin.rb
Overview
Override the Origen pin model so we can hook into all changes to pin states
Instance Attribute Summary collapse
-
#simulation_index ⇒ Object
The index number that is used to refer to the pin within the simulation.
Instance Method Summary collapse
- #_orig_initialize ⇒ Object
- #_orig_set_state ⇒ Object
- #_orig_set_value ⇒ Object
- #_orig_state= ⇒ Object
- #apply_force ⇒ Object
-
#initialize(id, owner, options = {}) ⇒ Pin
constructor
A new instance of Pin.
- #reset_simulator_state ⇒ Object
- #set_state(val) ⇒ Object
- #set_value(val) ⇒ Object
- #simulation_running? ⇒ Boolean
- #simulator ⇒ Object
-
#simulator_needs_update? ⇒ Boolean
Returns true if the current pin state is different to that last given to the simulator.
- #state=(val) ⇒ Object
-
#update_simulation ⇒ Object
Applies the current pin state to the simulation, this is triggered everytime the pin state or value changes.
Constructor Details
#initialize(id, owner, options = {}) ⇒ Pin
Returns a new instance of Pin.
10 11 12 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 10 def initialize(id, owner, = {}) _orig_initialize(id, owner, ) end |
Instance Attribute Details
#simulation_index ⇒ Object
The index number that is used to refer to the pin within the simulation
7 8 9 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 7 def simulation_index @simulation_index end |
Instance Method Details
#_orig_initialize ⇒ Object
9 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 9 alias_method :_orig_initialize, :initialize |
#_orig_set_state ⇒ Object
21 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 21 alias_method :_orig_set_state, :set_state |
#_orig_set_value ⇒ Object
14 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 14 alias_method :_orig_set_value, :set_value |
#_orig_state= ⇒ Object
28 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 28 alias_method :_orig_state=, :state= |
#apply_force ⇒ Object
54 55 56 57 58 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 54 def apply_force if force simulator.put("2^#{simulation_index}^#{force}") end end |
#reset_simulator_state ⇒ Object
49 50 51 52 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 49 def reset_simulator_state @simulator_state = nil @simulator_value = nil end |
#set_state(val) ⇒ Object
22 23 24 25 26 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 22 def set_state(val) ret = _orig_set_state(val) update_simulation if simulation_running? ret end |
#set_value(val) ⇒ Object
15 16 17 18 19 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 15 def set_value(val) ret = _orig_set_value(val) update_simulation if simulation_running? ret end |
#simulation_running? ⇒ Boolean
35 36 37 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 35 def simulation_running? tester && tester.is_a?(OrigenSim::Tester) end |
#simulator ⇒ Object
39 40 41 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 39 def simulator OrigenSim.simulator end |
#simulator_needs_update? ⇒ Boolean
Returns true if the current pin state is different to that last given to the simulator
44 45 46 47 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 44 def simulator_needs_update? return false if state == :dont_care && @simulator_state == :dont_care state != @simulator_state || value != @simulator_value end |
#state=(val) ⇒ Object
29 30 31 32 33 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 29 def state=(val) ret = _orig_state = (val) update_simulation if simulation_running? ret end |
#update_simulation ⇒ Object
Applies the current pin state to the simulation, this is triggered everytime the pin state or value changes
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/origen_sim/origen/pins/pin.rb', line 62 def update_simulation return if force || !simulation_index || !tester.timeset || !simulator_needs_update? case state when :drive @simulator_state = :drive @simulator_value = value simulator.put("2^#{simulation_index}^#{value}") when :compare @simulator_state = :compare @simulator_value = value simulator.put("4^#{simulation_index}^#{value}") when :dont_care @simulator_state = :dont_care simulator.put("5^#{simulation_index}") when :capture @simulator_state = :capture simulator.put("e^#{simulation_index}") when :drive_very_high, :drive_mem, :expect_mem, :compare_midband fail "Simulation of pin state #{state} is not implemented yet!" else fail "Simulation of pin state #{state} is not implemented yet!" end end |