So I have the following register defined in my verilog
reg [31:0] register_mem [0:15]/* verilator public */;
My goal is from my verilator c++ code to read each of the 16 values stored in it.
I have found that the documentation for this VPI stuff is rather difficult to find. I still cannot figure out what a t_vpi_vecval
is and what its parameters are or if it is even the right approach.
Here is my approach at reading the 5th value in the register
unsigned int read_regs() {
const std::string path = "TOP.TOP.cpu.reg_file.register_mem";
vpiHandle vh1 = vpi_handle_by_name((PLI_BYTE8*)path.c_str(), NULL);
if (!vh1) {
printf("Name %s", path.c_str());
vl_fatal(__FILE__, __LINE__, "sim_main", "No handle found: ");
}
const char* name = vpi_get_str(vpiName, vh1);
s_vpi_value v;
v.format = vpiVectorVal;
vpi_get_value(vh1, &v);
return v.value.vector[4].aval;
}
No-matter what I do here the method returns 0 suggesting that I am not looking at the register_mem array.
What am I doing wrong?