User guide

18-58
DirectC Interface
In an element in a Verilog memory, for each eight bits in the element
there is a data byte and a control byte with an additional set of bytes
for remainder bit, so if a memory had 9 bits it would need two data
bytes and two control bytes. If it had 17 bits it would need three data
bytes and three control bytes. All the data bytes precede the control
bytes.
Therefore memory1 needs 8 bytes of machine memory (four for data
and four for control) and memory2 needs 64 bytes of machine
memory (32 for data and 32 for control). Therefore the C/C++ function
needs to copy 64 bytes.
The Verilog code displays the following:
memory2[31]=3
UB *vc_MemoryElemRef(vc_handle, U indx)
Returns a pointer to an element (word, address or index) of a Verilog
memory. You specify the vc_handle of the memory and the element.
For example:
extern void mem_elem_doer( inout reg [25:1] array [3:0]
memory1);
module top;
reg [25:1] memory1 [3:0];
initial
begin
memory1 [0] = 25’bz00000000xxxxxxxx11111111;
$display("memory1 [0] = %0b\n", memory1[0]);
mem_add_doer(memory1);
$display("\nmemory1 [3] = %0b", memory1[3]);
end
endmodule