tpoikela / uvm-python

UVM 1.2 port to Python
Apache License 2.0
243 stars 46 forks source link

uvm_info #21

Closed zfling closed 4 years ago

zfling commented 4 years ago

How to save uvm_info into a log file,not only into terminal?

tpoikela commented 4 years ago

The API for setting report files is the same as in SystemVerilog. You can do the following:


# In your top test, after all components are created (ie connect_phase):
def connect_phase(self, phase):
    self.f = open("uvm_logfile.txt", "w")
    self.set_report_default_file_hier(self.f)
...
# In your top test, in final_phase:
def final_phase(self, phase):
    self.f.close()  # Without this, nothing is printed to the file, so don't forget it

Let me know if it does not work. And look at the reporting API. Each component can have its own logfile.

zfling commented 4 years ago

I tried and it did not work.

tpoikela commented 4 years ago

I forgot that default action is UVM_DISPLAY, so you need to also do (when you set the default file):

self.set_report_severity_action_hier(UVM_INFO, UVM_LOG | UVM_DISPLAY)
zfling commented 4 years ago

It worked now. Is there a way to save all logs in the terminal to a log file, not only the UVM_INFO, such as compile log, cocotb log...

tpoikela commented 4 years ago

Sure. It's not feature of cocotb or uvm-python. Just use shell re-direction:

make args > run.log
make args >& run.log  # This dumps also stderr to run.log

will dump everything to run.log. args should be your custom args to the Makefile.

tpoikela commented 4 years ago

I will close this as uvm-python -specific issue was resolved.