Module: VPI
- Included in:
- Handle
- Defined in:
- lib/ruby-vpi/core.rb,
lib/ruby-vpi/core/edge.rb,
lib/ruby-vpi/core/handle.rb,
lib/ruby-vpi/core/struct.rb,
lib/ruby-vpi/core/callback.rb,
lib/ruby-vpi/core/scheduler.rb
Overview
VPI structures (S_vpi_* and S_cb_*) stuff – Copyright 2006 Suraj N. Kurapati See the file named LICENSE for details.
Defined Under Namespace
Classes: Handle, S_vpi_time, S_vpi_value
Constant Summary collapse
- INTEGER_BITS =
Number of bits in PLI_INT32.
32- INTEGER_LIMIT =
Lowest upper bound of PLI_INT32.
2 ** INTEGER_BITS
- INTEGER_MASK =
Bit-mask capable of capturing PLI_INT32.
INTEGER_LIMIT - 1
Class Method Summary collapse
- .__callback__vpi_register_cb ⇒ Object
- .__callback__vpi_remove_cb ⇒ Object
-
.__scheduler__vpi_put_value ⇒ Object
intercept all writes to VPI handles so that they can be applied later by the scheduler.
Instance Method Summary collapse
-
#advance_time(aNumTimeSteps = 1) ⇒ Object
(also: #wait)
Wait until the simulation advances by the given number of time steps.
-
#always(*aBlockArgs, &aBlock) ⇒ Object
(also: #forever)
Wraps the given block inside an infinite loop and executes it inside a new concurrent process (see the VPI::process method).
-
#current_time ⇒ Object
Returns the current simulation time.
-
#process(*aBlockArgs, &aBlock) ⇒ Object
Creates a new concurrent process, which will execute the given block with the given arguments, and returns it.
-
#vpi_put_value(*args) ⇒ Object
:nodoc:.
-
#vpi_register_cb(aData, &aHandler) ⇒ Object
This is a Ruby version of the vpi_register_cb C function.
-
#vpi_remove_cb(aData) ⇒ Object
:nodoc:.
Class Method Details
.__callback__vpi_register_cb ⇒ Object
111 |
# File 'lib/ruby-vpi/core/callback.rb', line 111 alias_method :__callback__vpi_register_cb, :vpi_register_cb |
.__callback__vpi_remove_cb ⇒ Object
129 |
# File 'lib/ruby-vpi/core/callback.rb', line 129 alias_method :__callback__vpi_remove_cb, :vpi_remove_cb |
.__scheduler__vpi_put_value ⇒ Object
intercept all writes to VPI handles so that they can be applied later by the scheduler
184 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 184 alias_method :__scheduler__vpi_put_value, :vpi_put_value |
Instance Method Details
#advance_time(aNumTimeSteps = 1) ⇒ Object Also known as: wait
Wait until the simulation advances by the given number of time steps.
198 199 200 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 198 def advance_time aNumTimeSteps = 1 aNumTimeSteps.times { RubyVPI::Scheduler.pause_current_routine } end |
#always(*aBlockArgs, &aBlock) ⇒ Object Also known as: forever
Wraps the given block inside an infinite loop and executes it inside a new concurrent process (see the VPI::process method).
213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 213 def always *aBlockArgs, &aBlock process do loop do startTime = VPI.current_time aBlock.call(*aBlockArgs) finishTime = VPI.current_time advance_time unless finishTime > startTime end end end |
#current_time ⇒ Object
Returns the current simulation time.
193 194 195 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 193 def current_time RubyVPI::Scheduler.current_time end |
#process(*aBlockArgs, &aBlock) ⇒ Object
Creates a new concurrent process, which will execute the given block with the given arguments, and returns it.
207 208 209 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 207 def process *aBlockArgs, &aBlock RubyVPI::Scheduler.register_routine(*aBlockArgs, &aBlock) end |
#vpi_put_value(*args) ⇒ Object
:nodoc:
187 188 189 |
# File 'lib/ruby-vpi/core/scheduler.rb', line 187 def vpi_put_value *args #:nodoc: RubyVPI::Scheduler.capture_write(*args) end |
#vpi_register_cb(aData, &aHandler) ⇒ Object
This is a Ruby version of the vpi_register_cb C function. It is identical to the C function, except for the following differences:
-
This method accepts a block (callback handler) which is executed whenever the callback occurs.
-
This method overwrites the
cb_rtnanduser_datafields of the givenS_cb_dataobject.
123 124 125 126 |
# File 'lib/ruby-vpi/core/callback.rb', line 123 def vpi_register_cb aData, &aHandler # :yields: VPI::S_cb_data raise ArgumentError, "block must be given" unless block_given? RubyVPI::Callback.attach(aData, &aHandler) end |
#vpi_remove_cb(aData) ⇒ Object
:nodoc:
132 133 134 |
# File 'lib/ruby-vpi/core/callback.rb', line 132 def vpi_remove_cb aData # :nodoc: RubyVPI::Callback.detach(aData) end |