Simulation Using Modelsim
2. Adding Signals to a Wave Window
5. Debug Source Code and Resimulate
Modelsim is a vhdl, verilog and systemC simulator. Modelsim is used to verify that the system we have created in HDS designer functions the way we desire.
Launch the ModelSim simulator using the command; ModelSim -> Simulate on the task window.
OK the next dialog box.
2. Adding Signals to a Wave Window
Signals can be added to the wave window by highlighting xnor2 and then right clicking Add -> Add to Wave, as shown below.

To show just selected signals go to view -> Signals, copy the signals you wish to view.
Then go to view -> Wave, and paste the desired signals into the wave window.
There are essentially 3 ways to force signal values in Modelsim.
a) Execute a .do file. This is a file of commands; which can be useful in larger simulations
b) Enter the force command at the command prompt. Useful for smaller commands such as run
c) Use the GUI to enter commands as shown below.
In the signals window select signal a. Next select Edit -> Clock in the signal window, as shown below.

The following settings will force a to repeat every 10 ns, with a duty cycle of 50%. This means it will be high for half of the time and low for half.

Set the period for b to twice that of a. This will ensure all combinations of a and b are activated.

From the main Modelsim window click the run button. This should run the simulator for the default time of 100 ns.
When the simulation is complete the window should appear as follows.

As you can see the output z
follows the correct pattern of the xnor gate.
|
A |
B |
A XNOR B |
|
T |
T |
T |
|
T |
F |
F |
|
F |
T |
F |
|
F |
F |
T |
5. Debug Source Code and Resimulate
If you need to make changes to the source file go back into FPGA designer and edit the source code. Then generate and compile the entity. Go back into ModelSim and reload the design with the Simulate->Simulate pull down command. The following dialog box will appear. Choose the architecture to reload and OK the dialog box. This will reload the design changes. If you have the source window open in ModelSim you will be notified that the source is out of date.

6. Printing Your Simulation
To print the waveform choose File -> Print Postscript.. from the Wave windows pull-down command windows. Change the Print command to lpr as shown below. Access to the default postscript printer is through the lpr command.
Additional information about ModelSim and command syntax may be found in the on-line help through the Help pull down command:
Help -> SE PDF Documentation
Choose File -> Quit from ModelSim's main window to quit the simulator and close all the windows.