User guide

18-64
DirectC Interface
Element mem2[0] has an X value because half of its binary value is
x and the value is displayed with the %d format specification and here
a partially unknown value is just an unknown value. After the second
call of the function, the Verilog code displays:
mem1[1]=499
mem2[0]=127
This is because before calling the function, mem1[0] had a value of
999, and after the call it has a value of 499 which is as close as it can
get to half the value with integer values.
Before calling the function, mem2[0] had a value of 8’b1111xxxx, but
the data bits for the element would all be 1s (11111111). It’s the
control bits that specify 1 from x and this routine only deals with the
data bits. So the vc_getMemoryInteger routine returned an
integer value of 255 (the integer equivalent of the binary 11111111)
to the C/C++ function, which is why the function output the integer
value 127 to mem2[0].
void vc_putMemoryInteger(vc_handle, U indx, int)
Passes an integer value to a memory element that is 32 bits or fewer.
You specify the memory by vc_handle and the element by the indx
argument. This routine is used in the previous example.
void vc_get4stMemoryVector(vc_handle, U indx,
vec32 *)
Copies the value in an Verilog memory element to an element in an
array. This routine copies both the data and control bytes. It copies
them into and array of type vec32 which is defined as follows:
typedef struct { U c; U d;} vec32;