Building and running a sample PLI application for VeriLogger Extreme
--------------------------------------------------------------------

VPI (also called PLI 2.0) is a C-based interface for communicating
with Verilog simulators (including VeriLogger Extreme). Users create
a VPI application that will be loaded by the Verilog simulator via
dynamic linking (dll's in Windows or shared libraries on Unix).
Note: VeriLogger also supports the older PLI 1.0 standard (tf/acc
functions).

This example, vpi_test, is a VPI application that registers 
several user-defined tasks that can be called from Verilog
source code. The main purpose of these tasks is to test
the VPI functionality of a simulator and demonstrate the
usage of VPI C calls. The code for registering the tasks
is located in vpi_dll.c. 

The most important of these tasks is:

$traverse_top_modules

which will dump information about all the design objects in a 
simulation to the simulation log. For example, to dump the vpi
structure of a verilog design, add these lines to one of your
Verilog modules to call this function at the start of your
simulation run:

initial
  $traverse_top_modules;

Selecting an appropriate C/C++ compiler
---------------------------------------
VeriLogger Extreme ships with two versions of the simulator:
a 32-bit simulator called simx32 and a 64-bit simulator called
simx64. You must use an appropriate
version of your C/C++ compiler to build a compatible PLI application
(i.e. a 32bit PLI application for simx32 or a 64bit PLI application for
simx64). Note that 32bit applications will run on 64bit systems,
so for maximum cross-platform compatibility use the 32bit simulator.

To compile and run vpi_test on Windows using MS Visual Studio:
--------------------------------------------------------------
1. Open vpitest.sln and build the "Release" configuration (the "Debug"
   configuration will not build) using MS Visual Studio. If you
   use a later version of MS Visual Studio, you will be prompted to
   convert the solution to the later version's project format. This
   will generate vpitest.dll to the SynaptiCAD\bin directory. If you
   have installed SynaptiCAD in a "read-only" directory, you will need
   to specify an alternative destination for vpitest.dll and modify
   the next step accordingly to point to this dll.  
NEXT, EITHER:   
2. From the command-line, run the simulator: 
     simx +loadvpi=vpitest.dll c:\Synapticad\vpi_test\test.v

   Note: If vpitest.dll is in a different directory, you can specify an
   absolute or relative path in the +loadvpi argument, or you can 
   add the path to vpitest.dll to your PATH environment
   variable.   
OR:
2. From the BugHunter GUI, create a project with a verilog design.
3. Open the Project>Project Simulation Properties dialog, click on the
   Verilog tab, and add the option:
   +loadvpi=vpitest.dll 
   to both the compile and Simulator edit box options (the first option
   is required to successfully compile the source file that calls 
   $traverse_top_modules, the second option is required to run
   the simulation that uses this call).

Note: When building, you may see the following warnings:

'vpiHandle' differs in levels of indirection from 'void *'
'vpiHandle64' differs in levels of indirection from 'void *'

These warnings are benign and can safely be ignored.

To compile and run On UNIX:
---------------------------
1. edit the Makefile and change the SYNCAD_VPI_DIR variable to point
   to the root of your SynaptiCAD installation (e.g. /usr/local/syncad)
2. run "make" to generate the library libvpitest.so
3. run the simulator "simx +loadvpi=libvpitest.so test.v"

   If libvpitest.so is in a different directory, you can specify an
   absolute or relative path in the +loadvpi argument, or you can 
   add the path to libvpitest.so to your LD_LIBRARY_PATH environment
   variable.  When compiling your own PLI 2.0 applications, if your
   PLI application links against other shared libraries, make sure
   the operating system can find them by adding the required
   directories to the LD_LIBRARY_PATH environment variable.

Note: This VPI application has configurations for simx 
and ncverilog only, so minor changes will be needed in the compile process
for other simulators. In particular, you will need to point to the proper
vendor's vpi_user.h and link to the vendor-provided vpiruntime lib.

Notes on SynaptiCAD's VPI interface:
------------------------------------
SynaptiCAD's Verilog Extreme simulator's PLI 2.0 interface can be
accessed in two different modes.  By default, PLI applications will
communicate with the simulator using a standards-compliant interface
in which vpiHandle is defined as a 32-bit type.  The simulator also
supports a source-compatible interface where vpiHandle is defined as a
64-bit type.  This interface has a lower per-call overhead, but is
otherwise identical.  To use this interface, define the symbol
SYNCAD_VPI when compiling your PLI library.  In either case, the PLI
application must be compiled as a 32-bit DLL or shared library.

Note: This define is ignored in the 64-bit version of Extreme as
handles are automatically 64bits in size per the Verilog LRM.

Notes on writing your PLI application
-------------------------------------

The header files to include in your PLI application are located
in your SynaptiCAD installation directory under the subdirectory:

simxkernel\src\vpi\rh
(for example on Windows, it's probably in c:\synapticad\simxkernel\src\vpi\rh)

To use vpi functions in your PLI application, include the vpi_user.h
file located in this directory.
To use tf functions, include the veriuser.h file.
To use acc functions, include the acc_user.h file.

Some SynaptiCAD-specific functions can also be used by including these
files: acc_user_syncad.h and vpi_user_syncad.h.

