Beruflich Dokumente
Kultur Dokumente
June 2013
© 2011-2013 Cadence Design Systems, Inc. All rights reserved worldwide.
Printed in the United States of America.
Cadence Design Systems, Inc., 2655 Seely Avenue, San Jose, CA 95134, USA
Trademarks: Trademarks and service marks of Cadence Design Systems, Inc. (Cadence) contained in this document are attributed
to Cadence with the appropriate symbol. For queries regarding Cadence's trademarks, contact the corporate legal department at the
address shown above or call 800.862.4522.
Open SystemC, Open SystemC Initiative, OSCI, SystemC, and SystemC Initiative are trademarks or registered trademarks of Open
SystemC Initiative, Inc. in the United States and other countries and are used with permission.
All other trademarks are the property of their respective holders.
Restricted Permission: This publication is protected by copyright law and international treaties and contains trade secrets and
proprietary information owned by Cadence. Unauthorized reproduction or distribution of this publication, or any portion of it, may
result in civil and criminal penalties. Except as specified in this permission statement, this publication may not be copied, reproduced,
modified, published, uploaded, posted, transmitted, or distributed in any way, without prior written permission from Cadence. Unless
otherwise agreed to by Cadence in writing, this statement grants Cadence customers permission to print one (1) hard copy of this
publication subject to the following conditions:
The publication may be used only in accordance with a written agreement between Cadence and its customer;
The publication may not be modified in any way;
Any authorized copy of the publication or portion thereof must include all original copyright, trademark, and other proprietary notices
and this permission statement;
The information contained in this document cannot be used in the development of like products or software, whether for internal or
external use, and shall not be used for the benefit of any other party, whether or not for consideration
Disclaimer: Information in this publication is subject to change without notice and does not represent a commitment on the part of
Cadence. The information contained herein is the proprietary and confidential information of Cadence or its licensors, and is supplied
subject to, and may be used only by Cadence's customer in accordance with, a written agreement between Cadence and its
customer. Except as may be explicitly set forth in such agreement, Cadence does not make, and expressly disclaims, any
representations or warranties as to the completeness, accuracy or usefulness of the information contained in this document.
Cadence does not warrant that use of such information will not infringe any third party rights, nor does Cadence assume any liability
for damages or costs of any kind that may result from use of such information.
Restricted Rights: Use, duplication, or disclosure by the Government is subject to restrictions as set forth in FAR52.227-14 and
DFAR252.227-7013 et seq. or its successor.
2 Cadence Confidential
Workshop Setup Instructions
This workshop uses the following environment variables that you must ensure are set.
• SOCV_KIT_HOME - Points to the install location of the kit and is used to refer to examples
contained inside the kit. It is used by both the full SoC Verification Kit and the reduced version
known as the IP Kit. The following illustrates how it should be set:
% setenv SOCV_KIT_HOME <INCISIV _install_dir>/kits/VerificationKit
• MY_WORK_AREA - Points to general purpose working directory that the user is required to
create. This is where all the workshop labs should be run from and kit navigator launched. The
user is free to have this work area located where ever they want. An example suggestion is:
% mkdir <path_to_local_work_area>/work
% setenv MY_WORK_AREA <path_to_local_work_area>/work
• MY_REGRESSION_AREA - Points to the directory Incisive Manager stores its regression
content into and must be created by the user. This folder can and should be cleaned periodically.
It is used to retain regression data between runs. This directory can be located anywhere but an
example suggestion is:
% mkdir $MY_WORK_AREA/sessions
% setenv MY_REGRESSION_AREA $MY_WORK_AREA/sessions
3 Cadence Confidential
The UVM Register Layer Classes (uvm_reg)
4 Cadence Confidential
Agenda
5 Cadence Confidential
Typical System-Level Environment
Many devices are attached to a bus
and have a register set that interfaces
between the DUT and a programmer’s
The CPU controls the entire model
system, by reading and SW Application
writing device registers
SW Device Drivers
SoC
CPU DMA Memory
(DUT)
CPU Bus (AHB)
Bridge
Peripheral Bus (Xbus)
XCore XCore USB Ethernet
6 Cadence Confidential
UVM Register Layer Classes: Motivation
SoC
(DUT) CPU DMA Memory
Bridge
DUT
Peripheral Bus (Xbus)
XCore XCore
XCore USB Ethernet
Peripheral Interface
8 Cadence Confidential
Configuring Devices Using uvm_reg
Register Register sequence executes
Sequence register operations
Adapter converts
register operations to Adapter
bus transactions Randomize environment
and DUT configuration
APB
Master UVC drives master
bus transactions seqr agent Register Model
driver mon Register Block
0x0000
memory
...
(4K)
dut apb_if 0x0FFF
0x1000 mode0
memctl 0x1001 mode1
0x1002 mode2
mem_inst 0x1003 mode3
mode0 status
0x1010
mode1
memory
mode2 32x4096
mode3 Register model shadows the
status registers, register blocks and
memories in the DUT
9 Cadence Confidential 9
Register Monitoring and Checking
Predictor:receives transactions:
Predictor
Adapter converts bus Write: update the model
transactions back to Adapter Read: compare (and update)
register operations Predictor the register model
Component
APB
master
seqr agent Register Model
A bus monitor captures
driver mon Register Block
transactions on the bus
and sends them via TLM 0x0000
memory Functional coverage
...
(4K) is sampled in the
dut apb_if 0x0FFF
register model
Clear separation 0x1000 mode0
memctl 0x1001 mode1
of injection and 0x1002 mode2
collection path is mode0 mem_inst 0x1003 mode3
0x1010 status
key! mode1
memory
mode2 32x4096 Register model (database) contains
mode3 address map(s) and is placed in the
status testbench. Also holds attributes
and expected values.
10 Cadence Confidential 10
Register Model instantiation and hook-up
Testbench
Module UVC Add the predictor component
Implement adapter Adapter Predictor to the module UVC
bus2reg and reg2bus object Component
tasks
...
driver coll
(4K)
0x0FFF
Virtual 0x1000 mode0
Sequencer 0x1001 mode1
apb_if
dut 0x1002 mode2
0x1003 mode3
memctl 0x1010 status
mode0 mem_inst
mode1
memory Place register model, adapter,
mode2 32x4096
module UVC and register
mode3
sequencer in the testbench.
status
12 Cadence Confidential
Registers and Register Operations
Reg-file
0x00 tx_mode Register: Status Reg
0x01 tx_status e error_count
7 6 0
0x02 rx_mode
0x03 rx_status
13 Cadence Confidential
UVM_REG
15 Cadence Confidential
Capturing UVM_REG Model
Following the IP-XACT Hierarchy
• IP-XACT is the Accellera XML standard format to capture the
register model (driven by the IPXACT sub-committee)
• Proprietary input formats can be used with caution
User manually creates reusable
UVM configuration sequences
Users capture their project
Register model in IPXACT
testbench
Register
Generator
IP-XACT Utility Reg classes
and DB Placed inside a testbench
for randomizing, checking,
Provided by Vendors and coverage
16 Cadence Confidential
Cadence IP-XACT Generator (example)
Command
$IREG_GEN/bin/ireggen –i ipxact_example.xml –d ./out –qt
Output
<++> Cadence iregGen version 1.03
<++> XML parsed. Started decoding
...... Cadence generator options:
<++> Decoding done -i (input file name)
<++> Input File: ./ipxact_example.xml -d (directory for output files)
<++> Number of AddrMaps = 1 -qt (creates a simple test)
<++> Number of RegFiles = 1
<++> Number of Registers = 6
<++> Number of Memories = 0
<++> Files Created : ./rdb.sv
<++> Files Created : ./quickTest.sv
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
To simlulate using INCISIVE:
irun -clean -uvmhome $UVM_HOME \
+incdir+. \
./quickTest.sv
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
17 Cadence Confidential
Why is IES the Best Platform for UVM_REG?
• Technology
– According to users, IES Simulator demonstrated significantly
more scalability than other simulators
– Cadence IPXACT Generator
• Supports both the UVM_RGM and the UVM_REG packages (via a
switch)
• IPXACT front-end is proven in many projects
• Supports capabilities that are not yet in the standard library
• Results are tuned for performance and scalability
• Includes IPXACT extensions for effective register verification
• Knowledge and expertise
– Cadence field team and services are familiar with the
UVM_REG new methodology and use model
18 Cadence Confidential
Agenda
19 Cadence Confidential
UVM_REG Building Blocks
• All objects extend from uvm_object config_reg
– Allows use of UVM automation features!
f4 f3 f2 f1
• Each field is instance of uvm_reg_field
– Fields have many attributes such as reset value, and access
mode
class config_reg extends uvm_reg;
– Holds three copies of the value: uvm_reg_field f1; // 1-bit
uvm_reg_field f2; // 1-bit
• Mirrored: What we think is in the HW uvm_reg_field f3; // 4-bits
• Value: A value to be randomized uvm_reg_field f4; // 2-bits
endclass : config_reg
• Desired: A desired value for the field
• Registers extend from uvm_reg class
– An abstract representation of a DUT register kind
– Contains one or more fields
– Register width set in constructor
– Doesn’t need to have an associated address
20 Cadence Confidential
Field Access Policies Supported
21 Cadence Confidential
UVM_REG Building Blocks (Continued)
– Each register is offset from a 0x08 ch3 ch2 ch1 ch0 status
common address
0x0C rsvd i3 i2 i1 i0 interrupt
– Useful for reuse at higher
levels of abstraction 0x10 count error_cnt
0x00
0xFF
22 Cadence Confidential
Blocks and Maps
Register Model
• Block (Register Model)
...
0x0000
– Extends from uvm_reg_block class
0x014 Config
– A quasi-static UVM component represents a
“shadow” model of registers/memories in 0x018 Status Reg
0x01C Interrupt File
the system address space
0x020 Error Cnt
– Blocks can be nested
...
– Every block has at least one map 0x800
• Map Memory
8x256
– Extends from uvm_reg_map class 0x8ff
...
– Holds the information required to drive
objects through various sequencer/driver 0x1000
pairs 0x1004 Sub-Block
– Address maps can be nested 0x11ff
...
0xffff
23 Cadence Confidential
UVM_REG Class Diagram
For scalability, no unique
class per field
uvm_reg_block uvm_reg
1..N 1..N
my_block my_reg uvm_reg_field
1..N
24 Cadence Confidential
Register Declaration Generated by iregGen
Typically does not need to be read by users
class config_reg_c extends uvm_reg; 7 6 2 0
f4 f3 f2 f1 config_reg
rand uvm_reg_field f1;
rand uvm_reg_field f2;
rand uvm_reg_field f3; UVM_REG fields
rand uvm_reg_field f4;
Hard Reset
virtual function void build();
f1 = uvm_reg_field::type_id::create(“f1");
f1.configure(this, 1, 0, "RW", 0, ‘h0, 1, 1, 1);
f2= uvm_reg_field::type_id::create("f2");
f2.configure(this, 1, 1, "RO", 0, ‘h0, 1, 1, 1); Enables randomization of the field
f3 = uvm_reg_field::type_id::create(“f3");
f3.configure(this, 4, 2, "RW", 0, ‘h0, 1, 1, 1);
f4= uvm_reg_field::type_id::create("f4"); In the build() method, each field
f4.configure(this, 2, 6, “WO", 0, ‘h0, 1, 1, 1); is created, and then configured
endfunction
Size Offset
`uvm_register_cb(config_reg_c, uvm_reg_cbs)
`uvm_set_super_type(config_reg, uvm_reg)
`uvm_object_utils(config_reg_c) Callback + derivation support
<spirit:usage>memory</spirit:usage>
<spirit:volatile>false</spirit:volatile>
0xff <spirit:access>read-write</spirit:access>
</spirit::register>
26 Cadence Confidential
Register File and Register Model
Generated by the iregGen script
class memctl_rf_c extends uvm_reg_block;
27 Cadence Confidential
Register Operations
uvm_reg_bus_op:
addr: sized integer
kind: READ, WRITE
data: the register variable
status: result of transaction
28 Cadence Confidential
Access APIs for memories / registers / field
29 Cadence Confidential
Register sequencer and sequences A reference to the register
model for reg sequences
• Register sequencer is an UVM
sequencer class memctl_reg_sequencer extends uvm_sequencer;
• Its sequence item is a `uvm_component_utils(memctl_reg_sequencer)
uvm_reg_bus_op
// Contains a pointer to the register model
– And not a sequence of registers memctl_reg_model_c reg_model;
– The operation itself is protocol- function new( string name, uvm_component parent);
neutral super.new(name, parent);
endfunction
endclass : memctl_reg_sequencer
Operation to perform
uvm_reg_bus_op
addr on a specific register
kind
data Register
Fields
The register to be Attributes
30 Cadence Confidential
accessed
Creating Register Sequences
class blk_seq extends uvm_reg_sequence;
my_regfile model;
Pointer to the register model container
`uvm_object_utils(blk_seq)
function new ( string name=“blk_seq“ );
super.new(name); Note that there are read/write
endfunction : new tasks that cover the do items
virtual task body();
uvm_status_e status;
int data; Frontdoor Write
model.config.write(status, ‘h12, .parent(this)); Backdoor Write
model.config.write(status, ‘h34, UVM_BACKDOOR, .parent(this));
model.config.read(status, data, UVM_BACKDOOR, .parent(this)); Backdoor Read
model.my_mem.write(status, ‘h8, ‘h1234_5678, .parent(this)); Memory frontdoor
void'(model.randomize());
model.update(status, UVM_BACKDOOR, .parent(this)); Container level
model.mirror(status, UVM_CHECK, UVM_BACKDOOR, .parent(this)); Backdoor update
endtask : body
endclass : blk_seq Container level
Cadence Confidential
Backdoor mirror
31
Agenda
32 Cadence Confidential
UART DUT and Verification Environment
Module Verification
Component
UVM Testbench Scoreboard
Imitates external
Programs the Interface & white-box device by
UART and coverage
generating frames
transfers traffic
Control/Status Control/Interrupt
Registers Logic
Multi-channel controller
Controls APB and Tests indicate which
UART components stimulus sequences to
Test 1 Test 2 Test 3 execute
33 Cadence Confidential
Steps for Integrating uvm_reg in UART Design
34 Cadence Confidential
Creating the Register Model
35 Cadence Confidential
IP-XACT Input
36 Cadence Confidential
Creating the Register Database
37 Cadence Confidential
Sample UART DUT Registers Specification
Address 7 6 5 4 3 2 1 0
0x00 DIV_LATCH0 div_val
38 Cadence Confidential
IP-XACT Format
<spirit:name>apb_uart_reg_db</spirit:name>
<!–REGISTER DATABASE NAME -->
<spirit:memoryMap> <!– START OF ADDRESS MAP DEFINITION -->
<spirit:name>uart_addr_map</spirit:name>
<spirit:addressBlock> <!-- START OF REGISTER FILE -->
<spirit:name>uart_rf</spirit:name>
<spirit:baseAddress>0x00</spirit:baseAddress>
<spirit:range>32</spirit:range>
<spirit:width>32</spirit:width>
<spirit:register> <!– UART CONTROL REGISTER -->
<spirit:name>control_reg</spirit:name>
<spirit:addressOffset>0x00</spirit:addressOffset>
<spirit:size>32</spirit:size>
<spirit:access>read-write</spirit:access>
<spirit:field> <!-- FIELD -->
<spirit:name>rxrs</spirit:name>
<spirit:bitOffset>0</spirit:bitOffset>
<spirit:bitWidth>1</spirit:bitWidth>
</spirit:field>
39
...
Cadence Confidential
IP-XACT Format – Vendor Extensions
<!-- FIELD VENDOR EXTENSIONS-->
<spirit:vendorExtensions>
<!-- collect_coverage: cov_all, cov_none, cov_update, cov_compare_and_update -->
• <vendorExtensions:collect_coverage>
The SPIRIT IP-XACT standard input format was
cov_all</vendorExtensions:collect_coverage>
incomplete for users needs
</spirit:vendorExtensions>
<!-- REGISTER VENDOR EXTENSIONS -->
– For example constraints, coverage,
<spirit:vendorExtensions>
backdoor path etc’ had to be
<!-- type:introduced
Optional - default is register_name -->
– IP-XACT supports
<vendorExtensions:type> vendor
control_reg_c extensions
</vendorExtensions:type>
<!-- Constraint: with special characters (less-than, greater-than) -->
<vendorExtensions:constraint>c1 { rxen.value == !txen.value;}</vendorExtensions:constraint>
<vendorExtensions:constraint>rtx_c { cclk.value == 1’b1;}</vendorExtensions:constraint>
<!– soft reset value and mask: Optional - set to 0 by default -->
<vendorExtensions:soft_reset_value>0x0014</vendorExtensions:soft_reset_value>
<vendorExtensions:soft_reset_mask>0xFFFFFFFF</vendorExtensions:soft_reset_mask>
<!-- compare and update masks: Optional - determines fields updated/compared during checking
<vendorExtensions:compare_mask>0x0000FFFF</vendorExtensions:compare_mask>
<vendorExtensions:update_mask>0x000001D7</vendorExtensions:update_mask>
</spirit:vendorExtensions>
40 Cadence Confidential
Running the Converter
• The Cadence IP-XACT parser reads the XML code and generates
the SV classes for the register/field definitions, register file, address
map and register database
41 Cadence Confidential
iregGen : ipXact to System-Verilog generator
$IREG_GEN/bin/iregGen
-i <fileName> # Input ipxact (XML) file
42 Cadence Confidential
Register Declaration Generated by iregGen
Typically does not need to be read by users
class config_reg_c extends uvm_reg; 7 6 2 0
f4 f3 f2 f1 config_reg
rand uvm_reg_field f1;
rand uvm_reg_field f2;
rand uvm_reg_field f3; UVM_REG fields
rand uvm_reg_field f4;
Hard Reset
virtual function void build();
f1 = uvm_reg_field::type_id::create(“f1");
f1.configure(this, 1, 0, "RW", 0, ‘h0, 1, 1, 1);
f2= uvm_reg_field::type_id::create("f2");
f2.configure(this, 1, 1, "RO", 0, ‘h0, 1, 1, 1); Enables randomization of the field
f3 = uvm_reg_field::type_id::create(“f3");
f3.configure(this, 4, 2, "RW", 0, ‘h0, 1, 1, 1);
f4= uvm_reg_field::type_id::create("f4"); In the build() method, each field
f4.configure(this, 2, 6, “WO", 0, ‘h0, 1, 1, 1); is created, and then configured
endfunction
Size Offset
`uvm_register_cb(config_reg_c, uvm_reg_cbs)
`uvm_set_super_type(config_reg_c, uvm_reg)
`uvm_object_utils(config_reg_c) Callback + derivation support
`uvm_object_utils(memctl_rf_c)
function new (input string name=“memctl_rf_c"); Address offset
super.new(name, UVM_NO_COVERAGE);
endfunction : new
endclass : memctl_rf_c
44 Cadence Confidential
Register Block Declaration (Register Model)
Generated by the iregGen script
class memctl_reg_model_c extends uvm_reg_block;
45 Cadence Confidential
Register (or container) Array
46 Cadence Confidential
New Register Types : Indirect Registers
47 Cadence Confidential
Indirect Registers: IPXACT Code
Note: Indirect address
<spirit:register> <!– INDIRECT DATA REGISTER--> registers are declared
<spirit:name>ireg</spirit:name> like normal registers
<spirit:addressOffset>0x5</spirit:addressOffset>
<spirit:size>16</spirit:size>
<spirit:access>read-write</spirit:access>
<spirit:vendorExtensions> <!-- REGISTER VENDOR EXTENSIONS -->
<vendorExtensions:type>ireg_c</vendorExtensions:type>
address register
<vendorExtensions:indirect_addr_reg>addr_reg</vendorExtensions:indirect_addr
<vendorExtensions:array>
<vendorExtensions:x_from>1</vendorExtensions:x_from>
offset value
<vendorExtensions:x_to>4</vendorExtensions:x_to>
<vendorExtensions:offset_calc>'h0+x-1</vendorExtensions:offset_calc>
</vendorExtensions:array>
</spirit:vendorExtensions>
</spirit:register>
48 Cadence Confidential
Indirect Register
class my_rf_t extends uvm_reg_block;
Indirect address register
rand addr_reg_t addr_reg;
rand ireg_t ireg[1:16]; Indirect data register
rand uvm_reg_indirect_data uvm_ireg_1;
Abstract data
virtual function void build(); register container
uvm_reg r[$];
….
addr_reg = addr_reg_type::type_id::create("addr_reg");
uvm_ireg_1 = new("uvm_ireg_1", 32, UVM_NO_COVERAGE);
for(int x=1; x<=16; x++) begin
ireg[x] = ireg_t::type_id::create($psprintf(“ireg[%0d]", x));
ireg[x].build();
ireg[x].configure(this, null, $psprintf("ireg_hdl[%0d]", x));
r.push_back(ireg[x]);
end
addr_reg.build();
uvm_ireg_1.build();
addr_reg.configure(this, null, ""); Indirect addr and data registers
49 Cadence Confidential
New Register Types : Shared (Twin) Registers
50 Cadence Confidential
Shared Registers: SystemVerilog Code
// Defined with read-only access in IPXACT
class reg_RO extends uvm_reg;
`uvm_object_utils(reg_RO)
virtual function void build();
Define shared register like normal
F1 = uvm_reg_field::type_id::create("F1");
registers
F1.configure(this, 8, 0, "RO", 0, 8'h00, 1, 0, 1);
F2 = uvm_reg_field::type_id::create("F2");
F2.configure(this, 8, 16, "RC", 0, 8'hFF, 1, 0, 1);
endfunction: build
endclass : reg_RO
// Defined with write-only access in IPXACT
class reg_WO extends uvm_reg;
`uvm_object_utils(reg_WO)
virtual function void build();
F1 = uvm_reg_field::type_id::create("F1");
F1.configure(this, 8, 4, "WO", 0, 8'hAA, 1, 1, 1);
F2 = uvm_reg_field::type_id::create("F2");
F2.configure(this, 12, 12, "WO", 0, 12'hCCC, 1, 1, 1);
endfunction: build
endclass : reg_WO
51 Cadence Confidential
Shared Registers: SystemVerilog Code (cont)
// Register File
class block_B extends uvm_reg_block;
`uvm_object_utils(block_B)
rand reg_RO R;
rand reg_WO W;
52 Cadence Confidential
New Register Types : Aliased Register
Note: Shared Register – Two registers accessed via the same address
Aliased Register – One register accessed via multiple addresses
53 Cadence Confidential
Aliased Register: SystemVerilog Code
2 Normal register
class my_reg_Ra extends uvm_reg;
declaration
rand uvm_reg_field F1;
...
virtual function void build(); class my_blk extends uvm_reg_block;
rand my_reg_Ra Ra;
F1 = uvm_reg_field::type_id::create("F1");
F1.configure(this, 8, 0, "RW",rand my_reg_Rb
0, 8'h0, 1, 1, 1); Rb; 2 instances of register
endfunction virtual function build();
... default_map = create_map("", 0, 4, UVM_BIG_ENDIAN);
endclass Ra = reg_Ra::type_id::create("Ra",,get_full_name());
Ra.configure(this, null);
class my_reg_Rb extends uvm_reg;
uvm_reg_field F1; Ra.build();
... Rb = reg_Rb::type_id::create("Rb",,get_full_name());
virtual function void build(); Rb.configure(this, null);
Rb.build();
F1 = uvm_reg_field::type_id::create("F1"); Aliased register at
default_map.add_reg(Ra,
F1.configure(this, 8, 0, "RO", 0, 8'h0, 1, 0, 1); ‘h0100); additional address offsets
endfunction default_map.add_reg(Rb, ‘h0200);
begin
alias_RaRb RaRb;
RaRb = alias_RaRb::type_id::create("RaRb",,get_full_name());
RaRb.configure(Ra, Rb);
end The 3rd class definition in
endfunction next slide
Cadence Confidential
endclass
54
Aliased Register: SystemVerilog Code
class write_also_to_F extends uvm_reg_cbs;
local uvm_reg_field m_toF;
function new(uvm_reg_field toF);
m_toF = toF;
endfunction
virtual function void post_predict(uvm_reg_field fld, uvm_reg_data_t value,
uvm_predict_e kind,uvm_path_e path,uvm_reg_map map);
if (kind != UVM_PREDICT_WRITE) return;
void'(m_toF.predict(value, -1, UVM_PREDICT_WRITE, path, map));
endfunction
endclass
class alias_RaRb extends uvm_object;
protected reg_Ra m_Ra;
protected reg_Rb m_Rb;
…… Aliasing function provided in 3rd class
function void configure(reg_Ra Ra, reg_Rb Rb); that link the 2 register type instance
write_also_to_F F2F;
m_Ra = Ra; m_Rb = Rb;
F2F = new(Rb.F1);
uvm_reg_field_cb::add(Ra.F1, F2F);
endfunction : configure
endclass : alias_RaRb
55 Cadence Confidential
Comments about the SV Register Code
56 Cadence Confidential
Lab DUT Introduction: UART DUT and Environment
Testbench Driving
RS
UART Module
rdb
Scoreboard uart_cover
(white box
coverage)
Monitor
UART DUT
APB txd
Tx FIFO Transmitter UART
sqr APB Mode sqr
Interface Switch rxd
Rx FIFO Receiver
mon drv mon drv
Control/Status Control/Interrupt
Registers Logic
Virtual Sequencer
57 Cadence Confidential
Lab 1 – Register File Definition and Generation
58 Cadence Confidential
Lab 1 – Register File Definition and Generation
59 Cadence Confidential
Lab 1 – Adding a Register to the XML File
• The definition can be added anywhere in the file, but please add it
after the ua_lcr register and before ua_div_latch1. (Look for the
LAB1 note in the file)
Register: Divisor Latch byte 0 Register Offset: 0x00
Reg Name: ua_div_latch0 Access: read-write
ResetVal: 0x01
Fields: [7:0] div_val (clock divisor value)
• You will also need to include the following vendorExtension:
type: ua_div_latch0_c (register_class_name)
constraint: c_div_val { div_val.value == 1; }
60 Cadence Confidential
Lab 1 – Generating the SystemVerilog Code
• The test builds the register database and calls the reset() to reset
all registers. Review the irun.log file to verify that the
ua_div_latch0 reset value is correctly set.
End of Lab 1!
61 Cadence Confidential
Agenda
62 Cadence Confidential
uvm_reg Connection Requirements
63 Cadence Confidential
Connecting the Register Database
64 Cadence Confidential
Register Model instantiation and hook-up
Testbench
Module UVC Add the predictor component
Implement adapter Adapter Predictor to the module UVC
bus2reg and reg2bus object Component
tasks
...
driver coll
(4K)
0x0FFF
Virtual 0x1000 mode0
Sequencer 0x1001 mode1
apb_if
dut 0x1002 mode2
0x1003 mode3
memctl 0x1010 status
mode0 mem_inst
mode1
memory Place register model, adapter,
mode2 32x4096
module UVC and register
mode3
sequencer in the testbench.
status
65 Cadence Confidential
Hooking Up the uvm_reg
66 Cadence Confidential
Step 1: Transaction Adapter
class reg2apb_adapter extends uvm_reg_adapter;
Transaction Adapter
`uvm_object_utils(reg2apb_adapter)
function new(string name = "reg2apb_adapter");
super.new(name);
supports_byte_enables = 1; If bus protocol support byte lane enables
provides_responses = 1;
If bus driver returns responses
endfunction
virtual function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw);
apb_rw apb = apb_rw::type_id::create("apb_rw");
apb.kind = (rw.kind == UVM_READ) ? apb_rw::READ : apb_rw::WRITE;
apb.addr = rw.addr; apb.data = rw.data;
return apb; reg2bus function
endfunction
virtual function void bus2reg(uvm_sequence_item bus_item, ref uvm_reg_bus_op rw);
apb_rw apb;
if (!$cast(apb,bus_item)) begin
`uvm_fatal("NOT_APB_TYPE“, "Provided bus_item is not of the correct type")
return;
end Bus2reg function
rw.kind = apb.kind ? UVM_READ : UVM_WRITE;
rw.addr = apb.addr; rw.data = apb.data; rw.status = UVM_IS_OK;
endfunction
endclass
Cadence Confidential
67
Step 2: Testbench Activities
Testbench
Module UVC Add the predictor component
Implement register Adapter Predictor to the module UVC
sequencer and virtual object Component
sequencer
...
driver coll
(4K)
0x0FFF
Virtual 0x1000 mode0
Sequencer 0x1001 mode1
apb_if
dut 0x1002 mode2
0x1003 mode3
memctl 0x1010 status
mode0 mem_inst
mode1
memory Place register model, adapter,
mode2 32x4096
module UVC and register
mode3
sequencer in the testbench.
status
68 Cadence Confidential
Integrating a Register Model
class uart_ctrl_tb extends uvm_env;
// Testbench components – interface and module UVCs, Virtual Sequencer, config, etc
uart_ctrl_virtual_sequencer virtual_sequencer; // multi-channel sequencer
apb_pkg::apb_env apb0; // APB UVC
Register model declaration
uart_pkg::uart_env uart0; // UART UVC
uart_ctrl_env uart_ctrl0; // MODULE UVC
uart_ctrl_config cfg;
69 Cadence Confidential
Testbench Components build_phase() method
function new(input string name, input uvm_component parent=null);
super.new(name,parent);
endfunction
Register model build.
// class apb_uart_tb extends uvm_env … To enable reuse, first check if it’s
virtual function void build_phase(uvm_phase phase); build at higher level.
super.build_phase(phase);
// Configure and build UVCs
…
//Build register components
if (reg_model == null) begin
reg_model = uart_ctrl_reg_model_c::type_id::create("reg_model");
reg_model.build(); //NOTE: not same as build_phase: reg_model is an object
reg_model.lock_model();
Transaction adapter creation
end
reg2apb = reg_to_apb_adapter::type_id::create("reg2apb");
endfunction : build_phase
70 Cadence Confidential
Testbench Components connect_phase()
Method
// class uart_ctrl_tb extends uvm_env;
function void connect_phase(uvm_phase);
super.connect_phase(phase);
// Hook up virtual sequencer,TLM ports, etc Register sequence running
// . . . on APB bus sequencer
// UVM_REG Connections
reg_model.default_map.set_sequencer(apb0.master.sequencer, reg2apb);
……
endfunction : connect_phase
71 Cadence Confidential
Handling Reset
72 Cadence Confidential
Handling Reset - Example
class my_testbench extends uvm_env;
...
// Task to reset shadow register database
task reset_reg(); Detect hard reset
forever begin
wait (tb_top.reset === 1);
uvm_report_info(get_type_name(), “Resetting Shadow Registers");
reg_model.reset();
uvm_report_info (get_type_name(), “Reset Complete");
wait (tb_top.reset == 0);
end
endtask
Forgetting the reset is a common hook up mistake
task run();
fork
reset_reg();
join_none
…
73 Cadence Confidential
Lab 2: Adding the Register Components
• For this lab, you will be hooking up the register components in the
uart_ctrl design.
• Objectives:
– Review the transaction adapter and register model
– Hook up the required components in the testbench
– Handling reset
74 Cadence Confidential
Lab 2: Adding the Register Components
75 Cadence Confidential
Lab 2A: Finish transaction adapter
• NOTES:
• Search for LAB2A comments in your lab database files.
76 Cadence Confidential
Lab 2B: Adding register model to testbench
• NOTES:
• Search for LAB2B comments in your lab database files.
77 Cadence Confidential
Lab 2B: Adding register model to testbench
78 Cadence Confidential
Lab 2B: Adding register model to testbench
79 Cadence Confidential
End of Lab 2!
Lab 2C: Properly Handling Reset
• You will eventually have issues with reset unless you put in code to
handle a hard reset.
• Edit the uart_ctrl_tb.sv file in this directory.
(NOTE: Search for LAB2C in your lab database files)
– Finish reset_reg() task to call the reset() for the register model and print the
register model and it’s reset value.
– Change run_phase() to add call reset_reg there.
$SOCV_KIT_HOME/soc_verification_lib/sv_cb_ex_lib/uart_ctrl/tb/sc
ripts/run.sh
80 Cadence Confidential
End of Lab 2!
Agenda
81 Cadence Confidential
Controlling Register Scenarios
82 Cadence Confidential
uvm_reg run-time Tasks
83 Cadence Confidential
Access APIs for Memories, Registers, Fields
84 Cadence Confidential
Creating Sequences
class blk_seq extends uvm_reg_sequence;
The do actions are hidden with
`uvm_object_utils(blk_seq) read/write routines
Seq’s container
my_rf model; It is useful to combine positional
and named arguments binding
virtual task body();
Frontdoor Write
uvm_status_e status;
int data; Backdoor Write
endclass: blk_seq
86 Cadence Confidential
Lab 3: Register Sequences
• For this lab, you will be exploring register sequences for the
uart_ctrl design from our SOC Verification Kit
• Objectives
– Create a register sequence
– Execute a register sequence in conjunction with virtual sequences
87 Cadence Confidential
Lab 3: Register Sequences
88 Cadence Confidential
Lab 3A: Observe Register Sequencer Behavior
89 Cadence Confidential
Lab 3B: Write a New register Sequence
90 Cadence Confidential
End of Lab 3!
Built-in Sequences
91 Cadence Confidential
UVM Built-in Sequences for registers
Built-in-sequence Description Skip attribute
uvm_reg_hw_reset_seq Reads all of the register in a block and check NO_HW_RESET_T
EST
their POR value.
uvm_reg_single_bit_bash_seq Sequentially walks ‘0’ and ‘1’, checking if NO_REG_BIT_BAS
H_TEST
uvm_reg_bit_bash_seq appropriately set or cleared.
92 Cadence Confidential
Built-in-sequences – Cadence Extension
Cadence has created new built-in-sequence library which allows more
automation and does additional filtering to allow selection or removal of
registers. Sequences can be configured to access front-door or backdoor
(all combinations).
`ncroot`/tools/uvm-1.1/uvm_lib/uvm_sv/src/cdns_additions/reg
Sequence parameters
gets printed here print_configs filter_registers using addresses
Register rd/wr
happens here main using addr range
93 Cadence Confidential
Cadence’s Built-in Sequences
Built-in-sequence Description Skip attribute
Reads all of the register in a block. It is assumed that
uvm_reg_built_in_read_all_regs_seq explicit monitor does register value checking NO_RD_REG_TESTS
94 Cadence Confidential
Agenda
95 Cadence Confidential
Registers’ Checking and Coverage
96 Cadence Confidential
Monitoring and Checking in the Stimuli
Implicit Predictor
• Traditionally a directed testing approach
– Update and compare as part of the sequence body
– Advantage: natural for directed and check is done in one scope
• Disadvantageous
– The check is valid only for this specific operation
• Not in other operations or other sequences
– What if I’m not driving the bus?
• Could be other VIP or even the DUT
• Multiple register value assumptions grow stale
– Does not support vertical reuse
• Bus may become internal in larger system
• Different system-level sequence might be produced
– The current library adjust the desired value upon randomization
• What happens in case of pipelines, incomplete transaction, storing
continuation for later submission (e.g. DMA tasks).
97 Cadence Confidential
The Recommended approach:
Explicit Predictor
1. A predictor object needs to be created and associated with bus monitor
2. Predictor’s transaction-adapter needs to be set according to bus protocol
3. Once the transaction reaches predictor, ‘map’ inside predictor picks up
register associated at that address and does prediction
Predictor
Map reg.predict(data)
addr no
Compare
data If yes
Adapter read
With
shadow
Bus UVC
Monitor Bus
Sequencer Driver
98 Cadence Confidential
Explicit monitoring - Integrating a Predictor
class uart_ctrl_tb extends uvm_env;
// Testbench components – interface and module UVCs, Virtual Sequencer, config, etc
uart_ctrl_virtual_sequencer virtual_sequencer; // multi-channel sequencer
apb_pkg::apb_env apb0; // APB UVC
uart_pkg::uart_env uart0; // UART UVC
uart_ctrl_env uart_ctrl0; // MODULE UVC Predictor Component
uart_ctrl_config cfg;
99 Cadence Confidential
Testbench Components connect_phase()
Method
// class uart_ctrl_tb extends uvm_env;
function void connect_phase(uvm_phase);
super.connect_phase(phase);
// Hook up virtual sequencer,TLM ports, etc Connect address map
// . . . and adapter to predictor
// UVM_REG Connections
apb_predictor.map=reg_model.default_map;
apb_predictor.adapter=reg2apb;
apb0.bus_monitor.item_collected_port.connect(apb_predictor.bus_in);
endfunction : connect_phase
status
interrupt
UART DUT // within the monitor
Tx FIFO Transmitter
virtual task update_reg_model();
APB Mode forever begin
Interface Switch @interrupt;
Rx FIFO Receiver
set_reg_val_by_name(“csr.interrupt”, 1);
end
Control/Status Control/Interrupt endtask: update_reg_model
Registers Logic
covergroup wr_cg;
option.per_instance=1;
div_val : coverpoint ctrl.value[1:0]; Enabled fields are added as coverage
endgroup points
covergroup rd_cg;
option.per_instance=1;
div_val : coverpoint ctrl.value[1:0];
endgroup Extend virtual methods
virtual function void sample(uvm_reg_data_t data, byte_en, bit is_read, uvm_reg_map map);
super.sample(data, byte_en, is_read, map);
if(!is_read) wr_cg.sample();
if(is_read) rd_cg.sample();
endfunction
endclass : control_reg_c
Cadence Confidential
103
Adding/Modifying Coverage Groups
• For this lab, you will be hooking up the predictor components in the
uart_ctrl design.
• Objectives:
– Hook up the required components in the testbench
• NOTES:
• Search for LAB4 comments in your lab database files.
• Technology
– According to users, IES Simulator demonstrated significantly more
scalability than other simulators
– Cadence IPXACT Generator - iregGen
• Supports both the UVM_RGM and the UVM_REG packages (via a
switch)
• IPXACT front-end is proven in many projects
• Supports capabilities that are not yet in the standard library
• Results are tuned for performance and scalability
– Register viewer plug-in - iregViewer
– Cadence extensions – built-in-sequences and extended predictor
• Knowledge and expertise
– Cadence field team and services are familiar with the UVM_REG
new methodology and use model
112 Cadence Confidential