User guide
18-23
DirectC Interface
If return_reg() is a C++ function, it must be protected from name
mangling, as follows:
extern "C" scalar return_reg(scalar reti);
Note:
The extern "C" directive has been omitted in subsequent
examples, for brevity.
A scalar reg is passed by value to the function so the parameter is
not a pointer. The parameter’s type is scalar.
Example 2
Consider the following C/C++ function declared in the Verilog source
code:
extern "C" bit [7:0] return_vector_bit (bit [7:0] r3);
Here the function named return_vector_bit returns the value of
a vector bit. The "C" entry specifies direct access. Typically a
declaration includes this when some other functions use abstract
access. The value of an 8-bit vector bit is passed to it. The header of
the C/C++ function is as follows:
U return_vector_bit(U returner);
A vector bit is passed by value to the function because the vector bit
is less than 33 bits so the parameter is not a pointer. The parameter’s
type is U.