0

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);

}
toolic
  • 57,801
  • 17
  • 75
  • 117
albert waissman
  • 39
  • 1
  • 2
  • 6

1 Answers1

0

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

dave_59
  • 39,096
  • 3
  • 24
  • 63