1

My test.sv code contains interface and module as shown:

 interface Bus;
   logic [7:0] sig1;
   logic [15:0] sig2;
   logic sig3;
 endinterface

 module test();
   Bus inst();
   ...
 endmodule

I have given the vpiFullName test.inst.sig1 to the vpi_handle_by_name

 vpiHandle it1, it2, it3;

 it1 = vpi_handle_by_name("test.inst.sig1", NULL);
 func(it1, vpiBit);
 it2 = vpi_handle_by_name("test.inst.sig2", NULL);
 func(it2, vpiBit);
 it3 = vpi_handle_by_name("test.inst.sig3", NULL);
 func(it3, vpiBit);

 static void
 func(vpiHandle net, PLI_INT32 nettype)
 {
    char *name = vpi_get_str(vpiFullName, net);

    auto size = vpi_get(vpiSize, net);
    ...
 }

But I'm extracting the strings (sig1, sig2,...) from a file and storing it in an array arr. I want to pass these strings in the form of array to vpi_handle_by_name like this:

 vector <std::string> arr;

 it1 = vpi_handle_by_name(arr[0], NULL);
 func(it1, vpiBit);
 it2 = vpi_handle_by_name(arr[1], NULL);
 func(it2, vpiBit);
 ...

Is it possible to do this?

anu
  • 89
  • 1
  • 7
  • `vpi_handel_by_name`'s first argument type is `PLI_BYTE8 *` (where `PLI_BYTE8` is a typedef of `char`). `char* != std::string` – Greg Aug 01 '17 at 00:09
  • vpi functions expect 'c' strings. So, you wold need to do `arr[0].c_str()`. And if you use c++, you would need to cast it to `PLI_BYTE8*` when passing to the vpi function to avoid compilation warnings. – Serge Aug 01 '17 at 01:00
  • Even after casting to `(PLI_BYTE8 *)(arr[0].c_str())` , `vpi_get_str` is not obtaining the string in `arr[0]` i.e; `name` is not getting the string present in `arr[0]`. – anu Aug 01 '17 at 07:01

0 Answers0