Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Modelsim Microsemi Pro 2019.2

Status
Not open for further replies.

dpaul

Advanced Member level 5
Joined
Jan 16, 2008
Messages
1,793
Helped
317
Reputation
635
Reaction score
341
Trophy points
1,373
Location
Germany
Activity points
13,021
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.
 

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 a moderator:

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 ...
 
  • Like
Reactions: dpaul

    dpaul

    Points: 2
    Helpful Answer Positive Rating
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!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top