User guide

18-24
DirectC Interface
Example 3
Consider the following C/C++ function declared in the Verilog source
code:
extern void receive_pointer ( input pointer r6 );
Here the function named receive_pointer does not return a
value. The argument passed to it is declared to be a pointer. The
header of the C/C++ function is as follows:
void receive_pointer(*pointer_receiver);
A pointer is passed by value to the function so the parameter is a
pointer of type void, a generic pointer. Here we don’t need to know
the type of data that it points to.
Example 4
Consider the following C/C++ function declared in the Verilog source
code:
extern void memory_rewriter (input bit [1:0] array [1:0]
mem2, output bit [1:0] array [1:0] mem1);
Here the function named memory_rewriter has two arguments,
one declared as an input, the other as an output. Both arguments are
bit memories. The header of the C/C++ function is as follows:
void memory_rewriter(UB *out[2],*in[2]);
Memories are always passed by reference to a C/C++ function so
the parameter named in is a pointer of type UB with the size that
matched the memory range. The parameter named out is also a
pointer because its corresponding argument is declared to be output.
Its type is also UB because it outputs to a Verilog memory.