Module: RubyVPI

Defined in:
lib/ruby-vpi.rb,
lib/ruby-vpi/rcov.rb,
lib/ruby-vpi/core/edge.rb,
lib/ruby-vpi/core/callback.rb,
lib/ruby-vpi/core/scheduler.rb,
lib/ruby-vpi/core/edge-methods.rb

Overview

Defines methods for detecting all possible value changes. – Copyright 2007 Suraj N. Kurapati See the file named LICENSE for details.

Defined Under Namespace

Modules: Coverage Classes: CallbackClass, EdgeClass, SchedulerClass, Simulator

Constant Summary collapse

Project =
{
  :name    => 'ruby-vpi',
  :version => '21.1.0',
  :release => '2008-08-02',
  :website => 'http://ruby-vpi.rubyforge.org',
  :home    => File.expand_path(File.join(File.dirname(__FILE__), '..'))
}
SIMULATORS =

List of supported Verilog simulators.

[
  Simulator.new(:cver,  'GPL Cver',        '-DPRAGMATIC_CVER',  ''),
  Simulator.new(:ivl,   'Icarus Verilog',  '-DICARUS_VERILOG',  ''),
  Simulator.new(:ncsim, 'Cadence NC-Sim',  '-DCADENCE_NCSIM',   ''),
  Simulator.new(:vcs,   'Synopsys VCS',    '-DSYNOPSYS_VCS',    ''),
  Simulator.new(:vsim,  'Mentor Modelsim', '-DMENTOR_MODELSIM', ''),
]
Edge =
EdgeClass.instance
Callback =
CallbackClass.instance
Scheduler =
SchedulerClass.instance

Class Method Summary collapse

Class Method Details

.load_test(aDesignHandleOrPath, *aTestFilePaths) ⇒ Object

Loads a test to exercise a design (the given VPI handle).

  1. Creates a sandbox (an anonymous module).

  2. Defines a constant named “DUT” (which points to the given VPI handle) inside the sandbox.

  3. Loads the given test files into the sandbox.

  4. Returns the sandbox.

aDesignHandleOrPath

either a VPI handle or a path to an object in the Verilog simulation

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ruby-vpi.rb', line 51

def RubyVPI.load_test aDesignHandleOrPath, *aTestFilePaths
  # access the design under test
  design =
    if aDesignHandleOrPath.is_a? VPI::Handle
      aDesignHandleOrPath
    else
      VPI.vpi_handle_by_name(aDesignHandleOrPath.to_s, nil)
    end

  raise ArgumentError, "cannot access the design under test: #{aDesignHandleOrPath.inspect}" unless design

  # create a sandbox
  sandbox = Module.new
  sandbox.const_set :DUT, design
  sandboxBinding = sandbox.module_eval('binding')

  # load files into sandbox
  aTestFilePaths.flatten.compact.uniq.each do |path|
    if HAVE_RUBY_19X
      eval File.read(path), sandboxBinding, path
    else
      sandbox.module_eval File.read(path), path
    end
  end

  sandbox
end

.say(fmt, *args) ⇒ Object

Speaks the given message using printf().



33
34
35
# File 'lib/ruby-vpi.rb', line 33

def RubyVPI.say fmt, *args #:nodoc:
  VPI.vpi_printf("#{Project[:name]}: #{fmt}\n", *args)
end