Coverage/Block Level Functional Coverage Example
Coverage/Block Level Functional Coverage Example
Cookbook
Online Methodology Documentation from the Mentor Graphics Verification Methodology Team Contact [email protected]
http://verificationacademy.com
Table of Contents
Articles
Coverage/Block Level Functional Coverage Example 1
Datestamp:
- This document is a snapshot of dynamic content from the Online Methodology Cookbook - Created from http://verificationacademy.com/uvm-ovm on Tue, 20 Nov 2012 07:57:35 UTC
UARTOverview
The function of an Universal Aysynchronous Receiver Transmitter (UART) is to transmit and receive characters of differing formats over a pair of serial lines asynchronously. With an asynchronous serial link, there is no shared sampling clock, instead the receive channel samples the incoming serial data stream with a clock that is 16x the data rate. When there is no data to transmit the data lines are held high, and transmission of a data character commences by taking the data line low for one bit period to transmit the start bit. The receiving end detects the start bit and then samples and unpacks the serial data stream that can consist of between 5 and 8 bits of data, parity and then a stop bit which is always a 1.
Register Map
The UART design in this example is based on the industry standard 16550a UART. It has 10 registers which control its operation and in a system these are used by software to control the device and to send and receive characters. The transmit and receive paths are buffered with 16 word deep FIFOs. The register map is summarised here:
Width 8 8 8 8 8 8 8 8 8 8 8
Description Receive data FIFOoutput Transmit data FIFO input Enables for UARTinterrupts Interrupt status Set receive data FIFOthresholds Sets the format of the UARTdata word Used to control the modem interface outputs Transmit and receive channel status Used to monitor the modem interface inputs LSB of the 16 bit divider MSBof the 16 bit divider
Interrupt Identification (IIR) 0x8 FIFOControl (FCR) Line Control (LCR) Modem Control (MCR) Line Status (LSR) Modem Status (MSR) Divisor 1 Divisor 2 0x8 0xC 0x10 0x14 0x18 0x1C 0x20
For the UVMtestbench, a UVMregister model will be written to abstract stimulus for configuring and controlling the operation of the UART. One benefit of using this register model is that we can reference it for the functional coverage model. For more details on the UART functionality and the detailed register map, please refer to the datasheet.
External Interfaces
The UARTblock has a number of discrete interfaces which need to be driven or monitored. The UART example testbench is implemented using UVM, therefore the driving and monitoring of these interfaces will be done by Universal Verification Components (UVCs) or agents. If the testbench was implemented using another methodology, then BFM or BFM-like models would be used. However, the principles of how you model and collect coverage are essentially the same. The UART has the following external interfaces which will need to be driven and monitored in the testbench. APB Host interface Requires an APB agent TX Serial line Requires a passive UART agent RX Serial line Requires an active UART agent Modem interface Requires a simple parallel I/O agent Interrupt line Requires a monitor
Testbench Architecture
The UVM testbench architecture used for this example is shown in the block diagram.
An outline functional test plan for the UART has been created as part of the process of mapping its features to test cases and functional coverage.
We need to see all possible permutations of these configuration settings in order to say that we have achieved functional coverage for the transmit channel. An example implementation of the SystemVerilog covergroup used to collect this functional coverage is implemented in the example UARTtestbench. Transmit channel coverage summary
Transmit Channel Coverage LCR[5:0] - defining all permutations of UART serial word format
What are the dependencies between the values? No dependencies Are there illegal conditions? When is the right time to sample? When is the data invalid? No, all permutations are valid When a character has been transmitted N/A
There are a number of receive channel interrupt conditions that are considered in the section on interrupts.
What are the dependencies between the values? For error free RX conditions DR and all word formats For injected error RX, cross product of LCR &LSRbits Are there illegal conditions? When is the right time to sample? When is the data invalid? Cannot have OEwith no DR valid When a RX character has been received and DR is valid N/A
Coverage/Block Level Functional Coverage Example Example implementations of these coverage models are present in the uart_modem_coverage_monitor in the example UARTtestbench. Modem interface coverage summary
Coverage Criterion Which values are important? Modem Interface Coverage MCR[4:0] - Controlling outputs and loopback mode MSR[7:0] - input status and changes to input values
What are the dependencies between the values? Each of the modem signals are orthogonal, but the loopback mode creates a dependency between the MCR bits and the MSRbits. For coverage all permutations are relevant. Are there illegal conditions? When is the right time to sample? No When a change occurs on the Modem interface, or there is a write to the MCR, determined by the modem scoreboard. Immediately after a change in the loopback mode, handled by the scoreboard
UARTInterrupts
Testing UARTinterrupts
The testbench contains a monitor for the UART interrupt line and some of the test cases have stimulus which enables the various interrupts and then handles the interrupt conditions as they occur. The scoreboarding within the testbench checks the validity of the interrupt conditions dependent on its source. Interrupts can be generated by the UARTfor the following conditions: Transmit FIFO empty Receive data FIFOthreshold reached (1, 4, 8, 14 characters) Receiver line status - Parity error, Framing error or Break condition Receiver timeout - At least one character in the FIFO, but no receive channel activity for at least 4 character times Modem status change
Coverage/Block Level Functional Coverage Example The receiver FIFOthreshold level interrupt needs to have been seen to occur for the four possible values of the receive FIFO threshold, crossed with all the possible word formats. This covergroup needs to be sampled when a receive FIFO threshold interrupt occurs. The receive line status interrupt has several potential sources, the functional coverage for this needs to be sampled when a line status interrupt occurs. The data that needs to be sampled is the Line Status for Parity errors, Framing errors, Overrun errors or break condition, together with the FIFOerror bit, these bits need to be crossed, but with some illegal conditions filtered - for instance a line status interrupt with no active line status bits repesents an error, or a break condition will invalidate the parity and framing errors. The transmitter empty interrupt should be checked for all possible word formats. The modem status interrupt can come from one of the four signal change detected bits of the MSR. These bits are crossed for all permutations, and also with the MCRloopback bit. The modem status interrupt source covergroup is sampled when a modem status interrupt occurs. Example implementations of covergroups used to capture functional coverage for the UART Interrupts can be found here. UARTinterrupt coverage summary
Interrupt handling Coverage Criterion Which values are important? UART interrupt coverage summary IER[3:0] - Enables for the four sources of interrupts IIR[[3:0] - Identifying the interrupt source
What are the dependencies between the values? Interrupts should only occur if they are enabled Need to see all valid permutations of interrupt enables and interrupt sources Are there illegal conditions? When is the right time to sample? Invalid conditions are interrupt sources reported when an interrupt type is not enabled For the interrupt enables, when an interrupt occurs. For interrupt ids, when an interrupt occurs, followed by a read from the IIRregister N/A
Receiver FIFOThreshold Interrupt Coverage Criterion Which values are important? UART interrupt coverage summary LCR[5:0] - Definining the different word formats FC[7:6] - Defining the different FIFOthreshold values
What are the dependencies between the values? Need a cross between the LCR and FCR bits to ensure that FIFOthreshold interrupts have occurred for all possible permutations. Are there illegal conditions? When is the right time to sample? When is the data invalid? None When an RXFIFOthreshold interrupt occurs N/A
Receiver Line Status Interrupt Coverage Criterion Which values are important? UART interrupt coverage summary LSR[4:1] - Defining the different types of RXline status
What are the dependencies between the values? None, each status bit has a distinct source Are there illegal conditions? When is the right time to sample? When is the data invalid? When the break condition occurs, PE and FE are not valid When a line status interrupt occurs, followed by a read from the LSR N/A
Transmitter Empty Interrupt Coverage Criterion Which values are important? UART interrupt coverage summary LCR[5:0] - Defining the UARTserial format
What are the dependencies between the values? Cross product defining all permutations of the word format Are there illegal conditions? When is the right time to sample? When is the data invalid? None When a TXempty interrupt occurs, followed by a read from the LSR N/A
Modem Status Interrupt Coverage Criterion Which values are important? UART interrupt coverage summary MSR[3:0] - The modem i/p signal change flags
What are the dependencies between the values? None, each signal is orthogonal Are there illegal conditions? When is the right time to sample? When is the data invalid? None When a modem status interrupt occurs, followed by a read from the MSR The MSRflags are reset on read, so a second read will return invalid status
10
What are the dependencies between the values? DIV1 & DIVare concatonated, otherwise no dependencies Are there illegal conditions? When is the right time to sample? When is the data invalid? The divider cannot have a value of 0 On the rising edge of the BAUD_O signal If the divider registers are being programmed, or have just been programmed in which case the divide ratio will not match the register content (this is not an error)
Register Interface
Testing the register interface
The register interface is implicitly tested by the functional stimulus for each of the various test cases. There is a specific test case to check that the register reset values are correct.
11
Receive Channel Coverage Address bits [7:0] and read/write bit Only interested in valid register addresses
What are the dependencies between the values? Need to cross the valid addresses with the read/write bit to get the register access space Are there illegal conditions? When is the right time to sample? When is the data invalid? The MSR and LSR registers are read only, so writes to these registers are invalid When an APBbus transaction completes N/A
Verification Academy
Cookbook
www.mentor.com
2012-13 Mentor Graphics Corporation, all rights reserved. This document contains information that is proprietary to Mentor Graphics Corporation and may be duplicated in whole or in part by the original recipient for internal business purposes only, provided that this entire notice appears in all copies. In accepting this document, the recipient agrees to make every reasonable effort to prevent unauthorized use of this information. All trademarks mentioned are this document are trademarks of their respective owners.
Corporate Headquarters Mentor Graphics Corporation 8005 SW Boeckman Road Wilsonville, OR 97070-7777 Phone: 503.685.7000 Fax: 503.685.1204 Sales and Product Information Phone: 800.547.3000 Silicon Valley Mentor Graphics Corporation 46871 Bayside Parkway Fremont, California 94538 USA Phone: 510.354.7400 Fax: 510.354.1501 North American Support Center Phone: 800.547.4303 Europe Mentor Graphics Deutschland GmbH Arnulfstrasse 201 80634 Munich Germany Phone: +49.89.57096.0 Fax: +49.89.57096.400 Pacific Rim Mentor Graphics (Taiwan) Room 1001, 10F International Trade Building No. 333, Section 1, Keelung Road Taipei, Taiwan, ROC Phone: 886.2.87252000 Fax: 886.2.27576027 Japan Mentor Graphics Japan Co., Ltd. Gotenyama Garden 7-35, Kita-Shinagawa 4-chome Shinagawa-Ku, Tokyo 140-0001 Japan Phone: +81.3.5488.3030 Fax: +81.3.5488.3021