Cadence Introduction To Class Based UVM PDF
Cadence Introduction To Class Based UVM PDF
UVM Agenda
What is UVM?
UVM is the Universal Verification Methodology
A methodology and a library that codifies the best practices for
efficient and exhaustive verification.
A complete, proven solution
Proven solution, with a success record and large community of users
with methodology knowledge and commitment
Well-thought-out solution for a wide variety of verification challenges
Open
A key motivation for moving to SystemVerilog
An Accellera standard, supported by Cadence, Mentor and Synopsys
Jan
2006URM
2008 OVM
eVC
OVC
UVC
Configuration
DUT I/F
Configuration
DUT I/F
Configuration
DUT I/F
Passive Agent
Active Agent
Passive Agent
Active Agent
Passive Agent
Active Agent
Monitor
Sequence_driver
Monitor
BFM
Coverage
Checks
Architecture
Sequences
Messaging/logging
Reset/clocking
Common test interface
Packaging & code structure
SystemVerilog support
Architecture
Sequences
Factory
Configuration mechanism
Field automation
Message macros
Register pkg (contribution)
Integration of AVM base classes
TLM Communication Channel
Multi-language interoperability
OVM 2.1.1
Added:
Coverage
Driver
Included:
Sequencer
Seqs.
Checks
Added:
Monitor
Seqs.
Seqs.
Checks
Coverage
Sequencer
Driver
Added:
SV callback enhancements
Report catching callback
SV end of test enhancements
Closer to eRM capability
Register support
Enhanced phasing
Partial TLM2 support
Improved configuration and
command line support
Script for o to u migration for
OVM users
Why CDV?
Eliminate the effort and time to write hundreds of tests
Ensure thorough verification using upfront goal setting
Coverage
seed
23098432
38748932
23432239
17821961
10932893
20395483
18902904
23843298
23432432
24324322
55252255
09273822
13814791
4098e092
23432424
24242355
25262622
26452454
24524522
Monitor
Monitor
Random
Generation
Tests
Tests
Random
Stimulus
Sequence
Generator
Generator
Driver
DUT
UART
APB
Assertions,
Constraints
& Coverage
Simulation,
Acceleration,
Emulation
Refine Coverage
Model
Review Coverage
Agenda
Structural Elements
Methodology
name
copy(),
clone()
print()
uvm_transaction
uvm_sequence_item
uvm_sequence
uvm_report_object
body()
uvm_report_*()
uvm_port_base #(IF)
uvm_report_handler
uvm_component
uvm_subscriber
uvm_env
uvm_*_export
parent
children
get/set_config_*(), create ()
build_phase(),
connect_phase(),
end_of_elaboration_phase();
start_of_simulation_phase();
run_phase(),
uvm_tlm_fifo
uvm_tlm_analysis_fifo
uvm_test
uvm_driver
uvm_monitor
uvm_agent
uvm_scoreboard
10
uvm_*_port
TLM
uvm_*_imp
uvm_tlm_req_rsp_channel
uvm_tlm_transport_channel
uvm_sequencer
11
Option 2
12
integ/
xbus/
examples/
sv/
codec/
apb/
14
Agenda
15
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
UVM
Smart Testbench
16
Fields to be randomized
// utility functions
parity is calculated using a function
extern function bit calc_parity( );
extern function void print( );
extern function bit compare(uart_frame rhs);
endclass: uart_frame
17
endclass: uart_frame
18
Recommendation: Think of the desired scenarios and make sure you have the
needed control knobs to achieve them
// Utility functions
extern function bit calc_parity( );
extern function void print();
extern function bit compare(uart_frame rhs);
endclass: uart_frame
19
Cloning
Comparing
Copying
Packing
Transaction Recording
20
uart_frame fields
UVM_NOCOMPARE,
UVM_NOPRINT, etc.
--------------------------------------Name
Type
Size
Value
--------------------------------------my_frame
uart_frame @607
start_bit
integral
1
h1
payload
integral
8
hfc
parity
integral
1
h0
parity_type parity_e
32 BAD_PARITY
xmit_delay integral
32 d382
---------------------------------------
SimVision: Automatic
transaction recording.
23
Messages
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
Output
id
time
message body
scope
Simple Messaging:
uvm_report_*(string id, string message);
% irun . +UVM_VERBOSITY=UVM_NONE
26
28
Replace frame=new();
with create ()
delay_frame
from
to
uart_frame
...
delay_frame
...
Factory
Class Hierarchy
uart_frame
Create uart_frame
Factory allocates instance
of required type
+create
registered types
uart_frame
delay_frame
delay_frame
+create
Factory Overrides
Type override replaces ALL instances: For a specific test, replace all uart_frame
packets with delay_frame packets
A uart_frame
drv_c
B delay_frame
drv1_c
set_type_override_by_type(uart_frame::get_type(),
env1
delay_frame::get_type());
agent[0]
agent[1]
seqr
A
B
seqr
A
B
driver monitor
A
B
A
B
driver monitor
B
A
A
B
env1
agent[0]
agent[1]
seqr
A
B
seqr
A
driver monitor
A
A
driver monitor
A
A
A
Agenda
31
Sequencer
Generator
Produces data
i/f
UVM sequencer
By default works exactly like a generator
Generates random transactions on request
We replace the generator
Addresses all randomization requirements:
with a sequencer
random by-default, reactive generation,
system-level ready, modeling timing, etc
sequences
i/f
Bus Driver
Consumes and
send to DUT
33
Translates into:
Nesting Sequences
// call retry sequence wrapped with random frames
class rand_retry_seq extends uvm_sequence #(uart_frame);
`uvm_object_utils(rand_retry_seq)
retry_seq retry_sequence;
Using a previously
defined sequence
36
Sequence Execution
Sequencer
// Sequence: rand_retry_seq
class rand_retry_seq extends
//uart_frame req; //built into seq
retry_seq retry;
virtual task body ();
`uvm_do(req)
`uvm_do_with(retry, {pload
inside {[0:31]};))
`uvm_do(req)
endtask
endclass
// Sequence: retry_seq
class retry_seq extends uvm_sequence #();
// uart_frame req; // built into base seq
rand bit[7:0] pload;
virtual task body ();
`uvm_do_with(req, {payload ==pload;
parity==BAD_PARITY;})
`uvm_do_with(req,{payload==pload;
parity==GOOD_PARITY;})
endtask
endclass
get_next_item()
get_next_item()
item_done()
Driver
37
38
2.
3.
Produces data
`uvm_component_utils(uart_tx_driver)
i/f
i/f
Driver
Consumes and
send to DUT
39
Interface to the
sequencer via TLM
Agenda
40
BUS UVC
Mon
Mon
Module VC
BFM
BFM
SEQR
Scoreboard
Mon
coverage
DRV
VC3
Project1 DUT
Multi Channel Sequence Generator
CPU
Periph
Mon
Mon
Mon
BFM
BFM
DRV
SEQR
Protocol1
VC3 UVC
41
Mem
Periph
Mon
Mon
Mon
BFM
BFM
DRV
SEQR
Protocol2
VC3 UVC
Tasks to be done:
Issues:
How do we model complex environments?
Generation? Checking? Coverage?
How do we facilitate reuse?
Coverage
Scoreboard
Data Checking
Coverage
Monitor
Monitor
seed
23098432
38748932
23432239
17821961
10932893
20395483
18902904
23843298
23432432
24324322
55252255
09273822
42
Tests
Tests
Sequencer
Driver
DUT
UART
APB
Coverage
Scoreboard
Checking
Coverage
Passive
Coverage
Tests
Tests
Random
AHB
to APB
Sequence
Bridge
Generator
Monitor
Driver
Reusable Component
43
Monitor
DUT
APB
UART
44
Facilitating Reuse
Testbench
Mon
BFM
Mon
BFM
Mon DRV
SEQR
VC3
VC2
Multi Channel Sequence Generator
Project2 DUT
Periph
Periph
VC Repository
Mon
BFM
Mon
BFM
Mon DRV
Module VC
Mon
BFM
Mon
BFM
Mon DRV
Scoreboard
SEQR
coverage
45
VC3
Mon
BFM
Mon
BFM
Mon BFM
Mon
BFM
Mon
BFM
Mon DRV
BUS
VC
Mon
BFM
Mon
BFM
SEQR
SEQR
SEQR
SEQR
Mon DRV
VC3
VC3
eVC
VC3
VC2
VC3
Sequencer
Produces data
i/f
i/f
Driver
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
Checking and
coverage
covergroup uart_trans_frame_cg;
NUM_STOP_BITS : coverpoint frame.nbstop {
bins ONE = {0};
Implement coverage
bins TWO = {1};
model based on your
}
verification plan
DATA_LENGTH : coverpoint frame.char_length { }
PARITY_MODE : coverpoint frame.parity_mode { }
endgroup
function new (string name = "", uvm_component parent = null);
super.new(name, parent);
new() covergroup in the constructor
uart_trans_frame_cg = new();
endfunction: new
Task to collect data items
task collect_frame ( );
// 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
Env
(UVC)
Immediate assertion
Agent
checks in the monitor
Agent
Agent
Config:
active_passive
50
sequences
tlm i/f
tlm i/f
Monitor
tlm i/f
Coverage
Checking
Driver
vif
vif
Concurrent assertions
reside in the SV interface
Ask us for information or T=training
on UVM and Assertions
Sequencer
I/F
DUT
Agenda
51
SDRAM
Bank 0
SDRAM
Bank 2
SDRAM
Bank 1
SDRAM
Bank 3
SRAM
ROM
Flash
LCD Display
PC Cards
ETM
MOVE
Static
Memory
Interface
SDRAM
Controller
ARM926
CPU
Vectored
Interrupt
Control
Color
LCD
DMA
M
PCMCIA
Host
ARM I AHB
ARM D AHB
LCD AHB
SRAM
Buffer
DMA APB
Core APB
WATCHDOG
AHB/
APB
TIMERS
AHB/
APB
MPEG-4
Engine
Colour
Convert
SSP
Camera
Interface
Camera
GPIO (x4)
GPIO
x4
SYSTEM
CONTROL
RTC
Clk/Reset
Generator
32 GPIO
lines
32KHz
CLK
Xtal Osc
UART
SIM Card
USB
Interface
Transceiver
PLL
Xtal Osc
USB Connection
to PC
52
Camera
Control
Our new
system
specs are
in the mail
Config:
sequences
seq_item_export
uvm_monitor
events,
status,
data
uvm_driver
vif
vif
interface
DUT
53
uvm_agent
uvm_
sequencer
Config:
is_active:
UVM_PASSIVE
UVM_ACTIVE
sequences
seq_item_export
passive
uvm_monitor
events,
status,
data
seq_item_port
uvm_driver
vi
vi
interface
DUT
54
UVM_ACTIVE:
Actively drive an interface or device
Driver, Sequencer and Monitor are
allocated
UVM_PASSIVE:
Only the Monitor is allocated
Still able to do checking and collect
coverage
Configuration field
class master_agent extends uvm_agent;
uvm_active_passive_enum is_active = UVM_ACTIVE;
UVM field declaration for
library automation
`uvm_component_utils_begin(master_agent)
`uvm_field_enum(uvm_active_passive_enum, is_active, UVM_ALL_ON)
`uvm_component_utils_end
// agent sub component instances
Using the constructor to allocate the
master_driver
driver;
sub-instances is problematic
master_sequencer sequencer;
because new() is not polymorphic
master_monitor
monitor;
function new( input string name, input uvm_component parent);
agent
super.new( name, parent);
sequencer
// create the sequencer, driver and monitor
Config:
Is_active
sequences
monitor = new (monitor,this);
if (is_active == UVM_ACTIVE) begin
driver = new(driver,this);
monitor
events,
sequencer = new(sequencer, this);
status,
driver
end
data
Allocation using new() forces a
vi
vi
endfunction
re-write when modifications are
endclass
required
55
57
slave agent
slave agent
monitor
monitor
monitor
Config:
Config:
i/f
events,
events,
status,
events,driver
status,
driver
data
status,
driver
data
data
vi
vi
vi
vi
vi
vi
58
Config:
monitor
monitor
events,
events,
status,
status,
data
data
vi
vi
i/f
i/f
driver
driver
vi
vi
interface
Envs allow reuse at the interface
level!
DUT
num_masters=3
num_slaves=2
Virtual
interface
seq
i/f vi
i/f
vi
i/f
sequencer
seq
seq
i/f
i/f
arbiter agent
sequencer
sequencer
seq
seq
vi
i/f seq
i/f
Config:
i/f
monitor
monitor
i/f
events,
status,
data
vi
driver
events,
status,
data
vi
vi
build_phase
connect_phase
end_of_elaboration_phase
start_of_simulation_phase
run_phase
UVC1
DUT
UVC2
extract_phase
check_phase
report_phase
UVC3
60
build_phase
build
connect_phase
connect
end
of elaboration_phase
end
of elaboration Post-elaboration activity (e.g. print topology)
start_of_simulation_phase
start_of_simulation Configure verification components
61
run_phase
run
extract_phase
extract
check_phase
check
report_phase
report
pre-reset
reset
connect_phase
end of elaboration_phase
start of simulation_phase
post-reset
pre-configure
configure
post-configure
run_phase
pre-main
extract_phase
Allow components to
perform operations
related to reset
main
post-main
Perform operations
related to device
configuration (register
settings and more)
Defines the normal
operation of the
component for the
bulk of the test
check_phase
report_phase
finalize
62
pre-shutdown
shutdown
post-shutdown
Agenda
63
SEQR
Scoreboard
Mon
coverage
Multi Channel Sequence Generator
DUT
CPU
Mem
Periph
Periph
Mon
BFM
Mon
BFM
Mon DRV
SEQR
UVC1
VC3
64
DRV
VC3
Mon
BFM
Mon
BFM
Mon DRV
SEQR
UVC
VC32
Benefits
Tests are shorter, and descriptive
Less knowledge to create a test
Easier to maintain changes are done
in a central location
tb
Test1
Test2
- Use only
legal frames
Test3
Use zero frame
delay
- Do not Have
sendTest4
out-of-order
4 masters
Back-to-back
short
Send long
frame streams
frames frames
Change the clock speed
Send many illegal frames
65
If config needs to be
changed, no need to
visit all tests
env
tb
env
env
env
env
env
env
env
endtask
Multiple tests
module top
`include . // uvm lib, test, and components
IF
IF
IF
DUT
initial begin
run_test(test1);
end
rst
clks
endmodule : top
DUT snapshot
the entire
together
and use
Allows execution Compile
of multiple
teststest
on suite
the same
snapshot
command-line option to select a test:
% irun f run.f +UVM_TESTNAME=test3
66
Testbench Example
class uart_ctrl_tb extends uvm_env;
`uvm_component_utils(uart_ctrl_tb)
apb_env apb0; // APB UVC
uart_env uart0; // UART UVC
uart_ctrl_env uart_ctrl0; // Module UVC
Multi-Channel Sequences
69
Multi-Channel Sequences
uart_ctrl_env
virtual_sequencer
config_dut
u2a_incr_payload
uart_incr_seq
p_apb_seqr
p_uart_seqr
apb_rd_rx_fifo
uart_env
apb_env
apb_agent
uart_agent
uart_sequencer
apb_sequencer
seq
config_dut
uart_incr_seq
seq
rd_rx_fifo
Driver
70
Driver
Determining End-of-Test
Virtual Sequencer
coordinates traffic on
UVC1 and UVC2
virtual
sequences
Virtual
Sequencer
sequences
vseq2
UVC2
seqr
DUT
drvr
mon agent
sequences
ovc2_seq1
drvr seqr
How do we decide
when to end a test?
71
...
fork
`uvm_do_on(ovc2_seq1, ovc2)
`uvm_do_on(ovc1_seq3, ovc1)
Join
...
UVC1
agent mon
ovc1_seq3
UVC3
sequences
ovc3_seq1
agent mon
seqr
drvr
21 December 2011
Cadence Confidential
Drain Time
When all raised objections are dropped, simulation is stopped
A drain time allows propagation of outstanding items (e.g., DUT
response)
If no drain time is set, the test will stop immediately
73
21 December 2011
Cadence Confidential
Agenda
74
75
76
Agenda
Introduction to UVM and Coverage Driven Verification
UVM:
The UVM Library
Stimulus Generation
Building Reusable Verification Components
Testbench Creation Using Reusable Components
UVM Multi-Language and UVM Acceleration
Summary
77
AOP
VM
SystemC
System
Verilog
SV
SysC
Methodology includes TLM
communication between implementations
Cadence Confidential
VM
UVM
e
UVC
SV
UVC
UVC
SoC
SC
UVC
SC
UVC
C/C++
VIP
SV
VIP
Hardware Accelerator
Simulator
SoftwareSoftware
Simulator
Agent
Agent
Sequencer
Sequencer
Monitor
Monitor
events,
Coverage
status,
Checking
data
sequences
sequences
Collector
Collector
UVM ACCEL mode
Driver
Driver
UVM ACCEL mode
VIF
SCE-MI
PROXY
VIF
SCE-MI
PROXY
I/F
I/F
(collector_bfm)
I/F
(driver_bfm)
DUT
DUT
80
Cadence provides
UVM library extensions: UVM_Accel
Methodology
Examples
Support SV and e
Enables verification re-use
between simulation and
acceleration
Simulator
Transactions
SCE-MI pipe C
interface
Host
Workstation
81
SCE-MI
2.0
Interface
Sce-mi modules
(RTL)
UVM
Pipes Proxy
Driver
(HVL)
UVM
Testbench
Accelerator
Clock
DUT
BFM
(HDL)
signal-level
interface
Cadence
PdXP
82
Design Browser
83
Methods Tab
84
85
86
Constraint Debugger
87
Constraint Debug
This portion
lists the
variables and
their values. All
variables are
listed in the
object since
state variables
can be used in a
constraint.
89
Agenda
90
91
Beyond UVM
Inside the Incisive Platform
Unique Metrics Driven Methodology around UVM
Scalable register & memory modeling package
reg_mem downloadable from uvmworld.org/contributions.php
Useful Websites
UVM World Website:
http://uvmworld.org
Download latest version of UVM library, join the Community Forum to share
ideas and have discussions with other UVM users
93
Learning more
A Practical Guide to Adapting the Universal
Verification Methodology (UVM), by Sharon
Rosenberg and Kathleen A Meade
94
Thank You!
95