Professional Documents
Culture Documents
and VirSim
TM
Tutorial
Version 4.4
September 2003
Copyright Notice and Proprietary Information
Copyright 2001 Synopsys, Inc. All rights reserved. This software and documentation are owned by Synopsys,
Inc., and furnished under a license agreement. The software and documentation may be used or copied only in
accordance with the terms of the license agreement. No part of the software and documentation may be repro-
duced, transmitted, or translated, in any form or by any means, electronic, mechanical, manual, optical, or other-
wise, without prior written permission of Synopsys, Inc., or as expressly provided by the license agreement.
Right to Copy Documentation
The license agreement with Synopsys permits licensee to make copies of the documentation for its in-
ternal use only. Each copy shall include all copyrights, trademarks, service marks, and proprietary
rights notices, if any. Licensee must assign sequential numbers to all copies. These copies shall con-
tain the following legend on the cover page:
“This document is duplicated with the permission of Synopsys, Inc. for the exclu-
sive use of __________________________________________ and its employ-
ees. This is copy number __________.”
VirSim Tutorial i
Synopsys
ii VirSim Tutorial
Chapter 1
Introduction
In This Chapter VCS VirSim and VirSim ships
Tutorial Objectives with a tutorial directory with six
Introducing Virsim versions of a Verilog design to
Getting Started with VCS VirSim or VirSim help you become familiar with
VirSim features. The tutorial will
guide you through debugging
three errors in the example
design.
Tutorial Objectives
In the tutorial, you accomplish the following objectives:
Learn VirSim system tasks needed to collect signal data.
Learn to use six of the VirSim windows.
Become familiar with Virsim features.
Debug Verilog simulation results in post-simulation mode. Post-simulation mode
enables you to extract and analyze simulation data from VCD+ history files after
simulation has been completed.
Use a configuration file to quickly return to a window configuration of interest.
Trace the cause of the errors and correct them in the Verilog source code.
Run a Verilog simulation in Interactive Mode (VCS license required). Interactive
Mode enables you to extract and analyze simulation data during simulation.
View register memory contents, anotate source code signal values, and create
buses of signals.
Introducing Virsim
This section includes an overview of the VirSim windows and the command icons
used in the tutorial. The following topics are covered:
VirSim Windows
Tool Bar
VirSim Windows
VirSim contains graphic windows that present various views of your design. These
windows may be linked so that operations initiated in one view may affect other views.
All VirSim windows have a Window menu which can be used to open other VirSim
windows. The VirSim tutorial demonstrates the use of the following windows:
Register The Register Window can display text and block diagrams of simu-
Window lation modules and signal events at specific times in the simulation.
You use the Register Window to view input and output values and
events at specific times. Values highlighted in pink indicate values
that have changed at that time.
Source The Source Window displays source code for selected instances.
Window In the tutorial, the Verilog source code contains several errors. You
use the Source Window to debug and correct these errors in post
simulation mode. Several features help you to isolate problems in
the code: Show Values annotates signal values in the source code,
breakpoints let you stop execution at specific lines, and single step
execution lets you execute one line at-a-time.
Tool Bar
Table 1-1, Command Icons, shows tool bar icons that are referenced in the tutorial
and the windows in which they are found. If you do not recognize the icon by its icon
name, refer to this table.
To handle these $vcdplus system tasks, the VirSim pli must be linked to the simulator.
In the tutorial, we used the following command line during VCS simulation:
vcs -line -R -I -f run_bad.f +simargs+"+vpdfile+vcs.vpd +vpddrivers
+vpdports"
The -I option is the option that links these tasks and enables interactive/
postprocessing debugging capabilities.
See the Installation Notes for information on linking the VirSim PLI to the Cadence
Verilog simulator.
The default VCD+ file name is vcdplus.vpd. We can override this by specifying a
VCD+ file to create.
On the VCS command line, we added:
+vpdfile+vcs.vpd -line +simargs+"+vpdfile+vcs.vpd \
+vpddrivers +vpdports"
In addition, VCS requires the -line option to save line execution data. The
+vpddrivers switch saves all net driver data, which helps resolve multiply driven nets.
The +vpdports switch saves port direction data for display in the Hierarchy Window.
On the Verilog-XL command line, we used:
verilog -f run_bad.f
+loadpli=$VIRSIMHOME/Solaris/vcdplus/vxl2_6/
virsim:virsim_bootstrap
+vpdfile+vxl.vpd +vpddrivers +vpdports
The +vpddrivers switch saves all net driver data, which helps resolve multiply driven
nets. The +vpdports switch saves port direction data for display in the Hierarchy
Window.
We completed these preliminary steps and ran simulations that created VCD+ history
files that will be read by VirSim.
• For VirSim:
virsim -f run_bad.f +vpdfile+vcs.vpd +vpdfile+vxl.vpd \
+cfgfile+delta1.cfg &
Where:
-f filename.f Contains a list of .v files to compile
for use with the Source Window and
You will also notice a V1 and V2 next to the vpd file name. These file designators
reference a single VCD+ file and are used by the configuration file. As shown here,
multiple VCD+ files and multiple VirSim windows can be open simultaneously for
viewing with a single VirSim license.
Both Hierarchy Browsers are displaying the same design; however, we descended to
the risc1 module in the vxl.vpd file and saved the display to show part of the
configuration capability.
More detail regarding Hierarchy Browser features is given in the risc1 section of the
tutorial.
• For VirSim:
virsim -f run_bad.f +vpdfile+vcs.vpd +vpdfile+vxl.vpd \
+cfgfile+delta1.cfg &
NOTE: To drag-and-drop signals: With a three-button mouse, click and hold down the middle mouse
button on a signal or a selection and drag-and-drop it to the destination. With a two-button
mouse, first perform a selection, then click and hold down the left mouse on the item and drag-
and-drop it. (If you are using Exceed and a two button mouse, click the right and left mouse
buttons together to drag and drop.)
Figure 2-1. Dragging Signals from the Hierarchy Browser to the Waveform Window
2. To view the test risc1 signals generated by the Verilog-XL simulator, drag and
drop (using your middle mouse button) the test.risc1 module from the lower Hier-
archy Browser (V2) to the lower Waveform Window (WW2).
2. Right click and hold your mouse button down on time 10 in WW1; then select
Expand Time from the context sensitive menu (CSM) to expand it into delta time.
This delta cycle information defines the sequence of signal changes within simula-
tion time 10. Repeat this in WW2. Figure 2-3, Expanding Time.
Expanded time in
VCS simulation
Expanded time in
Verilog-XL simulation
You are able to view the delta time because the $vcdplusdeltacycleon call was
added to the design. For delta time, VirSim displays exactly what the simulators
report. With this design we see that the two simulators behave differently. This
delta time is non-determinate. The simulator reported multiple value changes in a
given simulation time, and Virsim assigns an incremental delta cycle value to each
change in the order it was received.
The $vcdplusevent call was also used in the design to create two user-defined
unique events. These can be placed anywhere in the code to help you quickly
locate a signal of interest.
always @(negedge test.risc1.clock
if(test.risc1.data==8’h00)
$vcdplusevent(test.risc1.data[7:0], "Data is unknown","IT");
3. Data[7:0] shows two events indicated by a small green triangle at time 0 and a red
diamond at time 20. When you place your cursor over either indicator, a user
defined description appears in the status bar. Figure 2-4, Unconnected Data in
Status Bar.
Viewing the expanded inc_pc signal in the two Waveform Windows shows the
glitch in the VCS inc_pc signal within time 10. The Verilog-XL simulator shows
signal change from 0 to 1, i.e. no glitch.
4. In both Waveform Windows, right click within simulation time 10, hold down your
mouse button, and select Collapse Time from the CSM.
3. Double click on the first instance listed. The Source Window jumps to line 58
where @posedge fetch, inc_pc=0. Both lines executed at time 10. This is the
cause of the glitch. See Figure 2-7, Jump to Second Instance.
.
• For VirSim:
virsim +vpdfile+vcs_good.vpd +vpdfile+vxl_good.vpd
+cfgfile+delta2.cfg -f run_good.f &
In the following procedures, you view and debug events associated with the XOR
operation.
5. Click on the test1.risc1 box to display all the signals associated with risc1 in the
right pane. See Figure 3-5, Displaying Signals.
6. Enter *es* in the Filter text entry box, and click Filter to select all signals with "es"
in their name. Three signals are displayed. See Figure 3-6, Filtering Signal
Names.
Vector
Scaler
Port
7. Click the + box in front of the vector, address [4:0], to expand this vector to individ-
ual bits. See
8. Click the - box in front of the vector address [4:0] to collapse this vector.
9. Enter * in the Filter text entry box and click Filter to select all signals in risc1.
10. Use the Search function to locate the scopes of interest: See Figure 3-8, Search-
ing Scopes.
11. Use the Search function to locate signals of interest. See Figure 3-9, Searching
Signals and Scopes.
12. Use a bookmark to view signals for a specific module as described below in Fig-
ure 3-10, Using Bookmarks.
To use a bookmark,
click the Root button in
the toolbar.
Select test.risc1.alu1 in
the CSM.
13. In the Signals pane, hold down the Ctrl key and click left on signals in the follow-
ing order: clock, opcode[2:0], accum[7:0], data [7:0], alu_out[7:0]. Note that
holding down the Ctrl key enables you to select multiple signals.
14. Drag-and-drop the signals you selected as a group to the Waveform Window.
Note that the Signal Name, Signal Value, and Waveform panes are legal drop
sites.
The signals appear in the Waveform Window in the order you selected them. See
Figure 3-11, Dragging and Dropping Signals into Waveform Window.
NOTE: In the Logic Browser, click left on a port symbol to move up in the hierarchy and on the inside
of a port instance symbol to move down in the hierarchy.
1. In the Register Window, click left on the Next Change icon to view the XOR oper-
ation at time 720.
2. Click left on Windows in the menu bar and choose Waveform.
A second Waveform Window opens.
3. In the Hierarchy Browser, if necessary click left on the up arrow to scroll up the
hierarchy to test.risc1.
4. Drag-and-drop the test.risc1 scope to the second Waveform Window.
All the signals associated with test.risc1 appear in the Waveform Window in
alphabetical order.
5. In the second Waveform Window menu bar, click left on Window and choose
Logic.
The Logic Browser opens.
6. Drag-and-drop the clock signal from the second Waveform Window to the Logic
Browser.
The clock net appears.
7. Scroll the Logic Browser up to display the alu1 scope.
The clock signal feeds into the lower-left port.
8. Click right on the ireghi[8:6] port to open the Port Instance menu.
9. Hold down the right mouse button and choose View Connection.
The Connections Dialog opens. The Connections Dialog displays how signals
are connected between the definition and the instantiation of the port. Notice that
the input register bits 8-6 equal the hexadecimal value 4.
10. Click left on Cancel to close the Connections Dialog.
11. In the second Waveform Window, click left on the Marker icon and then on mk1.
The C1 cursor moves to time 690.
12. Scroll the Waveform Window down until you see the ireghi[8:5] waveform.
13. Double-click left on ireghi[8:5] in the Signal Name pane to expand the vector. The
three bits used as opcode are at 4, i.e. XOR. Thus opcode is not at fault.
NOTE: If you intend to reuse the tutorial, you should not make actual corrections. Just note how it can
be done.
NOTE: The editor used is defined by the EDITOR environment variable in X Resources.
3. Hold down the right mouse button at the time 2000 transition of alu_out[2] and
choose Event Origin>Automatically Select Window.
The Multiple Drivers Dialog opens showing alu_out[2] driven by eight inputs.
To open a Source Window and load the source code for ALU, select the first
alu_out[2] signal listed.
In the Source Window, the case statement is controlled by the signal opcode[2:0].
In the Waveform Window, click left on the alu_out[2] signal at time 2000 to set the
C1 cursor at time 2000.
In the Value Pane, the opcode[2:0] signal is reported as "LOAD". Right on this
"LOAD" value, and select Hexadecimal to see the value 8'h5 reported.
In the Source Window the opcode[2:0] value of five causes statement 24 to
execute.
The expression alu_out = data assigns the input value data to alu_out. Point to
the data and alu_out signals. A tool tip shows that the data and alu_out values
equal 8’h0X.
4. Drag-and-drop the data signal from the Source Window to the Logic Browser.
5. If necessary, click the Logic Browser window to bring it forward, then click left on
the data input port to move up to the next level in the hierarchy. Scroll vertically to
the top of the Logic Browser window.
Notice that the tricon port has a value of 8’h05 and the net wire[7:0] data has a
value of 8’h0X.
Notice that the module mem1 has an input/output port connected to the same net
as tricon and that the hierarchical resolution of the mem1 port is 8’h03. The value
X indicates that both the tricon and mem1 modules are driving on the same net
at the same time, creating a signal error of an unknown value.
7 6 5 4 3 2 1 0
tricon 8’h05 0 0 0 0 0 1 0 1
mem1 8’h03 0 0 0 0 0 0 1 1
Result 8’h0x 0 0 0 0 0 x x 1
The X result for bits 1 and 2 indicate that tricon and mem are generating opposite
values at the same time.
The Logic Browser handles assignments as well as structural elements and dis-
plays significant information. Use the Logic Browser to navigate and debug struc-
tural design, continuous and register assignments.
6. In makex, click left on the inside half of the o port to move down a level.
The purple boxes representing the behavioral model appears.
Above the middle box an assigned statement is displayed: #2000,0=8’h5. This is
the cause of the 8"h5 value being driven on to the net.
7. Drag-and-drop the middle purple box to the Source Window.
8. In the Source Window, observe statement lines 19 and 20.
Notice that line 19 executes at time 2000. Line 20 drives the 8’h05 signal at the
tricon port. These two lines cause the signal value conflict between tricon and
mem1 at time 2000.
Removing line 19 and line 20 would correct the problem. However, if you intend to
reuse the tutorial, you should not make actual corrections. Just note how it can be
done.
Then:
cd your_risc_dir/risc3
At the prompt, run the script file which contains theVCS compile and VCS/VirSim
command lines:
run_risc3
The Interactive, Hierarchy, and two Waveform Windows open.
Command Pane is
used for simulator
input commands.
User Defined
Buttons Pane is
used to control the
simulator.
Simulator
Control Pane
includes switches to
control the simulator.
In the second
Waveform Window
(Wave 2), part of the
signals are from the
Interactive Simula-
tion (I1) and the rest
are from a vpd file
(V1) which has data
from a previous sim-
ulation (risc2).
2. In Wave2, view (V1)alu_out at time 20,000 picoseconds. Notice that the value is
8'h0X — same as in the previous lesson.
3. In the Interactive Window, run the simulation by clicking the Green Arrow icon until
the simulator stops at time 20,800 picoseconds , as displayed at the bottom of the
Interactive Window.
4. In Wave2, view the interactive alu_out (I1) waveform. It has the same result at
time 20,000 picoseconds .
5. In Wave2, right click on the (I1)alu_out signal at time 20,000 picoseconds and select
Event Origin->Automatically Select Window from the context sensitive menu.
6. The Multiple Drivers Dialog opens because of the multiple drivers on this net. See
Figure 5-4, Multiple Drivers Dialog.
7. In the Multiple Drivers Dialog, all possible drivers to alu-out are listed. This is
because trace data is captured only for source code in the Source Window, thus
none has been captured, so all drivers are listed.
8. Double click the first entry alu_out[1] to cause the Source Window to open with a
hollow arrow pointing to line 26. The statement on this line is executed within the
case statement, which is controlled by the signal opcode.
9. From the previous lesson, we know that data is the signal causing the 8’h0X. Ver-
ify this by pointing the cursor to data on one of the lines. The tool tip displays
8’h0X.
10. Still pointing to data, right click and select Event Origin>Point To Preferred Win-
dow from the context sensitive menu, then left click on data. The Multiple Drivers
Dialog is refreshed because of the multiple drivers on this net.
11. Double click the second entry, data[1], in the Multiple Drivers dialog.
The tricon.v module is displayed in the open Source Window.
12. In the Interactive Window, select Sim>Re-Exec to restart the simulation and trace
statement execution for the alu.v and tricon.v module.
13. In the Interactive Window Simulator Control pane, enter a step time of 19900,
then click OK to run the simulation to time 19900.
14. Link the Source Window to SIM, then click the Next Line icon. The solid arrow
indicates line 20 executed setting 0 to the 8’h05 that caused the Multiple Drivers
at time 20000. See Figure 5-8, Locating the Cause of Multiple Drivers.
15. Click the Next Line icon nine more times to trace statement execution through the
source code. Notice that the 8’h0X is displayed in the Wave2 alu_out(I1) wave-
form.
Go To Next/Previous Change
1. In the Waveform Window, select the alu_out (I1) signal by clicking the left mouse
button over the signal in the signal name pane.
2. Use shortcut key “N” to locate the next change on the selected signal. Notice that
the Interactive simulation is advanced.
3. if you are not linked to SIM, you can use “P” to locate the previous change.
Location 25 of register
memory dumped at
time 250.
Locations 0 to 3 of reg-
ister memory dumped
at time 30, 1st "read."
5. Enlarge the Waveform Window by Dragging and Dropping the upper left corner of
the Waveform Window to fill most of your screen.
6. Quickly double click on memory[0:31] to collapse it.
7. Quickly double click on memory[0:31] to expand it.
8. Quickly double click memory[0] to expand it into individual bits.
9. View the bits of memory[0][7] through memory[0][0].
10. Quickly double click on memory[0][7:0] to collapse it.
11. Select memory[14] through memory[24] in the Signals pane. Then select
Edit>Delete to delete these unused memory words.
Now evaluate memory data respective to the signal data.
12. Point to the memory[0] signal value (8'he3) in the Signal Value Pane, and press
the right mouse key to bring up the Radix popup menu, then select Binary. The
upper 3 bits are displayed as "111" at time 30.
13. Look at the signal addr[4:0] in the Wave Window to see value 5'h00. This selects
the contents of address zero to be read to the data[7:0] signal, and on to become
the three bit opcode "111".
14. Point to the opcode[2:0] signal value "HALT" in the Signal Value Pane, and press
the right mouse key to bring up the Radix popup menu, then select Binary. The
three bits are displayed as "111" at time 130.
6. Click on data[7:0] to see it being fed by the mem1 module bi-directional port.
7. Click inside the mem1 module on the data[7:0] pin to traverse down inside the
mem1 memory module.
See Figure 6-4, Traversing Inside the mem1 Module. Note that data[7:0] is fed
by the tbo (tribuf) module bi-directional port. It has an input memaddr[7:0].
8. Quickly double click the addr[4:0] signal to expand it into five separate bits.
9. Quickly double click the data[7:0] signal to expand it into eight separate bits.
10. In the Bus Builder Dialog, deselect both buses by clicking on them if selected.
11. Drag and Drop the following four signals from the Waveform Window to the Com-
ponents pane in the Bus Builder Dialog:
read write addr[4] data[7]
See Figure 6-8, Dragging and Dropping Signals into the Bus Builder Dialog.
Figure 6-8. Dragging and Dropping Signals into the Bus Builder Dialog
12. Click Add in the Bus Builder Dialog to create a new four bit bus named bus1.
Notice in the Hierarchy Browser that bus1 is now listed as a signal in the Signal
Pane.
Figure 6-9. New Signal, bus1, in the Signals Pane of the Hierarchy Browser
13. Drag and Drop bus1 into the Waveform Window to see it displayed. Then expand
bus1.
• For VirSim:
virsim +vpdfile+file1.vpd +vpdfile+file2.vpd
+cfgfile+risc5.cfg -f run.f
3. Viewing the results in the Waveform Window, you can see data displayed for the
"V1" file file1.vpd, from time 0 to time 100. The file name is defined in the $vcd-
plusfile("file1.vpd"); statement, the data collection started at time 0 with the first
$vcdpluson; statement, and the file closed at time 100 with the #100 and the first
$vcdplusclose; statements
4. Viewing the results in the Waveform Window, you can see data displayed for the
"V2" file file2.vpd, from time 110 to time 310. The file name is defined in the $vcd-
plusfile("file2.vpd"); statement, the data collection started at time 110 with the sec-
ond $vcdpluson; statement, and the file closed at time 310 with the #200 and the
second $vcdplusclose; statements.
5. In the Waveform Window, point to the V1 clock signal at time 80, press the right
mouse, and select Expand Time from the popup menu. Delta cycle data is dis-
played as a result of the $vcdplusdeltacycleon statement.
6. In the Waveform Window, point to the V2 clock signal at time 160, press the right
mouse, and select Expand Time from the popup menu. Delta cycle data is dis-
played as a result of the same $vcdplusdeltacycleon statement.
7. Modify the Load Range Start time to 1,200 and the Load Range End Time to
46,500.
8. Click Apply. The file3.vpd data now available to view is time 1,200 to 46,500.
9. Data displayed in the Waveform Window starts at time 1,200. Scroll right in the
Waveform Window to see data to time 46,500.