User guide

18-57
DirectC Interface
for ( i = 0; i < 8; i++){
memcpy(p2,p1,8);
p2 += 8;
}
}
The purpose of the C/C++ function mem_doer is to copy the four
elements in Verilog memory memory1 into the 32 elements of
memory2.
The vc_MemoryRef routines return pointers to the Verilog memories
and the machine memory locations they point to are also pointed to
by pointers p1 and p2. Pointer p1 points to the location of Verilog
memory memory1, and p2 points to the location of Verilog memory
memory2.
The function uses a for loop to copy the data from Verilog memory
memory1 to Verilog memory memory2. It uses the standard memcpy
function to copy a total of 64 bytes by copying eight bytes eight times.
Why copy a total of 64 bytes? Each element of memory2 is only two
bits wide, but for every eight bits in an element in machine memory
there are two bytes, one for data and another for control. The bits in
the control byte specify whether the data bit with a value of 0 is actually
0 or Z, or whether the data bit with a value of 1 is actually 1 or X.
Figure18-9 Storing Verilog Memory Elements in Machine Memory
012345
data data data
data control control control control
6
7