User guide

18-4
DirectC Interface
There are two access modes for C/C++ function calls. These modes
don’t make much difference in your Verilog code; they only pertain
to the development of the C/C++ function. They are as follows:
The slightly more efficient direct access mode - This mode has
rules for how values of different types and sizes are passed to
and from Verilog and C/C++. This mode is explained in detail in
"Using Direct Access" on page 18-20
The slightly less efficient but with better error handling abstract
access mode - In this implementation VCS creates a descriptor
for each actual parameter of the C function. You access these
descriptors using a specially defined pointer called a handle. All
formal arguments are handles. DirectC comes with a library of
accessory functions for using these handles. This mode is
explained in detail in "Using Abstract Access" on page 18-29
The abstract access library of accessory functions contains
operations for reading and writing values and for querying about
argument types, sizes, etc. An alternative library, with perhaps
different levels of security or efficiency, can be developed and used
in abstract access without changing your Verilog or C/C++ code.
If you have an existing C/C++ function that you want to use in a Verilog
design you consider using direct access and see if you really need
to edit your C/C++ function or write a wrapper so that you can use
direct access inside the wrapper. There is a small performance gain
by using direct access compared to abstract access.
If you are about to write a C/C++ function to use in a Verilog design,
first decide how you wish to use it in your Verilog code and write the
external declaration for it, then decide which access mode you want.
You can change the mode later with perhaps a small change in your
Verilog code.