No description
Find a file
2022-01-26 10:37:05 -05:00
includes Change the directory structure again 2021-05-12 22:52:19 -04:00
sv Refactor: SV vpiHandle -> VpiHandle 2021-05-13 13:19:00 -04:00
svvpi Refactor: SV vpiHandle -> VpiHandle 2021-05-13 13:19:00 -04:00
tests/basic Support doc strings under vpiDefine macro calls 2021-05-14 13:41:23 -04:00
wrapper Removing backports of deprecated consts 2021-05-14 20:28:44 -04:00
.gitignore Add makefiles 2021-05-07 14:17:56 -04:00
config.nims Fix 'nim wrap' 2021-05-13 01:15:48 -04:00
LICENSE Add MIT License 2021-04-30 13:45:21 -04:00
makefile Add makefiles 2021-05-07 14:17:56 -04:00
README.org Update installation instructions 2021-05-24 07:32:50 -04:00
svvpi.nim Fix logic by using break instead of continue when 1st arg is nullOp 2021-06-12 11:14:03 -04:00
svvpi.nimble Bump version 2022-01-26 10:37:05 -05:00

Wrapper for SystemVerilog VPI headers sv_vpi_user.h and vpi_user.h

Installation

nimble install svvpi

How to get nimble?

Get Nim installation (which includes nimble) from https://nim-lang.org/install.html.

Requirements

User needs to have access to some Verilog/SystemVerilog simulator supporting VPI, like Cadence Xcelium.

Macros

vpiDefine

Defining a system task

vpiDefine task <sys task>:
  setup: # optional
    # declarations of consts that you want to be made available to all procs
  compiletf: # optional
    # body of compiletf proc
  calltf:
    # body of calltf proc
  userdata: # optional
    # string
  more: # optional
    # further code like callback proc definitions and registering those.

At minimum, only the calltf is needed. Here's one example:

vpiDefine task hello:
  calltf:
    vpiEcho "Hello!"

Defining a system function

vpiDefine function <sys function>:
  setup: # optional
    # declarations of consts that you want to be made available to all procs
  compiletf: # optional
    # body of compiletf proc
  calltf:
    # body of calltf proc
  functype: # optional
    # Valid values: vpiIntFunc, vpiRealFunc, vpiTimeFunc, vpiSizedFunc, vpiSizedSignedFunc
    # If this is not specified, and sizetf is not specified, it defaults to vpiIntFunc.
    # If this is not specified, but sizetf is specified, it defaults to vpiSizedFunc.
  sizetf: # optional
    # integer
    # If this is specified, but functype is not specified, the latter defaults to vpiSizedFunc.
  userdata: # optional
    # string
  more: # optional
    # further code like callback proc definitions and registering those.

At minimum, only the calltf is needed. Here's one example:

vpiDefine function hello:
  calltf:
    vpiEcho "Hello!"

Special variables

Variable Description
userData If a vpiDefine has set userdata: <some string>, that string is available as this variable inside compiletf:, calltf: and sizetf:.
systfHandle This VpiHandle variable is available inside compiletf: and calltf:.
tfName This string const is the task/function identifier with a $ prefix. So if you have vpiDefine task mytask, this variable is set to $mytask. This variable is available anywhere in the vpiDefine scope.

Examples

See my nim-systemverilog-vpi repo for example uses of vpiDefine.

Templates

vpiException

Calling this template raises a VpiTfError type exception.

Example usage:

if argIter == nil:
  vpiException &"{tfName} requires 1 argument; has none"

Versions tested

Cadence Xcelium
20.09-s09
OS
CentOS 7.6
Nim
1.5.1 as of 2021-04-30 Fri.