ASIC/FPGA Design and Verification Out Source Services
A simple c-code program to read a memory array from verilog RTL, using
VPI.
-
The former
page
discussed the simple verilog file, which served as the example's DUT. This
one describes the c code, which reads a memory array from the verilog
DUT.
-
This pages only explains how the read is done. The c code registration is
discussed in other examples (
my first hello world: VPI,
a sparse memory model: VPI
), which are also available on the site.
-
The c code gets the left and right addresses of the verilog array and starts
a read loop.
...
argh = vpi_scan(args_iter);
argval.format = vpiIntVal;
vpi_get_value(vpi_handle(vpiLeftRange, argh), &argval);
left_addr = argval.value.integer;
argval.format = vpiIntVal;
vpi_get_value(vpi_handle(vpiRightRange, argh), &argval);
right_addr = argval.value.integer;
vpi_printf("the address range is %x %x\n", left_addr, right_addr);
vpiHandle h3;
s_vpi_value ar_da;
for(ix_addr=left_addr; ix_addr <= right_addr; ix_addr++) {
h3 = vpi_handle_by_index(argh, ix_addr);
ar_da.format = vpiIntVal;
vpi_get_value (h3, &ar_da);
vpi_printf("the value is %d\n", ar_da.value.integer);
}
...
-
Go to the next
page
to read the description on the compilation script and download the code.
|