+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Junior Member level 1
    Points: 116, Level: 1

    Join Date
    Jul 2019
    Posts
    18
    Helped
    0 / 0
    Points
    116
    Level
    1

    How to write in the log file

    Hello, I'm creating a file in the test bench and writing something in it using commands $fopen, $fdisplay and $fclose.

    What I would like to know is if there is a way to write directly in the log file or to create a file that is updated during the simulation and doesn't required to be closed before displaying something. Can someone kindly help me, please?

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 31,335, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,236
    Helped
    1711 / 1711
    Points
    31,335
    Level
    43

    Re: How to write in the log file

    Not directly with Verilog/Systemverilog. I think the lack of updates to the file isn't inherent in the system tasks themselves it's more of an OS think of when it writes out to the file during the simulation run. I notice that files I generate update but only after a significant number of KB's of output have been generated.

    You could write your own PLI/DPI and have it write directly to the file, without any buffering, it will most likely slow your simulation down considerably.

    Another option could be having both the $fdisplay and a $display task to output both to the file and the default display.



    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 5
    Points: 37,761, Level: 47
    Achievements:
    7 years registered

    Join Date
    Jun 2010
    Posts
    6,847
    Helped
    2012 / 2012
    Points
    37,761
    Level
    47

    Re: How to write in the log file

    $fflush should push any internal buffers to a file. You should be able to keep a file open as it updates (I normally do with notepad++). I am a VHDL user though (its been a while since I did SV).



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 31,335, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,236
    Helped
    1711 / 1711
    Points
    31,335
    Level
    43

    Re: How to write in the log file

    Quote Originally Posted by TrickyDicky View Post
    $fflush should push any internal buffers to a file. You should be able to keep a file open as it updates (I normally do with notepad++). I am a VHDL user though (its been a while since I did SV).
    Nice tip Tricky, I've in the past just waited for the simulation to complete and the $fclose to happen, never looked for a flush command. Though it could have significant detrimental effects on the simulation performance. I would probably use it in a 1us or so while loop in the testbench to occasionally get updates instead of doing it after every $fdisplay.

    Most of my simulation testbenches don't generate files, they just report pass/fail status of the tests as they run, which I can pipe or tee to a file since I run from a command line the majority of the time. If a test generates files it's usually for post processing of data from the UUT.



  5. #5
    Junior Member level 1
    Points: 116, Level: 1

    Join Date
    Jul 2019
    Posts
    18
    Helped
    0 / 0
    Points
    116
    Level
    1

    Re: How to write in the log file

    Thank you, I will try to use it and let you know if it works!



--[[ ]]--