user2756376
user2756376

Reputation: 117

How to add a new key to a Systemverilog associative array using VPI

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?

Upvotes: 0

Views: 1105

Answers (1)

dave_59
dave_59

Reputation: 42698

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.

Upvotes: 1

Related Questions