User guide
18-66
DirectC Interface
This C/C++ function declares an array of type vec32. We must declare
an array for this type but we, as shown here, specify that it have only
one element. The vc_get4stMemoryVector routine copies the
data from the Verilog memory element (here specified as the 0
element) to the 0 element of the vec32 array. It always copies to the
0 element. The vc_put4stMemoryVector routine copies the data
from the vec32 array to the Verilog memory element (in this case
element 32).
The call to printf is to show you how the Verilog data is stored in
element 0 of the vec32 array.
The Verilog and C/C++ code display the following:
mem1[0]=999
mem2[0]=Z
holder[0].d is 999 holder[0].c is 0
holder[0].d is 768 holder[0].c is 1
mem1[32]=999
mem2[32]=Z
As you can see the function does copy the Verilog data from one
element to another in both memories. When the function is copying
the 999 value, the c (control) member has a value of 0; when it is
copying the 8’b0000000z value, the c (control) member has a value
of 1 because one of the control bits is 1, the rest are 0.
void vc_put4stMemoryVector(vc_handle, U indx,
vec32 *)
Copies Verilog data from a vec32 array to a Verilog memory element.
This routine is used in the previous example.