VPI to modify $display and $write statements

There are some ERROR messages in TSMC memory model files that are written using $display and $write statements. Is there a way to contol/modify these messages ?

I was thinking of something like the following using VPI’s:

  1. When a system task is called, it will modify the messages from $display/$write from specific modules.
  2. When another system task is called, it will disable the VPI and messages will be printed without modification.

Any suggestions on how to do this ? Perhaps using VPI callbacks ?

In reply to Shanmugam5577:

Most system tasks/functions can be overridden by simply registering a new VPI routine with the same name (Check your tool’s User Manual for any optimizations you may have to disable).

You can use a special string like “modification on/off” to control when to make the modifications. The only problem is it’s easy to format the output with the modifications you want, but it’s much more difficult to recreate the original unmodified output. That’s because SystemVerilog $display format strings are not completely compatible with C printf format strings. For example, there is no binary %b format in C. You would have to parse the format string and write your own conversion routines.

It might be easer to post-process the log file with you favorite scripting language.

In reply to dave_59:

Thanks Dave.

Could you please elaborate on how to use “modification on/off” ?

In reply to shan_hyr:

It was just I thought I had instead of having a separate system task to control turning on or off whatever modifications you want, you could check the first argument to $display as a special code to do the same. Probably not worth the bother.