Time unit for VPI call back on signal value change

146 Views Asked by At

In my VPI call back function, I am getting real value for time, but units for this time value depends on timescale for the module where signal resides. How I can find what units for the provided time?

Here is my monitor VPI function:

my_monitor(p_cb_data cb_data_p)
{
  unsigned int value, bit, i;

  for(bit=1,value=0,i=strlen(cb_data_p->value->value.str) ; i ;i--){
    // Convert string to  hex value
    value += cb_data_p->value->value.str[i-1]=='1' ? bit : 0; // TODO: Check for other values?
    bit *= 2;
  }
  // Save to trace file
  fprintf(pv_file_trace,"%15f(?s): %s = %s 0x%X\n",
  cb_data_p->time->real,
  cb_data_p->user_data,
  cb_data_p->value->value.str, value);

}
1

There are 1 best solutions below

1
On

Assuming the signal is declared in a module, you can do

ts = vpi_get(vpiTimeUnit, vpi_handle(vpiModule, cb_data_p->obj));

I could not find I documented, but ts is in the scale of 10-ts in seconds