0

I'm implementing Verilog "force" and "release" using VPI so that they can be called from C routines. To force a value to a vector net, I need to create an array of s_vpi_vecval for value_p. I allocated a storage for the array and populated it with the value I want. Then I used vpi_put_value() to force the vector value to the net.

The standard, IEEE 1800, clearly says that the calling routine needs to allocate a space for such structure for value_p. But it didn't say when it is safe to free the storage. Is it safe to free the storage just after calling vpi_put_value()?

I assume, the vpi_put_value() will keep a copy of the force value in their side. Any insights to this are greatly appreciated.

user2756376
  • 117
  • 9

1 Answers1

1

I think it is safe to assume you can free the memory after making the VPI call - this is how all other VPI routines work.

You can easily test this by making two calls to dpi_put_value() using the same struct pointer.

I've put in a request to have the IEEE standard clarified.

dave_59
  • 39,096
  • 3
  • 24
  • 63
  • Thanks, Dave, for your prompt Answer. My code does free the storage after the call and is working fine. I think you are correct. Hope the standard is more clearer about the calling routine side storage management. – user2756376 Mar 01 '18 at 01:38
  • I know that it is safe with vcs. I think the other vendors should do this too. – Serge Mar 01 '18 at 15:24