Simulating a Design Circuit Using Qsim

advertisement
Simulating a Design Circuit Using Qsim
1. Start Qsim
From version 11.1, Quartus II provides another simulating tool called Qsim. Qsim is
bundled with both subscript edition and web edition of Quartus II.
Not like the previous simulating tool that provided by Quartus II before version 11.1,
Qsim can not be started directly from Quartus. Users need to run command “quartus_sh
--qsim” from a command window, or in a DOS environment, to invoke Qsim simulation
tools.
When launch the command “quartus_sh --qsim”, make sure the “quartus_sh.exe”
program is either in the current working directory, or in one directory that is included by
the environment Path variable. For example, for web edition Quartus II version 12.0sp1,
the “quartus_sh.exe” program is installed by default under directory of
c:\altera\12.0sp1\quartus\bin. Users either need to go to the above mentioned directory to
launch Qsim, or need to modify the “Path” system environment variable to include the
above mentioned folder so the Qsim can be launched when command prompt is under
any folder.
To modify the Path system environment variable:
1. Right click “My Computer” either on desktop or from the windows “Start” menu,
then choose “Properties” from the popup menu. (Figure 1)
2. In the “System Properties” window, click tab “Advanced”, then click button
“Environment Variables” at the bottom of the window. (Figure 1)
3. In the “Environment Variables” window, choose the variable “Path” in the
“System Variables” section, then click “Edit” button at the bottom of this section.
(Figure 2)
4. In the window of “Edit System Variable”, change the “Variable Value”. In our
case, append the folder name containing the “quartus_sh.exe” program at the end
of the existing value. Separate the existing value and the newly appended folder
name by a semicolon. Then clock OK to close windows. (Figure 2)
2. Create Simulation Input Waveform File
Before simulating, a design of Quartus project need to be created and be successfully
compiled.
1): Once Qsim is started, click File>Open Project… . This will pop up an “Open a
Project” window. Then open the Quartus project by choosing a .qpf file in the Quartus
project folder. (Figure 3)
Figure 1: Change Environment Variables
Figure 2: Edit the Path Environment Variable
Figure 3: Qsim, To Open a Project or to Create a Waveform File.
Figure 4: Waveform Editor Tool
2): Click File>New Simulation Input File to launch waveform editor tool to create input
waveforms for simulation. (Figure 4)
3): Users may need to set up simulation end time by choosing menu command Edit>Set
End Time… from the Waveform Editor window. User may also need to check the option
of “Snap to Grid” from the same Edit menu to make it easier to draw the input
waveforms. (Figure 4)
4): Insert the input and output nodes of the circuit to be simulated by using “Node
Finder” utility. This is done by following these steps: Click Edit>Insert>Insert Node or
Bus… in “Simulation Waveform Editor” to open the “Insert Node or Bus” window. In
the “Insert Node or Bus” window, click button “Node Finder…” to open window “Node
Finder”. In the “Node Finder” window, select an appropriate filter type from the “Filter”
list box, then click the button “List”, this will make the filtered nodes shown in the
“Nodes Found” box. Selecting the nodes to be simulated in the “Node Found” box, and
then use the button “>” to add them to the “Selected Nodes” box. Then click OK close
windows. (Figure 5)
Figure 5: Insert Nodes and Bus to be Simulated
5): Create waveforms for input signals to be used for simulation. After finishing
selecting the nodes to be simulated, users are left with a Waveform Editor window with
selected nodes’ names on the left and their waveforms on the right side of the window.
By default at this stage, the input signals are straight lines of value 0, and output signals
are of unknown values and are marked with a series of X.
If the “Snap to Grid” option has been selected, users can use mouse to select one or more
grid of area of a input signal, and then use tool of “Forcing Low” or “Forcing High” on
the tool bar to create a nice signal waveform. Users can change the grid size by clicking
Edit>Grid Size…. An easy way to create a input waveform is to select an input signal
first by clicking its name on the left side of the window, then click the “Overwrite
Clock” icon on the tool bar, then specify appropriate values for clock period, offset and
duty cycle.
The order of the nodes can be changed by moving them up and down. This is done by
selecting a node and dragging it to a new position.
Figure 6: Create Waveforms
6): Save the waveform file
3. Setting up for Simulation
This is done by clicking Assign>Simulation Settings…. in Qsim window to bring up a
Simulation Setting window. Through this window, users can specify an input waveform
file to use and can specify what either functional simulation or timing simulation will be
carried out.
Figure 7: Simulation Settings
5. Start Simulation
Start simulation by click Processing>Start Simulation in Qsim window, or click the “Start
Simulator” icon on the tool bar.
However, to do functional simulation, it is necessary to generate a netlist of the circuit
before simulation. To generate netlist, Select Processing>Generate Simulation Netlist, or
click the “Start Generate Simulation Netlist” icon on the tool bar.
If everything is correct, a message of “Simulator was successful” will be popped up at
the end of simulation. After click OK to the message window, another message window
will show indicating the output waveform file can not be altered. Click OK to this
message window, the simulation result will be displayed.
6. Online Tutorial Material.
Two online PDF tutorial documents are available through the Help menu of Waveform
Editor. One is for VHDL users and another is for Verilog HDL user. The tutorial PDF
document for Verilog users can also be downloaded from the following URL:
ftp://ftp.altera.com/up/pub/Altera_Material/11.1/Tutorials/Verilog/Quartus_II_Simulation
.pdf
Download