0

I'm trying to access Systemverilog associative array from C using VPI. I can write a value to an array element for a key using the following code if the key is already there.

index = vpi_handle_by_index(reg_array, 200); // 200 is an existing key
vpi_value.format = vpiIntVal;
vpi_value.value.integer = (PLI_INT32)array_var_val;
vpi_put_value(index, &vpi_value, NULL, vpiNoDelay);

vpi_handle_by_index() returns a NULL if a key doesn't exist already. My question is how can I add a new key to an associative array?

Similarly, I also want to push a value to a Systemverilog Queue using VPI. How can I implement push_back(val) method using VPI?

user2756376
  • 117
  • 9

1 Answers1

1

There is no way to modify the size of a dynamic array/queue through the VPI. The SystemVerilog VPI is missing many features that deal with dynamically allocated arrays.

The VPI is mainly a tool interface that interacts with the existing design database. You should be using the DPI as a modeling/inter-language interface.

dave_59
  • 39,096
  • 3
  • 24
  • 63
  • Thanks, Dave. That is not the answer I wanted to hear but at least I don't need to spend more time looking for something that doesn't exist. – user2756376 Aug 08 '18 at 21:38
  • @dave_59 Is there a good example of dealing with SV associative arrays in C via DPI-C? Thanks. – Kaushal Modi Apr 22 '19 at 12:04
  • Bu using the DPI, I meant you can export a SystemVerilog function to C and call it from your C code to deal with any SystemVerilog construct. You can create function wrappers around any datatype, then pass key/value pairs to read or write the array, – dave_59 Apr 22 '19 at 15:02