Monday, February 21, 2011

Modelsim: Store and load the signals

How do I store all signal transitions during the simulation so that when I add a new signal to the Wave window I do not have to restart and rerun the simulation?
Command line:
write format wave -window .main_pane.wave.interior.cs.body.pw.wf /sp605_kunal.do

By default, the only signal values that are maintained in memory are the signals that were already added to the Wave window before the simulation was run. If additional signals are added after the simulation was run, no values will be displayed for these signals in the Wave window. To change this behavior, you can use the following command to instruct ModelSim to retain all signal values in memory during the simulation:
log -r /*
You can add this command to the User DO file, ".udo". Open the ".udo" file in the project directory and add the above command anywhere in the file. The ".udo" file is called inside all of the other DO files, so this command will automatically be used when running a simulation through Project Navigator.

How do I save my waveform settings and load them during the next simulation?
It is often necessary to make many modifications to the Waveform window. A user might add some additional signals, change the viewing radix, add dividers between signals, etc. After making all of the these changes, it is helpful to save these settings and load them next time the simulation is run.

To save the settings, click File -> Save Format in the Wave window. Save the format as ".do". You can then get back to these settings in the Wave window by clicking File -> Load Format and selecting the DO file.

There are also a couple of options that allow this DO file to be loaded automatically when running a simulation from Project Navigator. The easiest way to do this is to call the DO file inside the User DO file, ".udo". Open the ".udo" file in the project directory and add the following command:
do .do
The ".udo" file will be called by all of the other DO files created by ISE, so these Wave settings will be loaded each time a simulation is run in this project. The only problem with this method is that automatic DO file created by ISE will still load the default waveforms. Therefore, you will get all of the signals that you saved plus the default signals. This can clutter up the waveform window.

To prevent Project Navigator from loading the default signals to the waveform window, you will need to create a custom DO file. Follow the steps below:
1. Copy the automatic DO file created by ISE and give it a new name. For instance, if you are running a behavioral simulation and your testbench is named "top_tb," make a copy of "top_tb.fdo" and rename it to "top_tb_custom.do".
2. Open the copy in a text editor.
3. Comment out the call to the ".udo" file:
## .udo
4. Comment out the "add wave *" command:
## add wave *
5. After the "## add wave *" add a new line that calls the saved waveform settings:
do .do
6. Optionally, add the "log -r /*" command after the line from step 5 (see above for more information on log -r /*).
7. In Project Navigator, right-click the Simulate Process and select Properties.
8. Uncheck Use Automatic Do File.
9. Check "Use Custom Do File" and select the custom DO file that you created.

After performing this, Project Navigator will always use the custom DO when this process is run. The automatic DO file will still be used for the other simulation processes. These steps must be redone for other simulation processes if necessary. Also, if any files are added or deleted from the project, the custom DO file needs to be modified appropriately. This can be done manually, or you can reselect the "Use Automatic DO file" option and let Project Navigator make a new template for you.

Here is an example of what a custom DO file might look like:

vlib work
vcom -93 -explicit top.vhd
vcom -93 -explicit top_tb.vhw
vsim -t 1ps -lib work top_tb
## do top_tb.udo
view wave
## add wave *
do wave.do
log -r /*
view structure
view signals
run -all

No comments: