Is there a way to use/execute the printf based debug information from the C Test in CPU

Hello !

  1. Typically in order to debug any CPU based C-tests, we depend on the tarmac logs → check for the execution PC numbers etc. which is slightly cumbersome or so.

  2. But is there any way where we can directly use the printf based debug prints inside the C-test, use some SV-DPI based functions or approach to pass on the debug prints from C-test [which is getting executed in the actual CPU RTL] to the SV side and print in the log files ?

If there are any best practices / methods etc. to be done for this flow, please provide the comments !

Thanks !

In reply to desperadorocks:

You can replace printf() with vpi_printf() and the output will be directed to your simulation logs and waveform databases.

In reply to dave_59:

Hello Dave,

Thanks for taking time and responding. But I am using ARM suite exec to compile my c-tests [and not regular gcc] and as expected I get the following error as shown below.

Error: L6218E: Undefined symbol vpi_printf (referred from abc_ctest.o).

  1. Do I need to include any standard libraries ? vpi_user.h ?
  2. Also Is there any performance hit/cycle time loss because of using vpi_printf ?
  3. Also do I need to use the default GCC compiler ? or even the ARM provided suiteexec is fine ?

Please provide your inputs.

Thanks & Regards

In reply to desperadorocks:

Sorry, I misread your original question. You are compiling this C code to run on your simulated DUT. You would need to create a virtual I/O device and have your C code write data to its address. Then you could display the data as a message.

Also suggest reading:

In reply to dave_59:

Hello Dave,

No problem.

  1. When you say virtual I/O device meaning, UART ports and direct the C code to these ports ?
  2. Is there any other ways that can we done ? like DPI calls or etc ?

By chance if you have any reference links for the virtual i/o device based flow, can you please share.

Thanks, appreciate your help !

In reply to desperadorocks:

Yes, like a UART port or something simpler.

You need to understand the difference between C code running on the CPU in the DUT in simulation versus C code running on the host CPU executing the simulation. The CPU on the DUT is basically a giant state machine and the C code gets compiled into a binary memory image. That’s completely disconnnected from the CPU running the simulation. So there is no ability to make calls to the OS.

In reply to dave_59:

Thanks a lot Dave !