Questa Tool Usage Beginers Guide
Questa Tool Usage Beginers Guide
Questa Tool Usage Beginers Guide
11th September,2015
Mentor Graphics Enterprise Verification Platform
Investing in Smarter, Stronger, & Faster Verification
Smarter
Management
Stimulus Stimulus
& Analysis
Debug
Metrics
Debug
Environment
Infrastructure
Faster
Virtual FPGA
Verification Prototype
Formal Simulation Emulation
Prototype
Engines
Functional Simulation Solutions
Mentor Graphics
ModelSim PE -HDL Simulation + code coverage (W,32)
Introduction to QuestaSim
Language/Standards Support.
Questa GUI.
Core Simulation Technology
SystemC
SystemVerilog Assertions
Core Simulation Technology
OVM/UVM Supported
Coverage-Driven Verification
Verification Management
Functional
Coverage
Hierarchies Supported
Single simulation kernel provides total freedom to intermix
VHDL and Verilog design units.
You cannot place Verilog code constructs inside of VHDL code or
vice versa.
Requires no additional effort from the designer.
VHDL
use IEEE.std_logic_1164.ALL;
Verilog
input x, y;
entity foo is
port (a: in std_logic; output z;
b: in std_logic; wire temp_wire;
c. out std_logic; initial begin
end; temp_wire = 1;
library IEEE;
module fee (x, y, z); use IEEE.std_logic_1164.ALL;
Verilog VHDL
input x, y; entity foo is
output z; port (a: in std_logic;
wire temp_wire; b: in std_logic;
initial begin c. out std_logic;
end;
temp_wire = 1;
VHDL Verilog
input x, y;
entity foo is
port (a: in std_logic; output z;
b: in std_logic; wire temp_wire;
c. out std_logic; initial begin
end; temp_wire = 1;
Design flow with Questa
Execution Methods
Graphic User Interface (GUI).
Can accept menu input and interactive.
Command line input via transcript window.
Interactive Command Line Interface (CLI).
Only interface is a command line console, no Graphical User
Interface.
Invoke vsim with -c switch.
Batch Mode.
Run batch files from DOS or UNIX/Linux prompt.
Driven from a TCL script “do file” or additional command line
switches.
vsim –c <other switches> -do “log /*; run –all; quit –f”
Run batch mode for performance, after debugging the design.
Change the Working Directory
Before compiling or simulating the design, change the working
directory.
GUI: File > Change Directory
Command: cd ../modelsim_labs/modsim_lab1
Create a New Library
Create and map the design library:
GUI: In the Library window, click the right mouse button (RMB),
and select New > Library from the popup menu.
Command: vlib lib
vmap work lib
Compiler Options
Set global compiler options:
GUI: Compile > Compile Options
Command: Various vcom and vlog compiler switches.
– Example: vcom -93 top_level.vhd
Compile the Design Files
Compile the design files:
GUI: Compile > Compile
– Select source files to compile.
– Specify target library for compiled design units.
Compile button on toolbar.
Command: vcom or vlog
Library window
Transcript window
Main Window With Design Loaded
Menus and toolbar buttons provide quick
access to simulation commands and functions.
Debug
Windows
Design
Navigation
Windows:
• Placed in any position
• Can be grouped with any
other window
Zoom,
Undock
Drag Handle & Close
buttons
Tab
Groups
Drag and Drop Feature
Select HDL items in
one window, drag
and drop into
another window.
Drag HDL items
from the List,
Locals, Memories,
Objects, Processes, Hold down the left mouse mutton (LMB) to
Source, Structure Drag and Drop from one window to another.
Address of
data in first
column
Data Viewer Display Properties
Change radix of
address and/or data
Once a memory is configured the way you want, simply save it to a file
so it can be loaded whenever you want
Name file
Loading Memories
Memories can be loaded with saved data or initialized with various fill
values
Select loading
from file, direct, or
both
File name
Direct load
data
Comparing Two Memories
A nice way to check results is collect data in a memory and then use
memory compare against a “golden” result
Language Templates.
Executable lines.
Port direction.
Double-clicking an item
Value at current
in the Objects window
simulation time.
bookmarks the line and
highlights the item in
the Source window.
Find by Name.
Processes Window
Message Bar
Port
direction
Values
Cursor
Toolbox
RMB > Cursor Linking
Link and move two or
more cursors together
While dividers only create a “named” separator, groups add the ability
to expand and collapse the separator
Select
signals to Expand &
group collapse
as needed
Wave Cursors
Values linked to
Lock/Unlock active cursor
Properties Active cursor
Add/Remove highlighted
Gridlines
Leaf names
Time at each
cursor and
distance
between
cursors
Cursor Properties
Locked cursors
never move
Cursor Linking
Link/Unlink all
cursors or select
Configure... to
link only specific
cursors
Both cursors
move together
Saving the Wave Window Setup
Once you have the wave window setup the way you like, you can save
it for future reloading
Signals, zoom, cursors, radix, groups, dividers, etc.
Active Marker
Non-active Marker
Source Window:
Editable,
color-coded.
Transcript Window:
Tracks simulation
commands and
messages.
Locals Windows:
Dataflow Window: Next executable data.
Interconnect of
processes and
signals.
Dataflow Window.
Schematic Window.
Waveform Comparison.
Hierarchical
boundary
Input on
sensitivity list Verilog primitives
of process automatically
mapped to correct
symbol
Dataflow Viewing Options
Enabling Hierarchy
adds boarder
showing instance
boundary
Attached Wave Viewer
Toggle attached
wave ON/OFF
Values in
dataflow linked
to active cursor
Dataflow Example: Finding X Root Cause
Chose RMB
menu ChaseX
Double click to
show source
Schematic Window GUI: View > Schematic
CLI: view schematic
process or
logic gate
module
or entity
instance
Schematic Window (Cont.)
Incremental view
Logical gate equivalent of the
RTL design
– Understand design intent
Ideal for design debugging
– Trace signal readers/drivers
Embedded wave viewer
Full view
Structural overview of the
design hierarchy
– Processes and interconnect
Dynamically linked to
selections in other windows
with the “Follow” selection
Tracing From the Schematic Window
1. Click time indicator
3. Highlight signal
2. Enter causality
trace start time
4. RMB > Event Traceback
> Show Cause
1. Add signal
2. Select signal
View in
Transcript
window
Save to a
text file
VCD (Value Change Dump)
Next, with the design loaded, specify the VCD file name and
objects to add with the vcd dumpports command:
vcd dumpports -file myvcdfile.vcd /test_counter/dut/*
Run
quit –f
Using VCD as stimulus
First, create the VCD file for the single instance using vcd
dumpports:
cd <installDir>/examples/tutorials/verilog/basicSimulation
vlib work
vlog counter.v tcounter.v
vsim test_counter +dumpports+nocollapse
vcd dumpports -file counter.vcd /test_counter/dut/*
Run
quit -f
Next, rerun the counter without the test bench, using the -
vcdstim argument:
vsim counter -vcdstim counter.vcd
add wave /*
run 200
Checkpoint and Restore
checkpoint saves the simulation kernel state of the design.
This includes the vsim.wlf file, the list of the HDL items shown in the List and
Wave windows, the file pointer positions for open files, and the state of
foreign architectures.
checkpoint <filename>
restore restores the “state” of the design saved by checkpoint.
restore <filename>
or
vsim -restore <filename>
Useful for long simulations.
Put in periodic checkpoints in anticipation of simulation error.
Restore back to “state” prior to simulation error.
– Add more signals to monitor for debugging purposes.
– Continue simulation.
$init_signal_driver()
$signal_force()
$signal_release()
Signal Spy (Cont.)
Signal probing capability.
Can check any signal
in any other VHDL or VHDL testbench
Verilog module without
having to modify your code. ...
signal s, t, r: std_logic;
...
Greatly simplifies init_signal_spy(“/top/u1/s”, “s”);
init_signal_spy(“/top/u1/t2/v1/s”, “t”);
testbench development Verilog init_signal_spy(“/top/u1/t2/v2/r”, “r”);
always @ (x or y) begin
z = 0;
if (x == 0) z = 1;
end
Branch Coverage
Branch Coverage measures the coverage of
expressions and case statements that affect
control flow. if (x == 0)
Branch Coverage reports if the if x == 0 branch z = 1;
was tested true or false.
else begin
Case statements z = 0;
Statement coverage end
– 1,2: z = 1; reports a hit if x was 1 or 2
Branch Coverage
case (x)
– Reports if x was tested 1, 2 or 3
1,2: z = 1;
– 1,2: z = 1; 1 and 2 will be reported separately
3: z = 0;
– Provides additional information
to Statement coverage endcase
Expression Coverage
Analyzes expressions on the right hand side of assignment
statements.
Counts when these expressions are executed.
Constructs a truth table and tabulates counts for conditions
involving Boolean expressions.
Example:
Truth Table for Line 236
Row 1 1 0 0 1 1
Row 2 0 0 1 0 0
Row 3 2 1 0 0 1
Row 4 0 1 1 1 0
Unknown 0
one of the variables
had an “x” state Line 236: x <= a xor (not b(0));
Condition Coverage
Extension of branch coverage
Evaluates “if”, “if-then-else”, and other ternary statements
Constructs truth table
Keeps track of count of each row of truth table
Example:
counts a b (a or b)
Row 1 5 1 - 1
Row 2 0 - 1 1
Row 3 8 0 0 0
Unknown 0
Types of coverage:
State Coverage Metric.
Transition Coverage Metric.
The two-step process enables coverage statistics collection on all areas of the design.
Enabling Code Coverage in the GUI, 2-Step Flow
GUI
Compile > Compile Options > Coverage Tab
Simulate > Start Simulation > Others Tab > Enable code coverage
1 2
Expression Analysis:
– expression has been covered.
XE – one or more expressions were missed.
Code Coverage Analysis Window (Cont.)
Statement Analysis:
– statement has been covered.
XS – one or more statements were missed.
Condition Analysis:
– Condition has been covered.
XC – one or more conditions were missed.
Code Coverage Analysis Window (Cont.)
Click the state button to open
a state machine view window.
State
Transition
FSM Analysis:
The state variable name is listed at the top of the
hierarchy and is also a button.
A green check mark indicates that the state was
covered.
An X indicates that a transition was not taken.
Viewing Toggle Coverage
Click to view in
Coverage Details
window.
– Line has been executed.
X – More than one kind of coverage was missed.
XB – One or more branches were missed.
XC – One or more conditions were missed.
XE – One or more expressions were missed.
XS – One or more statements were missed.
XT – True branch not executed. (BC column)
XF – False branch not executed. (BC column)
Code Coverage in the Source Window (Cont.)
After adding the UCDB file(s) to the Browser window, results for each
UCDB file are available.
Merging Coverage Data in the GUI
Invoke coverage view mode through the GUI or with vsim –viewcov <filename>.ucdb or coverage open
<filename>.ucdb. The workspace contains a tab for the .ucdb file, called cover3 in this example.
Generating HTML Reports
0 1 2 3 4 5
req
ack
Example intended behavior
property p1;
@(posedge clock) a |-> b == 8’b10010001;
endproperty
assert property (p1);
Failure/Pass counts
Assertion error
Local variable
pane
Design
Objects pane
Yellow dots indicates
additional thread
spawned Redundant failures:
individual spawned thread
failed but other threads
still active
100
80
Random
60
Constrained Random
40
20 Distributed,
but focused
0
0 20 40 60 80 100 120
Defining & Controlling Random Variables
class Bus;
rand bit [15:0] addr;
rand bit [31:0] data;
constraint word_align {addr[1:0] == 2’b0;} Test whether or
endclass not constraint is
function int toggle_constraint( Bus b ); enabled
if ( b.word_align.constraint_mode() )
b.word_align.constraint_mode(0);
else Turn constraint OFF
b.word_align.constraint_mode(1);
toggle_constraint = b.randomize();
endfunction : toggle_constraint Turn constraint ON
Module -5
covergroup dram_ctrl_cg;
fsm_cp: coverpoint fsm_state;
endgroup : dram_ctrl_cg
Sample when there
dram_ctrl_cg cg1 = new();
is known good data
...
always @(posedge xact_write)
cg1.sample();
Covergroups in Classes