User guide
E-12
PLI Access Routines
Examples
The following code examples illustrates the use of
acc_setmem_hexstr:
• Example D-4 shows the C source code for an application that calls
acc_setmem_hexstr.
• Example D-5 shows the contents of a data file read by the
application.
• Example D-6 shows the PLI table file that associates the
user-defined system task in the Verilog code with the application.
• Example D-7 shows the Verilog source that calls the application.
Example D-4 C Source Code For an Application Calling
acc_setmem_hexstr
#include <stdio.h>
#include "acc_user.h"
#include "vcsuser.h"
#define NAME_SIZE 256
#define len 100
pli()
{
FILE *infile;
char memory_name[NAME_SIZE] ;
char value[len];
handle memory_handle;
int row,start;
infile = fopen("initfile","r");
while ( fscanf(infile,"%s %s %d %d ",
memory_name,value,&row,&start) != EOF )
{
printf("The mem= %s \n value= %s \n row= %d \n start= %d \n ",
memory_name,value,row,start);
memory_handle=acc_handle_object(memory_name);
acc_setmem_hexstr(memory_handle,value,row,start);
}
}