Doku - Pub Uvm-Ramakrishna
Doku - Pub Uvm-Ramakrishna
05-May-2011 SM Silicon
04-Aug-2011 Sahara DV
20-Dec-2011 wpu-all
For Internal Knowledge Sharing Purpose only.
Confidential
SM Silicon India
Pvt Ltd
Agenda
1. World of UVM
2. Brief understanding of Migration
from HDL to UVM
3. Phases
4. Framework understanding (walk
through a simple code)
5. Sample Make file and run an
example
1. World of UVM
What is UVM?
• UVM was created by Accellera based on the OVM (Open Verification Methodology) version
2.1.1. The roots of these methodologies lie in the application of the languages IEEE 1800™
SystemVerilog, IEEE 1666™ SystemC, and IEEE 1647™ e.
• UVM is explicitly simulation-oriented, but UVM can also be used alongside assertion-based
verification, hardware acceleration or emulation.
• UVM test benches are more than traditional HDL test benches, which might wiggle a few
pins on the design-under-test (DUT) and rely on the designer to inspect a waveform diagram
to verify correct operation.
• UVM test benches are complete verification environments composed of reusable verification
components, and used as part of an overarching methodology of constrained random,
coverage-driven, verification.
[Just a quick snippet] When its traditional test, what
we remember
module test(PAddr, PWrite, PSel, PRData, Rst, clk);
// Port declarations omitted...
initial begin
// Drive reset
Rst <= 0;
#100 Rst <= 1;
// Toggle PEnable
@(posedge clk)
PEnable <= 1'b1;
@(posedge clk)
PEnable <= 1'b0;
endmodule
Back to Why UVM?
Checkers can be implemented using SystemVerilog assertions or using regular procedural code.
Assertions can be embedded within the design-under-test, placed on the external interfaces, or can be
part of the verification environment.
UVM provides mechanisms and guidelines for building checkers into the verification environment
and for logging reports
SystemVerilog offers two separate mechanisms for functional coverage collection; property-based
coverage (cover directives) and sample-based coverage (covergroups).
Both can be used in an UVM verification environment
Engineering Effort
Automated coverage collection gives accurate feedback on the progress of the verification
effort, and the emphasis on verification planning ensures that resources are focussed on
achieving agreed goals
Verification Reuse
Verification reuse is enabled by having a modular verification environment where each
component has clearly defined responsibilities, by allowing flexibility in the way in which
components are configured and used, by having a mechanism to allow imported components to
be customized to the application at hand, and by having well-defined coding guidelines to
ensure consistency.
The architecture of UVM has been designed to encourage modular and layered verification
environments, where verification components at all layers can be reused in different
environments
Test scenarios can be reused from application to application
Flexibility is built into the UVM class library
Worlds simplest spec and lets derive a verification
plan for it.
Given condition X, the design shall exhibit a
It is important
behavior Y. for the verification plan to document the
verification requirements. Generally speaking, three categories
of requirements exist:
This default behavior allows you to add constraints to the data item class in
order to control the distribution of randomized values. Unlike generators that
randomize arrays of transactions or one transaction at a time, a sequencer
captures important randomization requirements out-of the-box.
• The
uvm_sequencer
base class contains
all of the base
functionality required
to allow a sequence
to communicate with
a driver.
A monitor:
— Collects transactions (data items). A monitor extracts signal information from a bus and translates
the information into a transaction that can be made available to other components and to the test
writer.
Note:
A— bus monitor
Extracts events. The handles
monitor detectsallthethe signals
availability and transactions
of information on a
(such as a transaction),
bus, while an agent monitor handles only signals and
structures
the data, and emits an
transactions event to notify
relevant to other
a componentsagent.
specific of the availability of the transaction. A
monitor
also captures status information so it is available to other components and to the test writer.
Typically, drivers and monitors are built as separate entities
(even though
— Performs they
checking and may use the same signals) so they can
coverage.
Checking typically consists of protocol and data checkers to verify that the DUT output meets the
work independently of each other.
protocol specification. Coverage also is collected in the monitor.
However, you
— Optionally prints can
trace reuse code that is common between a
information.
driver
and a monitor to save time.
class master_monitor extends uvm_monitor;
Basic UVM virtual bus_if xmi; // SystemVerilog virtual interface
bit checks_enable = 1; // Control checking in monitor and interface.
flow bit coverage_enable = 1; // Control coverage in monitor and interface.
uvm_analysis_port #(simple_item) item_collected_port; Note:
event cov_transaction; // Events needed to trigger covergroups
— The monitor protected simple_item trans_collected; Coverage collection and
`uvm_component_utils_begin(master_monitor)
collects bus `uvm_field_int(checks_enable, UVM_ALL_ON) checking are conditional
`uvm_field_int(coverage_enable, UVM_ALL_ON)
information `uvm_component_utils_end because they can affect
through a covergroup cov_trans @cov_transaction;
option.per_instance = 1; simulation run-time
virtual ... // Coverage bins definition
performance.
endgroup : cov_trans
interface function new (string name, uvm_component parent);
super.new(name, parent);
(xmi). cov_trans = new();
cov_trans.set_inst_name({get_full_name(), ".cov_trans"}); If not needed, they can be
trans_collected = new();
item_collected_port = new("item_collected_port", this); turned off by setting
— The endfunction : new
collected data virtual task run_phase(uvm_phase phase); coverage_enable or
is used in
fork
collect_transactions(); // Spawn collector task. checks_enable to 0, using
join
coverage endtask : run the
collection and
virtual protected task collect_transactions();
forever begin configuration mechanism.
checking. @(posedge xmi.sig_clock);
...// Collect the data from the bus into trans_collected. For example:
if (checks_enable)
perform_transfer_checks();
— The
if (coverage_enable)
perform_transfer_coverage(); uvm_config_db#(bit)::set(t
collected data item_collected_port.write(trans_collected);
end his,“*.master0.monitor”,
is exported on endtask : collect_transactions
“checks_enable”, 0);
virtual protected function void perform_transfer_coverage();
an analysis -> cov_transaction; Data Item
endfunction : perform_transfer_coverage
port virtual protected function void perform_transfer_checks(); (Transaction)
Driver (BFM)
(item_collect ... // Perform data checks on trans_collected.
endfunction : perform_transfer_checks Sequencer
ed_port). endclass : master_monitor Enabling Scenario
Creation
Monitor
Agent
General understanding of Coverage
Definition and Implementation
Three elements of information must be defined for each coverage item.
WHAT to observe
WHEN to observe it
WHERE to observe it
The WHAT, WHEN, and WHERE are embedded right inside the
covergroup code.
A transfer cycle is valid Cover WHAT: {cyc_i, stb_i} = {00, 01, 10, 11}
only when cyc_i and stb_i (property WHEN: each time {cyc_i, stb_i} has a value
are asserted; otherwise, it ) change
is ignored WHERE: bus interface on design
…//snippet
wire [1:0] wb_cyc_stb = {cyc_i, stb_i};
reg [1:0] wb_cyc_stb_r;
event ev_cyc_stb_changed;
Here is a list of the changes required to convert from UVM-EA to fully compliant UVM-1.0
code
(UVM-1.0 was released in February 2011)
We will see…
a. Modules to the UVM Component
b. HDL Processes to the UVM Run
Phase
c. HDL Input and Output Ports to TLM
Ports and Exports
d. Verilog Parameters to UVM
Configurations
e. VHDL Records to Transactions
2.a. Modules to the UVM Component
// VERILOG // UVM
class A extends uvm_component;
module A;
wire w; `uvm_component_utils(A)
B B_instance( .p(w) );
B B_h;
C C_instance( .q(w) ); C C_h;
endmodule
//constructor
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
endclass
[contd] explanation for previous slide
• In the example above, a top-level block named A instantiates two lower level blocks
named B and C.
• The Verilog module instances named B_instance and C_instance are replaced in UVM by
the SystemVerilog variables B_h and C_h, the suffix _h indicating that the variable is a
handle to an object rather than being the object itself.
• The UVM equivalent of Verilog module instantiation is done within function build_phase,
and the UVM equivalent of Verilog port connection is done within function
connect_phase.
• UVM ports are analogous to Verilog ports and can even be connected by name like
Verilog ports, although unlike Verilog ports UVM ports are used to pass transactions using
function calls (more on this later).
• The rest of the UVM component should be treated like boilerplate code and just
reproduced as shown in each and every component. This includes the
uvm_component_utils line, the function new (which is known technically as the
constructor of the class), and the skeleton of the functions build_phase and
connect_phase.
2.b HDL Processes to the UVM Run Phase
-- VHDL // UVM
entity D is class D extends uvm_component;
end entity;
`uvm_component_utils(D)
endclass
producer producer_h;
consumer consumer_h;
producer_h.my_port.connect( consumer_h.my
_export );
endfunction
endclass
[contd] Explanation of previous 2 slides
• Whereas in Verilog a producer would make an assignment to an output port, in UVM a producer
would make a call to the put method through a port.
• Whereas in Verilog a consumer would have a process sensitive to an input port and would then
read the value of that input port when it changes, in UVM a consumer would provide an
implementation of the put method and also an export that can be hooked to the corresponding
port on the producer.
• In the example above you can see the producer making the call
my_port.put(99);
and the consumer providing an implementation of put
function void put(int arg);.
// UVM
class producer_config extends uvm_object;
endclass
contd
// UVM
class producer extends uvm_component;
...
producer_config config_h;
// Configuration parameters
bit param1 = 0;
int param2 = 0;
string param3;
...
function void build_phase(uvm_phase phase);
super.build_phase(phase);
my_port = new("my_port", this);
begin
if ( uvm_config_db #(producer_config)::get(this, "", "config",
config_h) )
begin
param1 = config_h.param1; // Local parameters copied from
configuration object
param2 = config_h.param2;
param3 = config_h.param3;
end
end
endfunction
...
endclass
contd
// UVM
class my_test extends uvm_test;
...
function void build_phase(uvm_phase phase);
super.build_phase(phase);
begin
producer_config config_h = new;
config_h.param1 = 1; // Set test-specific values for
configuration parameters
config_h.param2 = 2;
config_h.param3 = 3;
uvm_config_db #(my_agent_config)::set(this, "*.*producer*",
"config", config_h);
end
top_h = top::type_id::create("top_h", this);
endfunction
endclass
2.e VHDL Records to UVM Transactions
// UVM
-- VHDL package my_pkg;
package my_pkg class my_transaction extends
is uvm_sequence_item;
type
my_transaction is `uvm_object_utils(my_transaction)
record
data: integer; rand int data;
end record;
// Other attributes of the transaction go
end package;
here...
endclass: my_transaction
Endpackage
1. World of UVM
2. Brief understanding of Migration
from verilog to UVM
3. Phases
4. Defining a Skelton (walk through a
simple code)
5. Sample Make file and run an
example
3. Phases
In Conventional Verilog there Because UVM is SystemVerilog it
shares SystemVerilog's phases, but
are three fixed phases the SystemVerilog simulation phase is
further broken down within UVM into:
PPT Notes
Added
[contd]
build()
UVM provides
This phase is usedan objection
to construct mechanism
various child components/ports/exports and configures them.
to allow hierarchical status class interesting_sequence extends
communication
connect() among components. uvm_sequence#(data_item);
This phase is used for connecting the ports/exports of the components.
Phases
uvm_test_top.t_env.ag1.drv [uvm_test_top.t_env.ag1.drv] End_of_elaboration
uvm_test_top.t_env.ag1.mon [uvm_test_top.t_env.ag1.mon] End_of_elaboration
uvm_test_top.t_env.ag1 [uvm_test_top.t_env.ag1] End_of_elaboration
uvm_test_top.t_env.ag2.drv [uvm_test_top.t_env.ag2.drv] End_of_elaboration
uvm_test_top.t_env.ag2.mon [uvm_test_top.t_env.ag2.mon] End_of_elaboration
uvm_test_top.t_env.ag2 [uvm_test_top.t_env.ag2] End_of_elaboration
uvm_test_top.t_env [uvm_test_top.t_env] End_of_elaboration
uvm_test_top [uvm_test_top] End_of_elaboration
----------------------------------------------------------------------
Name Type Size Value
----------------------------------------------------------------------
uvm_test_top test1 - uvm_test_top@2
t_env env - t_env@4
ag1 agent - ag1@6
drv driver - drv@12
rsp_port uvm_analysis_port - rsp_port@16
sqr_pull_port uvm_seq_item_pull_+ - sqr_pull_port@14
mon monitor - mon@10
ag2 agent - ag2@8
drv driver - drv@20
rsp_port uvm_analysis_port - rsp_port@24
sqr_pull_port uvm_seq_item_pull_+ - sqr_pull_port@22
mon monitor - mon@18
uvm_test_top.t_env.ag1.drv[uvm_test_top.t_env.ag1.drv]Start_of_simulation
uvm_test_top.t_env.ag1.mon[uvm_test_top.t_env.ag1.mon]Start_of_simulation
uvm_test_top.t_env.ag1[uvm_test_top.t_env.ag1]Start_of_simulation
uvm_test_top.t_env.ag2.drv[uvm_test_top.t_env.ag2.drv]Start_of_simulation
1. World of UVM
2. Brief understanding of Migration
from verilog to UVM
3. Phases
4. Defining a Skelton (walk through a
simple code)
5. Sample Make file and run an
example
4. UVM Boilerplate Code Framework
(like a rough Skelton)
import uvm_pkg::*;
dut_if1.reset = 1;
repeat(3) @(negedge +
dut_if1.clock); my_pkg
dut_if1.reset = 0;
endmodule: dut end This library has classes are for
initial
begin: blk
uvm_config_db #(virtual callback interface
dut_if)::set(null, "*", "dut_vi", driver
dut_if1); monitor
agent configuration
uvm_top.enable_print_topology agent
= 1; subscriber
uvm_top.finish_on_completion env
= 1; callback modification
report catcher
run_test("my_test"); test
1. World of UVM
2. Brief understanding of Migration
from verilog to UVM
3. Phases
4. Defining a Skelton
5. Sample Make file and run an
example
5. Sample Make file and a Run
Example (Hierarchy View in DVE)
Open VNC or NX
For Live demo
[General Ending Note]
What’s the strategy for a good
verification plan ?
• A good verification methodology starts with a statement of the function the DUT is
intended to perform.
• From this is derived a verification plan, broken down feature-by-feature, and agreed in
advance by all those with a specific interest in creating a working product. This verification
plan is the basis for the whole verification process.
• Verification is only complete when every item on the plan has been tested to an acceptable
level, where the meaning of "acceptable" and the priorities assigned to testing the various
features have also been agreed in advance and are continually reviewed during the project.
• Functional checking must be automated if the process is to scale well, as must the
collection of verification metrics such as the coverage of features in the verification plan
and the number of bugs found by each test.
• Along with the verification plan, automated checking and functional coverage collection
and analysis are cornerstones ofTake help
any good of UVM.
verification methodology.
UVM is here to stay. Period.
• Checkers and a functional coverage model, linked back to the verification plan, take
engineering time to create but result in much improved quality of verification.
Thankyou
Pls support yourself if you want to getinto the world of
UVM.
1. UVM user guide
2. SV P-1800 LRM
3. Verification Academy
4. Vendor support sites (supportnet from
MentorGraphics, solvnet of Synopsys,
support.cadence.com)
5. Uvmworld.org
6. Accelerra
7. Testbench.in, asicworld, Ubus Example part of User
Guide, other sites
8. Legacy blogs of ovm, vmm
Reportin Factory
Globals Base
g
Synchroniza
Configuration tion
and UVM
Resources Classes Policies
Containe and
rs
utilities Componen
ts
TLM
Macros Register
Sequence Sequenc Layer
rs es Command Line
Processor
PPT Notes
Added