Class: RubyVPI::SchedulerClass::Routine
- Inherits:
-
Object
- Object
- RubyVPI::SchedulerClass::Routine
- Defined in:
- lib/ruby-vpi/core/scheduler.rb
Overview
Represents Verilog’s “process block” construct (a coroutine or concurrent process), which is used as the body of an “initial” or “forever” block.
Instance Method Summary collapse
-
#done? ⇒ Boolean
Returns true if this process block is finished (it cannot be resumed anymore).
-
#initialize(*aLogicArgs, &aLogicBody) ⇒ Routine
constructor
A new instance of Routine.
-
#pause ⇒ Object
Pauses the execution of this process block.
-
#pause? ⇒ Boolean
Returns true if this process block is currently paused and can thus be resumed.
-
#resume ⇒ Object
Resumes the execution of this process block.
Constructor Details
#initialize(*aLogicArgs, &aLogicBody) ⇒ Routine
Returns a new instance of Routine.
116 117 118 119 120 121 122 123 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 116 def initialize *aLogicArgs, &aLogicBody raise ArgumentError unless block_given? @gen = Generator.new do |@ctl| pause # until we are ready to begin aLogicBody.call(*aLogicArgs) end end |
Instance Method Details
#done? ⇒ Boolean
Returns true if this process block is finished (it cannot be resumed anymore).
Must be called from outside the logic of this process block.
151 152 153 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 151 def done? not pause? end |
#pause ⇒ Object
Pauses the execution of this process block.
Must be called from inside the logic of this process block.
128 129 130 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 128 def pause @ctl.yield nil end |
#pause? ⇒ Boolean
Returns true if this process block is currently paused and can thus be resumed.
Must be called from outside the logic of this process block.
136 137 138 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 136 def pause? @gen.next? end |
#resume ⇒ Object
Resumes the execution of this process block.
Must be called from outside the logic of this process block.
143 144 145 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 143 def resume @gen.next end |