+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Advanced Member level 4
    Points: 8,775, Level: 22
    Achievements:
    7 years registered Created Blog entry
    dpaul's Avatar
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    1,315
    Helped
    282 / 282
    Points
    8,775
    Level
    22
    Blog Entries
    1

    VHDL write to file with Modelsim Microsemi Pro 2019.2

    I am using the Modelsim Microsemi Pro 2019.2.
    In the testbench I am opening a file in write mode and periodically writing data to it. I open the file in write mode and never close the file (always stopping the sim manually).

    As long as the simu is running, whenever I see the file on disk, they are not updated. File size is always 0KB. The file is updated only after I stop the sim.

    Is this how Modelsim file write generally behaves? The file write data seems to be held is some cache and is flushed to the disk after sim is stopped or quit.

    I have used the same TB with Vivado simulator, xsim, and there such a file is regularly updated with data as the simu proceeds.

    Can this behavior be somehow changed?
    I tried closing the file and re-opening it just before the file needs to be written to, but it does not help.
    FPGA enthusiast!

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 4
    Points: 8,775, Level: 22
    Achievements:
    7 years registered Created Blog entry
    dpaul's Avatar
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    1,315
    Helped
    282 / 282
    Points
    8,775
    Level
    22
    Blog Entries
    1

    Re: Modelsim Microsemi Pro 2019.2

    Looking at the *_simulation.log I found the following...

    Code dot - [expand]
    1
    2
    3
    4
    5
    6
    7
    
    # ** Fatal: (vsim-4) ****** Memory allocation failure. *****
    # Attempting to allocate 131072 bytes
    # Please check your system for available memory and swap space.
    # ** Fatal: (vsim-4) ****** Memory allocation failure. *****
    # Attempting to allocate 131072 bytes
    # Please check your system for available memory and swap space.
    # End time: 13:49:30 on Jan 22,2020, Elapsed time: 2:07:15

    I want to find why is this memory problem occurring.
    Last edited by BradtheRad; 22nd January 2020 at 23:52. Reason: Put report in box
    FPGA enthusiast!



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 32,105, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,422
    Helped
    1742 / 1742
    Points
    32,105
    Level
    43

    Re: Modelsim Microsemi Pro 2019.2

    Modelsim has a large buffer for simulation file output, I've observed the file needs 10's of KB before it will automatically write out the buffer.

    vhdl 2008 has a flush(file); procedure
    verilog has a $flush(file); system task

    Neither of these will help unless you use them every time you write data to the file.

    One way to do this, so you don't have to force a flush before the simulation is ended (which is what is occurring here), will be to store the data to be written in an array. When the array has enough entries you run a task/procedure that then opens a file for appending and writes all the data out to the file. In this way you will always be guaranteed to have X number of data added to the file each time (or dropped if you stop before the last X are ready to be written) and you won't slow the simulation down as much as doing: open-file, write-data, close-file or open-file ... write-data, flush, write-data, flush ...


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 4
    Points: 8,775, Level: 22
    Achievements:
    7 years registered Created Blog entry
    dpaul's Avatar
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    1,315
    Helped
    282 / 282
    Points
    8,775
    Level
    22
    Blog Entries
    1

    Re: Modelsim Microsemi Pro 2019.2

    In my code I have a part where I am asserting a message at the Transcript window every 20us.
    Have added the flush() there. Works for me!
    FPGA enthusiast!



--[[ ]]--