Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
908 views
in Technique[技术] by (71.8m points)

system verilog - Writing to simulator log file without writing to terminal

I would like to write to the simulator log file without writing to the terminal. I'm guessing it's not possible to do this from SystemVerilog code, but is it possible using the VPI?

I looked at the vpi_mcd_printf method. It states that channel 1 represents the output channel of the tool and the log file. Is there a way to only write to the log file?


The background for this question is that I would like to implement colors for error/warning messages. Terminals can take escape characters, which control the color that gets displayed. If I just write such escape characters using a $display call, I'll get the desired behavior in the terminal, but the log file will contain these escape characters verbatim. They will also be present when the tool is started in GUI mode, where messages aren't printed in the terminal, but in the tool's console.

I can write to the terminal using a regular printf from C code, but there's still the issue of writing to the log file.

question from:https://stackoverflow.com/questions/65875247/writing-to-simulator-log-file-without-writing-to-terminal

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your question starts off asking how suppress printing to the terminal. But your background to your question suggest you want the option to separately control the format to both.

Terminal/stdout suppression:

Your simulators might have a built in in command line option; ex -noprint, -nostdout, or -quiet. Check the manual for your specific simulator.

For Linux based simulation you can always pipe the standard output to /dev/null

If using UVM:

Use the plusarg +uvm_set_action=*,_ALL_,UVM_INFO,UVM_LOG +uvm_set_action=*,_ALL_,UVM_WARNING,UVM_LOG so info and warning messages will only go to a log file; error and fatal will still go to standard out and log.

To get all UVM messages to go only to the logs files you could add something like the following to the top of your base test's build_phase:

set_report_severity_action_hier(UVM_INFO,    UVM_LOG);
set_report_severity_action_hier(UVM_WARNING, UVM_LOG);
set_report_severity_action_hier(UVM_ERROR,   UVM_LOG | UVM_COUNT);
set_report_severity_action_hier(UVM_FATAL,   UVM_LOG | UVM_EXIT);

Both allow ways to mix and match with controls on component, ID, and severity.

Reference guild for UVM messaging: http://www.sunburst-design.com/papers/CummingsSNUG2014AUS_UVM_Messages.pdf

Fine tone control:

If you really need to terminal and log output to differ (ex color formatting, making log in XML format, etc.), then you will need to avoid using $display and instead use your own VPI or DPI functions. To the best of my knowledge, you cannot override the $display system function.

As stated in your background statement, you can write terminal using a regular printf from C code. To write exclusivly to the log file, you can use $fdisplay/$fwrite or your own VPI/DPI code to target output file. Probably cannot be the default log file.

Your simulator might have a command to disable writing to the default log file if file management is an issue.

UVM Expert!!!

You need create your own report_server (extended form uvm_report_server) and override the execute_report_message and compose_report_message. This might require you to write your own VPI or DPI functions.

uvm_report_server XML example: http://www.verilab.com/files/SNUG_Applications_of_custom_UVM_report_servers.pdf


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...