User guide
18-12
DirectC Interface
This example declares a C/C++ function named memory_reorg.
When we call this function the values in memory mem2 are passed to
the function. After the function executes, new values are passed to
memory mem1.
Example 8
extern void incr (inout bit [] r7);
This example declares a C/C++ function named incr. When we call
this function the value in bit r7 is passed to the function. When it
finishes executing it passes a new value to bit r7. We did not specify
a bit width for vector bit r7. This allows us to use various sizes in the
parameter declaration in the C/C++ function header.
Example 9
extern void passbig (input bit [63:0] r8,
output bit [63:0] r9);
This example declares a C/C++ function named passbig. When we
call this function the value in bit r8 is passed by reference to the
function because it is more than 32 bits; see "Using Direct Access" on
page 18-20. When it finishes executing, a new value is passed by
reference to bit r9.
Calling the C/C++ Function
After declaring the C/C++ function you can call it in your Verilog code.
You call a void C/C++ function in the same manner as you call a
Verilog task-enabling statement, that is, by entering the function
name and its arguments, either on a separate line in an always or
initial block, or in the procedural statements in a Verilog task or
function declaration. Unlike Verilog tasks, you can call a C/C++
function in a Verilog function.