module advanced uvm session10 register based testing tfitzpatrick

13
[email protected] www.verificationacademy.com [email protected] www.verificationacademy.com Advanced UVM Register-Based Testing Tom Fitzpatrick Verification Evangelist

Upload: christopher-patterson

Post on 14-Dec-2015

28 views

Category:

Documents


6 download

DESCRIPTION

UVM

TRANSCRIPT

Page 1: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

[email protected] www.verificationacademy.com

[email protected] www.verificationacademy.com

Advanced UVM Register-Based Testing

Tom Fitzpatrick Verification Evangelist

Page 2: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Register-Based Analysis Components • The register model mirror is used by analysis

components • Scoreboards to check current DUT configuration

- Where this may affect the checking algorithm

• Functional coverage monitors - What is the configuration at a triggered sample?

• Analysis components use the register model passively: • get() • Backdoor read() or peek() accesses

• Alternatively they look up the register model values using • uvm_reg_field.value • uvm_reg.value – aggregate of field values

Page 3: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Register Scoreboard Guidelines • Scoreboard needs a handle to the register

model • Scoreboard accesses register values

• via handle to register (spi_rm.ctrl.ie.value) • or calling register.get() (spi_rm.ctrl.ie.get())

• Scoreboard checks DUT register contents • Compare observed data vs.

register contents • Compare DUT contents vs.

expected - via peek access to DUT

• Use predict() to set mirrored value

- Use mirror() to read & check - Via scoreboard or sequence

Page 4: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Scoreboard Checking • Actual vs. register contents

• DUT contents vs. expected

rdata = spi_rm.rxtx_reg.get(); if(rdata != mosi_data) error = 1;

spi_rm.rxtx_reg.peek(status, pdata); if(pdata != miso_data) error = 1; assert(spi_rm.rxtx_reg.predict(miso_data));

Page 5: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Functional Coverage Monitors • The register model has built-in functional

coverage

• A custom functional coverage monitor lets

you sample based on significant events • Interrupts • Writes to certain ‘trigger’ registers

• Register Assistant generates an ‘intelligent’ register access covergroup • included in the register package

UVM_NO_COVERAGE (0) - None UVM_CVR_REG_BITS (1) - Individual register bits UVM_CVR_ADDR_MAP (2) - Individual register and memory addresses UVM_CVR_FIELD_VALS (4) - Field values UVM_CVR_ALL (-1) - All coverage models

Currently limited to UVM_CVR_ADDR_MAP

Page 6: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Functional Coverage Monitor Example class spi_reg_functional_coverage extends uvm_subscriber #(apb_seq_item); `uvm_component_utils(spi_reg_functional_coverage) spi_reg_block spi_rm; covergroup combination_cov; option.per_instance = 1; ASS: coverpoint spi_rm.ctrl_reg.ass.value[0]; IE: coverpoint spi_rm.ctrl_reg.ie.value[0]; LSB: coverpoint spi_rm.ctrl_reg.lsb.value[0]; TX_NEG: coverpoint spi_rm.ctrl_reg.tx_neg.value[0]; RX_NEG: coverpoint spi_rm.ctrl_reg.rx_neg.value[0]; // Suspect character lengths - there may be more .... CHAR_LEN: coverpoint spi_rm.ctrl_reg.char_len.value[6:0] { bins LENGTH[] = {0, 1, [31:33], [63:65], [95:97], 126, 127}; } CLK_DIV: coverpoint spi_rm.divider_reg.ratio.value[15:0] { bins RATIO[] = {16'h0, 16'h1, 16'h2, 16'h4, 16'h8, 16'h10, 16'h20, 16'h40, 16'h80}; } COMB_CROSS: cross ASS, IE, LSB, TX_NEG, RX_NEG, CHAR_LEN, CLK_DIV; endgroup: combination_cov

Covergroup checks that all interesting SPI Master configurations have been checked.

Page 7: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Functional Coverage Monitor Example class spi_reg_functional_coverage extends uvm_subscriber #(apb_seq_item); `uvm_component_utils(spi_reg_functional_coverage) spi_reg_block spi_rm; function void write(T t); // Sample the combination covergroup when go_bsy is true if(address == 5'h10) begin if(wnr) begin if(t.data[8] == 1) begin combination_cov.sample(); // TX started end end end endfunction: write

