# How to make Modelsim dump the data immediately?

Status
Not open for further replies.

#### machael

Hi, guys!
I'm using Modelsim to run a sdf timing simulation. In the testbench, I make several important signals to output the values into some text files using $fdisplay system task function. So I can compare the output file with an "ideal output" file made by Matlab simulation to evaluate whether the design is correct. Because the simulation is rather slow, I want to firstly run the simulation for several microseconds and break it and compare the outputs first, if the output has became wrong, I don't need to keep going and will stop to find the bugs in my design. If the output is correct, I can resume the simulation for longer time. Now I meet a problem: Modelsim does not output the result of the signal immediately, otherwise, it keep the data in memory. Until the data is "enough" or the simulation is stopped, the simulator will not dump it into the text files. So I found I can't preview the simulation rusult just as I wish, it really bother me. Can anyone tell me how to dump "the data to fdisplay" immediately or whenever I want to? Maybe it need a command or some special code in testbench? I will be very thankful! #### echo47 ##### Advanced Member level 5 I don't see this Verilog command in ModelSim's Commad Reference manual, but it works! According to IEEE Std 1364-2001: 17.2.6 Flushing output$fflush ( mcd );
$fflush ( fd );$fflush ( );
Writes any buffered output to the file(s) specified by mcd, the file specified by fd or if $fflush is invoked with no arguments, writes any buffered output to all open files. #### machael ##### Member level 2 echo47, Thank you very much for your great resolve method! In fact, I have thought another method to solve this problem yesterday. It is that every time when the data has been wrote into the file by$fdisplay, the file is close by $fclose, and when the next time it should be written again, the file is open by$fopen with append option, e.g.

file = \$fopen("test.txt","a");

so, the file will be wroten each time and closed, when the file is closed , the data is flushed into it.
This method has another problem: to avoid the file become bigger and bigger with the repeated simulation. It should be open by a "w" option in the initial process of simulation and closed immediately, so it will be cleared.

Of course, my method is more trivial and your method is more effective. So I want to say thank you again!

Regards!

Status
Not open for further replies.