User guide

18-69
DirectC Interface
char *vc_MemoryString(vc_handle, U indx)
This routine works like the vc_toString routine except that it is for
passing values to from memory element instead of to a reg or bit. You
enter an argument to specify the element (index) whose value you
want the routine to pass. For example:
extern void memcheck_vec(inout reg[] array[]);
module top;
reg [0:7] mem[0:7];
integer i;
initial
begin
for(i=0;i<8;i=i+1) begin
mem[i] = 8’b00000111;
$display("Verilog code says \"mem [%0d] = %0b\"",
i,mem[i]);
end
memcheck_vec(mem);
end
endmodule
The C/C++ function that calls vc_MemoryString is as follows:
#include <stdio.h>
#include "DirectC.h"
void memcheck_vec(vc_handle h)
{
int i;
for(i= 0; i<8;i++) {
printf("C/C++ code says \"mem [%d] is %s
\"\n",i,vc_MemoryString(h,i));