UVM and Coverage Driven Verification
UVM and Coverage Driven Verification
2
What is UVM?
Passive Agent Active Agent Passive Agent Active Agent Passive Agent Active Agent
OVM 2.1.1
Included: Added: Added:
• Architecture • SystemVerilog support • SV callback enhancements
• Sequences • Architecture • Report catching callback
• Messaging/logging • Sequences • SV end of test enhancements
• Reset/clocking • Factory • Closer to eRM capability
• Common test interface • Configuration mechanism • Register support
• Packaging & code structure • Field automation • Enhanced phasing
Added: • Message macros • Partial TLM2 support
• Module to system reuse • Register pkg (contribution) • Improved configuration and
• Register package (vr_ad) • Integration of AVM base classes command line support
• HW/SW co-verification •TLM Communication Channel • Script for “o” to “u” migration for
• Multi-language interoperability OVM users
4 © 2011 Cadence Design Systems, Inc. All rights reserved.
UVM and Coverage Driven Verification
• Why CDV?
– Eliminate the effort and time to write hundreds of tests
– Ensure thorough verification using upfront goal setting
seed
Coverage Monitor Monitor
23098432
38748932
23432239
17821961
10932893
20395483
Random
18902904
23843298 Generation
23432432
24324322
55252255
09273822 Random DUT
Stimulus
13814791
Tests Sequence Driver
4098e092
Tests Generator UART APB
23432424 Generator
24242355
25262622
26452454
24524522
6
Coverage Driven Verification Flow
Verification • Create a verification plan
Plan
Verification – Based on specification requirements
vPlan
Environment
– Decide what to test and how
Verification • Create smart testbench that:
Architecture
– Generates random legal stimulus
Adjust and Add Assertions,
– Includes assertions and coverage to
Constraints Constraints measure progress against the goals
and Stimulus & Coverage
Sequences – Checks for undesired behavior (BUGS!)
• Implement coverage model based on
Simulation, the verification plan, in place early on
Acceleration,
Emulation • Iteratively run simulations and analyze
coverage
• Adjust constraints and add new
Refine Coverage
Model scenarios targeting coverage holes
Review Coverage
• Refine and enhance the coverage
model
7
Agenda
8
The UVM Library
Using inheritance and encapsulation in class libraries
Structural Elements
Classes common to most
Methodology methodologies: components,
messages, simulation
phases, etc.
uvm_sequence
uvm_report_object
body()
uvm_report_*()
11
Where Do I Get UVM?
14
Agenda
15
Modeling Data Items
• Data items
– Represent the main transaction input to the DUT
– Adhering to a protocol, consistent values are generated and sent
– Examples include packets, transactions, instructions, and so on
• Test environment randomizes data items (transactions)
– A default distribution should be generated
– Tests further steer generation by layering constraints or
selecting from pre-defined scenarios
– This makes test short, readable, easier to write and maintain
Test 3
Test 2
Test 1
UVM
Smart Testbench
16
SystemVerilog Data Item: A UART Frame
class uart_frame;
rand int transmit_delay; Fields to be randomized
rand bit start_bit;
rand bit [7:0] payload;
rand bit [1:0] stop_bits;
rand bit [3:0] error_bits; How will the test-writer
bit parity; request a bad parity frame?
17
Design for Test-writing using Knobs
typedef enum bit {BAD_PARITY, GOOD_PARITY} parity_e;
class uart_frame;
Can you
Define an find another to
enumeration possible
make it
rand int transmit_delay; easy to describe parity type
rand bit start_bit;
control field in the frame?
rand bit [7:0] payload; Can have zero, short, medium
rand bit [1:0] stop_bits; and long delays
rand bit [3:0] error_bits;
bit parity; Knobs are control fields that
// control fields allow easy user interface
rand parity_e parity_type;
Test writers can specify the
// utility functions
distribution of GOOD vs. BAD
extern function bit calc_parity( );
parity
…
endclass: uart_frame
Extra logic can set the parity based
on the generated parity_type
Recommendation: Think of the desired scenarios and make sure you have the
18
needed control knobs to achieve them
Data Item Example
class uart_frame;
rand int transmit_delay;
rand bit start_bit;
rand bit [7:0] payload;
bit parity;
rand bit [1:0] stop_bits;
rand bit [3:0] error_bits; User defined function
// Utility functions
extern function bit calc_parity( ); Required for most
transactions!
extern function void print();
extern function bit compare(uart_frame rhs);
…
endclass: uart_frame
19
Where SV Language Stops and UVM Begins
Example: Data Items
class uart_frame;
bitrand bitstart_bit;start_bit;
[7:0]bitpayload;
bitrand [7:0] payload;
bitrand bitparity; parity;
parity_e
rand parity_e
parity_type;
parity_type;
intrand inttransmit_delay;
transmit_delay;
endclass: uart_frame
Does language alone support all the necessary customization operations?
• Randomization No! Only randomization is defined
• Printing in the SystemVerilog LRM
• Cloning
• Comparing
• Copying UVM provides the rest!
• Packing
• Transaction Recording
20
Enabling Data Item Automation
---------------------------------------
Name Type Size Value
---------------------------------------
my_frame uart_frame - @607
uart_frame frame1, frame2; start_bit integral 1 ’h1
initial payload integral 8 ’hfc
begin parity integral 1 ’h0
frame1 = new(“my_frame”); parity_type parity_e 32 BAD_PARITY
assert(frame1.randomize()); xmit_delay integral 32 ’d382
---------------------------------------
frame1.print();
$cast(frame2, frame1.clone()); Create a new uart_frame
frame2.set_name(“my_frame2”) and copy frame1 to frame2
frame2.print(tree_printer);
end my_frame2: (uart_frame@788) {
start_bit: ’h1
payload: ’hfc
Three built-in printers parity: ’h0
can be used parity_type: BAD_PARITY
xmit_delay: ’d382
}
22
Transaction Recording in IES
// inside driver or monitor code
uart_frame frame1;
int handle;
...
handle = begin_tr(frame1); // start recording
… // body including timing
end_tr(frame1)); // end recording
SimVision: Automatic
transaction recording.
23
Automatic recording methods built into UVM items
Messages for Debug & Error Reporting
• Messages
– While developing or using environments, users need to print messages
– $display does not allow non-intrusive filtering and control
– User may want to get trace messages from a suspect component
– Critical to large environment with many verification components
• Error reporting
– The testbench must produce clear and descriptive error messages to
communicate a checker mismatch
– Should affect simulation based on severity
• Error – stop
• Warning – record and proceed
• Allow customization of above
24
UVM Messaging Facility
26
Using the UVM Library with Incisive Simulators
• irun allows users to run the simulator by specifying all input files and
command-line options on a single command line.
– Each file is compiled using the appropriate compiler based on the file
extension used.
• Verilog, SystemVerilog, VHDL, e, C and C++
– Command-line options are also recognized and passed to the compiler,
the elaborator and the simulator
% irun -access +r -gui test.sv verify.e top.v sub.vhd
• irun supports UVM-specific options:
-uvm Searches <install_dir>/tools/uvm/src and
sets command-line options to compile the lib
-uvmhome $UVM_HOME Optionally specifies a different directory for
the UVM installation
+UVM_TESTNAME Passes the default test name for run_test()
+UVM_VERBOSITY Sets the verbosity level for UVM messages
27
Constraint Layering Using the Factory
31
Scenario Creation Requirements
32
UVM Sequencer – an Advanced Generator
UVM sequencer
Sequencer
Generator • By default works exactly like a generator
– Generates random transactions on request
We replace the generator
Produces data • Addresses all randomization requirements:
with a sequencer
– random by-default, reactive generation,
i/f
system-level ready, modeling timing, etc
•
sequences User-defined sequences of transactions are
created and executed
i/f
– For example, a user creates a sequence that
Bus Driver
interleaves legal and illegal frames
Consumes and • Test writer sets the sequencer to execute a
send to DUT specific sequence
33
Sequences Example: UART Retry Sequence
36
Sequence Execution
Sequencer
// Sequence: retry_seq
// Sequence: rand_retry_seq class retry_seq extends uvm_sequence #(…);
class rand_retry_seq extends … // uart_frame req; // built into base seq
//uart_frame req; //built into seq rand bit[7:0] pload;
retry_seq retry; virtual task body ();
virtual task body (); `uvm_do_with(req, {payload ==pload;
`uvm_do(req) parity==BAD_PARITY;})
`uvm_do_with(retry, {pload `uvm_do_with(req,{payload==pload;
inside {[0:31]};)) parity==GOOD_PARITY;})
`uvm_do(req) endtask
endtask endclass
endclass
get_next_item()
get_next_item()
item_done()
Driver
37
Controlling Sequencer Behavior
• How do we control which sequences run on a UVC
sequencer and when?
1. run_phase() (and every run sub-phase) has a default_sequence
property.
• Set default_sequence to a sequence to execute in that
phase.
// Test: Set uart_tx_sequencer to use retry_seq as the default sequence
uvm_config_db#(uvm_config_wrapper)::set(this,"uart_tx_sequencer.run_phase
", "default_sequence",
retry_seq::type_id::get());
39
Agenda
40
Creating a Reusable Verification Environment
Scoreboard
Data Checking
Monitor Monitor
Coverage
seed
23098432
38748932
23432239
17821961
10932893
20395483
Tests
DUT
18902904
23843298
Tests Sequencer Driver UART APB
23432432
24324322
55252255
09273822
Packaged for reuse
42
Reuse at the System Level
• Configure APB UVC as passive:
– Monitor still collects coverage
Coverage
• New blocks are added as they are developed
• Reuse of scoreboard for checking
Scoreboard
Checking
Passive Coverage
AHB to APB
Random DUT
Tests
Tests Sequence Driver
APB UART
Bridge
Generator
Reusable Component
43
Reusable Environments: Main Players
Note: At times the same person is doing two or all the roles above
44
Facilitating Reuse
45
Coverage and Checking
i/f
• For this we need a third component
Driver called a “Monitor”
Consumes and
send to DUT
46
The Monitor
• Monitor
– A passive component that collects information on a monitored
interface
– Builds abstract transactions
– Contains events, status, checkers and coverage
• Protocol specific
• Passive entity Monitor
47
The UVM Monitor – Coverage Implementation
class uart_monitor extends uvm_monitor; Derived from uvm_monitor
`uvm_component_utils(uart_monitor) and registered with the
uart_frame frame; // data item to be collected factory
covergroup uart_trans_frame_cg;
NUM_STOP_BITS : coverpoint frame.nbstop {
bins ONE = {0};
bins TWO = {1}; Implement coverage
} model based on your
DATA_LENGTH : coverpoint frame.char_length { …} verification plan
PARITY_MODE : coverpoint frame.parity_mode { … }
endgroup
function new (string name = "", uvm_component parent = null);
super.new(name, parent);
uart_trans_frame_cg = new();
new() covergroup in the constructor
endfunction: new
task collect_frame ( ); Task to collect data items
// Collect uart data from interface from the DUT interface
uart_trans_frame_cg.sample();
endtask: collect_frame Sample coverage when
endclass: uart_monitor frame is collected
48
Creating Assertion/Formal-Ready Interface
Components
49
UVM Assertions Methodology
The methodology was designed to: Env Immediate assertion
• Combine upfront planning and (UVC) Agent
checks in the monitor
assertions development into your Agent
flow Agent
• Instantiate and control assertions Sequencer
Config:
• Reuse assertions active_passive sequences
Concurrent assertions
reside in the SV interface I/F
DUT
Ask us for information or T=training
on UVM and Assertions
50
Agenda
51
Consider This: Your Next Verification
Challenge!
Trace Port SDRAM SDRAM
SRAM ROM Flash LCD Display
Analyser Bank 0 Bank 2
SDRAM SDRAM
Bank 1 Bank 3
PC Cards
MOVE Static Vectored
SDRAM Memory Color
Interrupt DMA
Controller Interface LCD
Control M M S
ETM
ARM926 PCMCIA
CPU Host
ARM I AHB
ARM D AHB
LCD AHB
DMA 1 AHB (Periph)
SRAM Our new
Buffer
DMA 2 AHB (Memory)
EXPANSION AHB
system
specs are
Core APB DMA APB MPEG-4
Engine
Colour
Convert in the mail
AHB/ AHB/ SSP
WATCHDOG TIMERS
APB APB
Camera
Interface
Camera
GPIO (x4) RTC SYSTEM
GPIO x4 UART SIM Card USB Camera
CONTROL Interface Control
Clk/Reset Trans-
Generator ceiver
32KHz
32 GPIO CLK
lines PLL
Xtal Osc Xtal Osc
USB Connection
to PC
interface
DUT
54
Creating the Agent Derived from uvm_agent
56
The Agent build_phase() and connect_phase()
class master_agent extends uvm_agent;
... class v2_mdriver extends master_driver;
// agent sub component instances // add attributes + override virtual methods
master_driver driver; endclass
master_sequencer sequencer; // syntax for introducing the new driver – in test
master_monitor monitor; master_driver::type_id::set_type_override (
... v2_mdriver::get_type());
virtual function void build_phase(uvm_phase phase); Use the factory to override
super.build_phase(uvm_phase phase); the driver for a specific test
// create sequencer, driver and monitor Call super.build_phase(…)
monitor = master_monitor::type_id::create( “monitor”, this);
if (is_active == UVM_ACTIVE) begin
driver = master_driver::type_id:: create(“driver”, this);
sequencer = master_sequencer::type_id::create(“sequencer”, this);
end Use create() for factory
endfunction allocation
virtual function void connect_phase(uvm_phase phase);
driver.seq_item_port.connect(sequencer.seq_item_export);
endfunction
Standard TLM mechanism for connecting
endclass the driver and sequencer
57
Allows changing the number
Example: Bus SomeEnvironment
agent config of agents without further
parameters come from configuration per agent
Environment the environment config
master agent Config:
master agent slave agent num_masters=3
master agent
sequencer slave agent arbiter agent num_slaves=2
sequencer sequencer
Config: sequencer sequencer sequencer
Config: Config: Virtual
Config: Config: Config: interface
seq
seq seq
i/f seq
vi seq seq
i/f vi i/f vi
i/f i/f i/f
monitor
monitor monitor
monitor i/f monitor monitor monitor
i/f i/f
events, i/f i/f i/f
events,
status, events,
events,driver
status, events,
status, events,
events,
data driver status,
driver status,
status,
data driver data driver driver
data
status,
vi data vi data
vi vi vi vi data
vi vi vi vi vi vi vi
59
Simulation Phases and Coordination
Simulation Phases
What if UVC1 starts Now we can start build_phase
sending traffic right sending traffic connect_phase
after build_phase()?
end_of_elaboration_phase
start_of_simulation_phase
run_phase
UVC1 DUT UVC2
extract_phase
check_phase
report_phase
Can this VC check for non-
empty scoreboard?
Environment was not fully UVC3
Not yet! All components must finish
elaborated yet!
their run phase first!
Must wait for run_phase()
Now can check
scoreboards
60
UVM Simulation Phases
UVM component’s built-in phases – run in order
All phases except run_phase()
Execute in zero time
build_phase
build Build Top-Level Testbench Topology
connect_phase
connect Connect environment topology
end
end of elaboration Post-elaboration activity (e.g. print topology)
of elaboration_phase
start_of_simulation Configure verification components
start_of_simulation_phase
run_phase
run task – Run-time execution of the test
extract_phase
extract Gathers details on the final DUT state
check_phase
check Processes and checks the simulation results
report_phase
report Simulation results analysis and reporting
63
Testbench Environment (TB)
module top ( );
• Separate the env configuration
class test extends … and the test
class tb extends uvm_env…
BUS
Mon UVC
BFM
– TB class instantiates and configures
Mon BFM
Module VC SEQR
reusable components
Scoreboard
coverage
Mon
VC3
DRV
• Specific tests are built on top of
testbenches (tbs)
DUT – Specify the nature of generated traffic
Multi Channel Sequence Generator
SEQR
in a central location
SEQR
UVC1
VC3 UVC
VC32
64
Using a tb for Multiple Tests
Test1
Test2
- Use only legal frames
• Tests determine the
Test3 nature of the generated
Use zero frame delay
sendTest4
- Do not Have out-of-order
Send long
4 masters
Back-to-back short
frame streams
traffic
frames frames
Change the clock speed
Send many illegal frames
65
The Test Launching Mechanism
endmodule : top
Multiple tests DUT snapshot
69
Multi-Channel Sequences
class u2a_incr_payload extends uvm_sequence;
. . .
virtual task body();
`uvm_do_on (config_dut,
uart_ctrl_env p_sequencer.p_apb_seqr);
fork
virtual_sequencer
config_dut `uvm_do_on(uart_incr_seq,
u2a_incr_payload p_sequencer.p_uart_seqr);
uart_incr_seq `uvm_do_on(apb_rd_rx_fifo,
p_apb_seqr
p_sequencer.p_apb_seqr);
p_uart_seqr
apb_rd_rx_fifo join
endtask
uart_env apb_env
uart_agent apb_agent
uart_sequencer apb_sequencer
seq
config_dut
uart_incr_seq seq
rd_rx_fifo
Driver Driver
70
Determining End-of-Test Each UVC and the virtual
sequencer have a list of
Virtual Sequencer executable sequences
coordinates traffic on
UVC1 and UVC2 virtual ...
sequences fork
`uvm_do_on(ovc2_seq1, ovc2)
Virtual `uvm_do_on(ovc1_seq3, ovc1)
vseq2
Sequencer Join
...
74
IVB – About the Incisive Verification Builder
What is IVB ?
75
Automated Creation of UVCs with IVB
76
Agenda
77
UVM Multi-Language (ML) – Enable Mixed-Language Env
OOP AOP
UVM VM
U VM
U
System
All libraries are open
SystemC Verilog e
source under the
Apache license
SysC SV e
Methodology includes TLM
communication between implementations
SoC
• Unifies VIP for reuse
SC
UVC
SC
UVC
• Choose best language for
application and group skills
C/C++ SV VMM
VIP VIP VIP
79
UVM for acceleration
Extending agents for acceleration
UVMUVM
Acceleration
Simulation
Agent
Agent
• Cadence provides
– UVM library extensions: UVM_Accel
Simulator
Monitor
Monitor Sequencer
Sequencer
events, sequences
Coverage
status,
Checking
data
sequences
– Methodology
Simulator
– Examples
SoftwareSoftware
Collector Driver
• Support SV and e
Collector
UVM ACCEL mode
Driver
UVM ACCEL mode
VIF
SCE-MI VIF
SCE-MI
• Enables verification re-use
PROXY PROXY
between simulation and
acceleration
Hardware Accelerator
I/F
I/F I/F
(collector_bfm) (driver_bfm)
DUT
DUT
80
The Software – HDL Interface
SCE-MI 2.0 modules
• scemi_input_pipe
• scemi_output_pipe
Simulator Clock
Accelerator
Driver
UVM (HVL)
Sce-mi modules
SCE-MI DUT
Pipes Proxy
Testbench
2.0 BFM
Interface (HDL)
UVM
(RTL)
Trans- signal-level
SCE-MI pipe C
actions interface
HDL Side API interface
Cadence
Host PdXP
Workstation
81
SimVision - Advanced UVM Analysis and Debug
82
Design Browser
83
Methods Tab
84
Interactive Sequence Debug
Callstack Viewing
85
Transaction Stripe Chart (TSC)
86
When there is a constraint solver failure, a new
Constraint Debugger constraint debugger window is created for
showing random variables and constraints
associated with the class instance.
87
Constraint Debug At the top of the window is a toolbar which has
buttons that allow the user to create or delete a
new constraint.
88
Constraint Debug – Dynamic Analysis
Show All constraints
With refined
constraints,
constraint
solver success
now.
89
Agenda
90
What Have We Seen Today?
91
Beyond UVM …
Inside the Incisive Platform
92
Useful Websites…
93
Learning more…
94
Thank You!
95