Class: RubyVPI::SchedulerClass::Routine

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(*aLogicArgs, &aLogicBody) ⇒ Routine

Returns a new instance of Routine.

Raises:

  • (ArgumentError)


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.

Returns:

  • (Boolean)


151
152
153
# File 'lib/ruby-vpi/core/scheduler.rb', line 151

def done?
  not pause?
end

#pauseObject

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.

Returns:

  • (Boolean)


136
137
138
# File 'lib/ruby-vpi/core/scheduler.rb', line 136

def pause?
  @gen.next?
end

#resumeObject

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