Sva in A Uvm Class Based Environment VH v9 I3
Sva in A Uvm Class Based Environment VH v9 I3
The unique capabilities of SVA Figure 2.0 Using the results of an assertion to stop the
simulator3 http://SystemVerilog.us/verizons/sc2uvm.sv
in a verification environment
SVA provides two types of assertions: immediate and
concurrent. Immediate assertions are executed like a import uvm_pkg::*; `include “uvm_macros.svh”
statement in a procedural block and do not need a clocking class dut_xactn extends uvm_sequence_item;
event to trigger the assertion, as that is controlled by the endclass : dut_xactn
procedural block when the code reaches the assertion. k and h are static class variables
class C; that can be read and written from
An example of an immediate assertion commonly used in static int k=9; within modules and interfaces.
UVM is something as the following: static bit h;
int v =5;
assert($cast(rsp_item, req_item.clone()) else rand int r; k is updated in a class
`uvm_error(“driver”,$sformatf(“%m : error in task test(); (in this or some other class)
casting rsp_item”))); // some actions
if(v==5) k=1000; else k=0;
Concurrent assertions are temporal, are based on clock endtask : test
semantics, and use sampled values of static variables. endclass : C
Assertions can also access static variables defined in
interface bus_if(input bit clk);
classes; however, access to dynamic or rand variables is class declaration
C c; (no instantiation needed)
illegal. Concurrent assertions are illegal within classes, but bit a, b, d;
can only be written in modules, SystemVerilog interfaces, bit done_abc; // for use by class
and SystemVerilog checkers2. As will be shown in the clocking cb @ (posedge clk); endclocking
25
// update statis class variable and interface variable apabc : assert property (@ (cb)
for use by other classes $rose(a) |=> (b, f(1’b1), $dumpon ) ##[1:10] (c,
task updates(bit done); $dumpoff));
done_abc <= done; c.k is used in an assertion.
Action block updates c.h initial begin
c.h <= done; and done_abc $dumpvars (0, top); Other functions can also be
endtask : updates end called, including system level
apEndProp : assert property (@ (cb) functions.
endinterface
$rose(a) && c.k==1000 |=> b ##[1:10] d) module top;
updates(1’b1); logic x =1, y=0, z;
endinterface endmodule : top
26
// This is then followed by b==1 within 5 cycles cache_hit_error <= 1’b0; else cache_hit_
after that. error <= 1’b1;
property p_ab_min; ap_cache_miss_access: assert property(@ (cb)
int count_v; rd |=> !cache_hit |->
($rose(a), count_v=count) |=> !data_valid[*4] ##1 data_valid)
(!b, count_v-=1’b1)[* 1:$] ##1 count_v==0 cache_miss_error <= 1’b0; else cache_
##[1:5] b; miss_error <= 1’b1;
endproperty : p_ab_min endinterface : c_if
ap_ab_min: assert property(@ (posedge clk)
p_ab_min)
ab_error <= 1’b0; else ab_error <= 1’b1;
endinterface : b_if Enhanced coverage sampling
SystemVerilog assertion statements enable the control of
transaction recording from action blocks or sequence match
For more complex problems, a scoreboard data structure item, i.e., from any clocking event when a variable is true.
can keep track of conditions (driven and expected), and This can be used in the setting of values within a module
the assertions in the SystemVerilog interfaces can then or interface, or to call any function, including the call of the
sample() function to sample group coverage. The following
determine the correctness of DUT’s responses. For
example demonstrates the concepts.
example, assume that a scoreboard keeps track of the
expected caching of data in the variable abc is accessible Figure 6.0 Use of assertions for covergroup sampling
by a class instance It is modified by a function called from
within a sequence of an assertion. Other functions can
also be called, including system level functions. DUT’s typedef enum {NOP, ADD, SUB, MULT, JMP, MOV,
READ, WRITE,
memory based on a caching algorithm. The scoreboard
IDLE} instr_e;
can keep track of an expected miss or hit (cache_hit), typedef enum {FETCH, DECODE, EXECUTE} mode_e;
and transfer that information, along with the value of any typedef enum {PC, IR1, IR2, REGA, REGB, MAR,
expected data (expected_data) into a SystemVerilog REG_FILE, STK} resource_e;
interface. Assertions in that interface can then verify the interface cpu_if(input logic clk);
correct response from the DUT and log in any detected clocking cb @ (posedge clk); endclocking
instr_e instr;
errors (cache_hit_error, cache_miss_error), which can
resource_e resource;
then be read by the class instance. mode_e mode;
Figure 5.0 Use of scoreboard values from class
logic[15:0] addr;
variables for use in assertions covergroup instr_cg;
InstXrsc : cross instr, resource;
endgroup : instr_cg
interface c_if (input logic clk); instr_cg instr_cg1 =new();
bit rd, wr, data_valid; covergroup addr_cg @(clk);
bit cache_hit_error, cache_miss_error; // f for addr_cp : coverpoint addr
use by class-based verification unit { bins instruction = {[0:255]};
bit cache_hit; // f for this read address, bins data = {[256:32767]};
supplied by scoreboard }
Sampling of cover group
in cycle after the rd endgroup : addr_cg from a sequence
logic [15:0] mem_data; addr_cg addr_cg1 =new();
logic [15:0] expected_data; // f supplied by sequence q_fetch; @ (clk)
scoreboard mode==FETCH ##1 (1, instr_cg1.sample(),
logic [31:0] addr; addr_cg1.sample());
clocking cb @ (posedge clk); endclocking endsequence : q_fetch
ap_cache_hit_access: assert property(@ (cb) cover property (q_fetch); // f Enables the sampling
rd |=> cache_hit |-> in cycle following the mode==FETCH
mem_data==expected_data) endinterface : cpu_if
27
UVM SEVERITY LEVELS IN SVA For bus protocol types of verification properties (signal level
verification), we recommend SVA at the interfaces instead
UVM provides several macros that resemble the of using scoreboarding with compare as a verification
SystemVerilog severity levels, but provide more options, technique. If a tool supports SystemVerilog checkers
verbosity, and consistency with the UVM verification (1800-2009 and 2012), use checkers bound to interfaces.
environment. In our SystemVerilog Assertions Handbook, Assertion results can be written into the interface variables
3rd Edition, we recommend the use of the UVM severity or class static variables for control and access by the UVM
levels in all SVA action blocks instead of the SystemVerilog environment. For coverage of temporal properties, use
native severity levels. For example, assertions in SV interfaces. For covergroups that require the
completion of temporal sequences as the sampling trigger,
use SVA sequences that can transfer the sampling triggers
string tID=”UART “;
ap_MEDIUM: assert property(a) else
to class variables. Use UVM severity levels in all SVA
`uvm_info(tID,$sformatf(“%m : error in a %b”, a), action blocks instead of the SystemVerilog native severity
UVM_MEDIUM); levels. Use SVA immediate assertions to flag unsuccessful
ap_handshake : assert property ($rose(req) |=> randomization and terminate the simulation run.
##[0:4] ack) else
`uvm_error(tID, $sformatf(“%m req = %0h, END NOTES
ack=%0h”, $sampled(req),
$sampled (ack))); 1. MENTOR GRAPHICS UVM/OVM documentation
verification methodology online cookbook
See http://systemverilog.us/uvm_hi_low3.pdf for a
discussion on this topic along wth simulation results. 2. See Chapter 17 of SystemVerilog 1800-2012.
3. SystemVerilog Assertions Handbook, 3rd Edition
with IEEE 1800-2012, ISBN 978-0-9705394-3-6
CONCLUSIONS AND RECOMMENDATIONS http://SystemVerilog.us
28
Editor: Tom Fitzpatrick
Program Manager: Rebecca Granquist
To subscribe visit:
www.mentor.com/horizons