Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

How to save the simulation results in file for check?

Sometimes I did simulation in Modelsim, the output data are huge, it is impossible to compare the data with results computed in Matlab.

So I need to save the results simulated in Modelsim as file then load into Matlab to compare.

As I know, the command I can use:

fid=$fopen("filename.dat","w");

then I need the write command:

$fwrite(fid,"%d",Portname);

I try them but it does not work well. Firstly, it seems I can't write data in decimal, I should write in binary format. Another is when I try to load the dat file, Matlab seems can't distinguish the space between each number.

If anybody who is familiar with these data save operation, can you give me a completed example to show the commands you use in testbench? If you also have Matlab code to read the file, please show me.

Thanks very much.