User guide

18-28
DirectC Interface
You can copy from these extern declarations to the function headers
in your C code. If you do you will always use the right type of parameter
in your function header and you don’t have to learn the rules for direct
access. Let VCS do this for you.
Access Routines for Multi-Dimensional Arrays
DirectC requires that Verilog multi-dimensional arrays be linearized
(turned into arrays of the same size but with only one dimension).
VCS provides routines for obtaining information about Verilog
multi-dimensional arrays when using direct access. This section
describes these routines.
UB *vc_arrayElemRef(UB*, U, ...)
The UB* parameter points to an array, either a single dimensional
array or a multi-dimensional array, and the U parameters specify
indices in the multi-dimensional array. This routine returns a pointer
to an element of the array or NULL if the indices are outside the range
of the array or there is a null pointer.
U dgetelem(UB *mem_ptr, int i, int j) {
int indx;
U k;
/* remaining indices are constant */
UB *p = vc_arrayElemRef(mem_ptr,i,j,0,1);
k = *p;
return(k);
}
There are specialized versions of this routine for one, two, and three
dimensional arrays:
UB *vc_array1ElemRef(UB*, U)