Covergroup sampled when a transfer starts, could be on an interrupt to indicate that a transfer has completed

Page 8: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Coding Guideline • Always wrap a covergroup in a uvm_object

wrapper class covergroup_wrapper extends uvm_object; `uvm_object_utils(covergroup_wrapper) covergroup cg (string name) with function sample(my_reg reg, bit is_read); option.name = name; PARITY: coverpoint reg.parity { bins parity_on = {1'b1}; bins parity_off = {1'b0};} ALL_OPTIONS: cross CHAR_LEN, PARITY; endgroup: cg function new(string name = "covergroup_wrapper"); super.new(name); cg = new(); endfunction function void sample(); cg.sample(); endfunction: sample endclass: covergroup_wrapper

Covergroup can be (conditionally) constructed at any time

Wrapper class can be overridden from the factory

Page 9: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Monitor with Wrapped Covergroup class spi_reg_functional_coverage extends uvm_subscriber #(apb_seq_item); `uvm_component_utils(spi_reg_functional_coverage) spi_reg_block spi_rm; combination_cov_wrapper cg; function new(string name = "covergroup_wrapper"); super.new(name); cg = new(); endfunction function void write(T t); // Sample the combination covergroup when go_bsy is true if(address == 5'h10) begin if(wnr) begin if(t.data[8] == 1) begin cg.sample(); end end end

Covergroup checks that all interesting SPI Master configurations have been checked.

Page 10: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Modelling Memory • The register model provides access to

memory regions • mem.read()/write() to location x in memory y • The memory location address offset is calculated:

• The model does not shadow memory regions

• DUT memories are usually modelled separately • Maintaining a memory shadow is expensive • No set()/get() functions available

• Memory accesses can support bursts • mem.read_burst() • mem.write_burst()

mem.read(status, offset_addr, data, ….) mem.write(status, offset_addr, data, ….)

Page 11: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Check against stored data

Read back from stored addresses

Write to randomized addresses

Constrain address to be within the memory range

Example Memory Based Sequence class mem_1_test_seq extends mem_ss_base_seq; `uvm_object_utils(mem_1_test_seq) uvm_reg_addr_t addr_array[10]; uvm_reg_data_t data_array[10]; task body; super.body(); for(int i = 0; i < 10; i++) begin assert(this.randomize() with {addr <= mem_ss_rm.mem_1.get_size();}); mem_ss_rm.mem_1.write(status, addr, data, .parent(this)); addr_array[i] = addr; data_array[i] = data; end for(int i = 0; i < 10; i++) begin mem_ss_rm.mem_1.read(status, addr_array[i], data, .parent(this)); if(data_array[i][31:0] != data[31:0]) begin `uvm_error("mem_1_test", $sformatf("Memory access error: expected %0h, actual %0h", data_array[i][31:0], data[31:0])) end end endtask: body endclass: mem_1_test_seq

Buffers for the addresses and the write data

Write loop

Read loop

Randomize data

Page 12: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Memory Built-In Sequences Sequence Name Description uvm_mem_single_walk_seq Walking ones bit test for a single memory uvm_mem_walk_seq Walking ones bit test for all memories within a

block uvm_mem_single_access_seq Checks front and back door accesses to a single

memory uvm_mem_access_seq Checks front and back door accesses to all

memories in a block uvm_mem_shared_access_seq Where a memory is present in several maps,

checks that all mapped access combinations work

Sequence Name Description uvm_reg_mem_shared_access_seq Runs reg_access_seq and

mem_access_seq on all the registers and memories available in that block

uvm_reg_mem_built_in_seq Runs all of the built in sequences on a block

Aggregated Sequences:

Page 13: Module Advanced Uvm Session10 Register Based Testing Tfitzpatrick

Register Summary • Register Block contains

• Register model - Fields

• Register analysis components have register block pointer • Access via get() or backdoor read/peek • Use model.reg.value directly

• Wrap covergroups to increase flexibility • Use built-in test sequences for sanity

checking • Registers and Memories

• Address Map • Sub-blocks