Main Content

UVM Component Generation Overview

UVM Component Generation Overview

If you have a Simulink® Coder™ license, you can generate a Universal Verification Methodology (UVM) testbench and additional components from a Simulink model. Generating UVM components enables a direct transition from your Simulink environment to a UVM framework.

HDL Verifier™ exports Simulink subsystems as generated C code inside UVM components with a direct programming interface (DPI). You can integrate these generated components into your existing UVM environment. You can also use the generated UVM testbench to test an HDL DUT by replacing the generated behavioral DUT with your detailed HDL design.

Note

This topic is about generating a full UVM testbench. If you are interested in generating only a piece of the UVM testbench, you can generate individual components using the Simulink toolstrip or the slbuild function for a single subsystem. For more information about generating individual UVM components, see Generate Individual UVM Component from Simulink.

This feature requires the ASIC Testbench for HDL Verifier add-on.

Prepare Simulink Model for UVM Component Generation

Your Simulink model must include these subsystems.

  • A DUT subsystem. This subsystem generates a SystemVerilog DPI (SVDPI) behavioral model of your DUT. For more information about SystemVerilog DPI Generation, see DPI Component Generation with Simulink.

  • A sequence subsystem. This subsystem creates stimulus and drives it to the DUT.

  • A scoreboard subsystem. This subsystem collects and checks the output of the DUT.

  • The sequence can also drive signals directly to the scoreboard, as illustrated in red in the Simulink Model Structure figure.

For details on how to create a subsystem, see Create Subsystems (Simulink).

Required Simulink Model Structure

Image shows a block diagram with a sequence, a DUT, and a scoreboard subsystem. An arrow connects from the sequence to the DUT, and another arrow connects from the DUT to the scoreboard.

In addition to the previous structure, you can optionally include these blocks or subsystems.

  • A driver subsystem

  • A monitor subsystem

  • A predictor subsystem

  • A Sequence Feedback block (or several)

Note

All the subsystems in your Simulink model must have names that start with a letter and use a combination of alphanumeric characters and underscores.

When adding a monitor, driver, or predictor subsystem, this feature supports these configurations.

  • All signals coming out of the sequence must be connected to the driver, predictor, or the scoreboard. Other output signals are ignored for UVM generation.

  • If your model includes a driver subsystem, then all signals coming out of the driver must be connected to the DUT.

  • If your model includes a driver subsystem, then all input signals to the driver must originate in the sequence.

  • If your model includes a monitor subsystem, then all signals coming out of the DUT must be connected to the monitor.

  • If your model includes a monitor subsystem, then all signals coming out of the monitor must be connected to the scoreboard.

  • If your model includes a predictor subsystem, then all input signals to the predictor must originate in the sequence. Additional inputs are ignored for UVM generation.

  • If your model includes a predictor subsystem, then all output signals from the predictor must connect to the scoreboard. Additional outputs are ignored for UVM generation.

  • If your model includes a Sequence Feedback block, then its input must be driven from the scoreboard subsystem, and its output must connect to the sequence subsystem.

This image shows a Simulink model that includes a driver, a monitor, and a predictor subsystem, as well as a Sequence Feedback block.

Expanded Simulink Model Structure

Image shows a block diagram with a sequence, a DUT, and a scoreboard subsystem. There is a driver subsystem between the sequence and the DUT, a monitor subsystem between the DUT and the scoreboard, and a predictor subsystem between the sequence and the scoreboard. The model also includes a Sequence Feedback block carrying data back from the scoreboard to the sequence subsystems.

Select System Target

Because UVM generation utilizes the technology for generating SystemVerilog DPI, you must first select a supporting system target file. Open the configuration parameters dialog box, and select Code Generation from the left pane. For System target file, click Browse, and then select systemverilog_dpi_grt.tlc from the list.

Alternatively, if you have the Embedded Coder® product, you can select target systemverilog_dpi_ert.tlc. This target enables you to access additional code generation options when you select Code Generation from the left pane of the Configuration Parameters dialog box.

For an example of UVM generation, see Generate Parameterized UVM Testbench from Simulink.

Generated UVM Structure

Use the uvmbuild function to generate this structure of UVM components.

Image shows a UVM block diagram with a DUT and a Test module in the Top module. The Test includes an Environment module and a sequence. The Environment includes a module for the scoreboard, the predictor, and an Agent module. The Agent Includes a sequencer that communicates with the Sequence in the Test module, get an input from the Scoreboard, and communicates with a driver module. The driver drives a monitor and a Monitor-Input block. The monitor connects to the Scoreboard, and the Monitor input connects to the Scoreboard directly, or via the Predictor module in the Environment.

  • Top – This module instantiates a generated behavioral DUT and the test environment. The top module has clock and reset signals that propagate into the design.

  • DUT – a behavioral design-under-test module is generated from your Simulink DUT subsystem.

  • Test – This module includes the UVM environment and sequence class.

  • Sequence – This UVM object defines a set of transactions. The sequence object is generated from your Simulink sequence subsystem.

  • Environment – This module includes the agent and generated scoreboard, and optionally a predictor.

  • Scoreboard – The UVM scoreboard is generated from your Simulink scoreboard subsystem. The scoreboard compares expected results with output from the DUT.

  • Agent – The UVM agent includes a sequencer, driver, and monitor. If a direct path exists from the Simulink sequence subsystem to the Simulink scoreboard subsystem, an additional monitor is included to monitor that signal.

  • Sequencer – This module controls the flow of sequence transactions to the DUT.

  • Driver – This module is generated from your Simulink driver subsystem and transforms each transaction from the Sequence to signals that the behavioral DUT understands. If your Simulink module does not include a driver subsystem, the driver is a pass-through UVM driver.

  • Monitor – This module is generated from your Simulink monitor subsystem and it samples the signals from the behavioral DUT and generates transactions that are sent to the UVM scoreboard. If your Simulink module does not include a monitor subsystem, the monitor is a pass-through UVM monitor.

  • Monitor Input – This module is generated if you have a predictor or a direct connection from the sequence to the scoreboard subsystem. The monitor input samples the signals from the sequence and generates transactions that are sent to the UVM predictor or the scoreboard.

  • Predictor – This module is generated from your Simulink predictor subsystem. The predictor represents a golden model of the DUT. It receives input from the sequence, calculates the results, and drives the results to the scoreboard to compare against the DUT results.

For more information about the UVM components and structure, see UVM reference guide.

Generated Files and Folder Structure

When generating UVM components, HDL Verifier generates SystemVerilog DPI (SV-DPI) components from your DUT, sequence, and scoreboard subsystems, as well as optional SV-DPI components for driver, monitor or predictor subsystems if your model includes them. The artifacts of DPI generation are placed in a directory named uvm_build in your working directory, that includes these two directories:

  • top_model_dpi_components – This directory includes all generated DPI components.

  • top_model_uvm_testbench – This directory includes the UVM testbench, the generated DUT, and shared libraries.

Where top_model is the name of your top-level Simulink model. You can change the default directory by setting the buildDirectory property in the uvmcodegen.uvmconfig configuration object.

The top_model_dpi_components directory contains directories for each one of the subsystems in the top model (DUT, sequence, scoreboard, driver, monitor, or predictor) named subsystem_build. Each directory includes:

  • subsystem_dpi_pkg.sv – SystemVerilog package file with function declarations for the component

  • subsystem_dpi.sv – The generated SystemVerilog component

  • DPI component and header files with extensions .c and .h

  • Metadata and information files with extensions .mat, .txt, .dmr, .tmw, and .def

  • A makefile for compiling the components into .o and .so files

The top_model_uvm_testbench directory includes several subfolders for the various generated UVM components:

  • DPI_dut – This folder contains a copy of the SystemVerilog package, module files, and a .dll file from the dut_build folder.

  • driver (optional) – This folder is generated if you specified a driver subsystem to the uvmbuild function. This folder contains a UVM driver, a copy of the SystemVerilog package, and a shared library file (dll-file or so-file) from the driver_build folder.

  • monitor (optional) – This folder is generated if you specified a monitor subsystem to the uvmbuild function. This folder contains a UVM monitor, a copy of the SystemVerilog package, and a shared library file (dll-file or so-file) from the monitor_build folder.

  • predictor (optional) – This folder is generated if you specified a predictor subsystem to the uvmbuild function. This folder contains a UVM predictor, a copy of the SystemVerilog package, a predictor transaction, and a shared library file (dll-file or so-file) from the predictor_build folder.

  • scoreboard – This folder contains a copy of the SystemVerilog package and a .dll file from the scoreboard_build folder. This folder also includes the UVM scoreboard class, a scoreboard configuration object, and a scoreboard transaction that defines the input transaction type for the scoreboard.

  • sequence – This folder contains a copy of the SystemVerilog package and a .dll file from the sequence_build folder. This folder also includes the UVM sequencer, the sequence class, and a sequence transaction that defines the transaction type from the sequencer to the driver.

  • top – This folder contains the SystemVerilog package and module files for the top Simulink model. This folder also contains scripts for HDL-simulator execution.

  • uvm_artifacts – This folder contains these SystemVerilog files.

    • mw_DUT_agent.sv – This file includes a UVM agent that instantiates sequence, driver, and monitor.

    • mw_DUT_environment.sv – This file includes a UVM environment, that instantiates an agent and a scoreboard.

    • mw_DUT_if.sv – This file defines the DUT SystemVerilog interface type. It contains DUT inputs and outputs, as well as ports for clock, reset, and clock-enable signals.

    • mw_DUT_monitor_input.sv – This file includes a pass-through UVM monitor. The monitor samples signals from the driver to the scoreboard or predictor.

    • mw_DUT_test.sv – This file includes a UVM test, that instantiates an environment and sequence. The test module starts the transactions by calling seq.start.

    • mw_dpi_types_pkg.sv – This file contains definitions of generated SystemVerilog types, such as enum and struct, exposed by UVM component interfaces. Only UVM components which use these types import this package.

    • mw_DUT_driver.sv – This file includes a pass-through UVM driver by default. When specifying a driver subsystem to the uvmbuild function, this module includes a scheduler and the API calls to the DPI component Driver_dpi_pkg.sv.

    • mw_DUT_monitor.sv – This file includes a pass-through UVM monitor. The monitor samples signals from the DUT to the scoreboard. When specifying a monitor subsystem to the uvmbuild function, this module includes a scheduler and the API calls to the DPI-component Monitor_dpi_pkg.sv.

This image shows the generated directory structure for a top level model named drv_and_mon_uvmtb.

Generated directory structure for a top level model named drv_and_mon_uvmtb. A directory named "drv_and_mon_uvmtb_dpi_components" is expanded to show contents, and a directory named "drv_and_mon_uvmtb_uvm_testbench" is expanded to show contents.

Supported Simulink Data Types

Supported Simulink data types are converted to SystemVerilog data types, as shown in this table.

Generated SystemVerilog Types

MATLAB®SystemVerilog
Compatible C TypeLogic VectorBit Vector
uint8byte unsignedlogic [7:0] bit [7:0]
uint16shortint unsignedlogic [15:0] bit [15:0]
uint32int unsignedlogic [31:0]bit [31:0]
uint64longint unsignedlogic [63:0]bit [63:0]
int8bytelogic signed [7:0]bit signed [7:0]
int16shortintlogic signed [15:0]bit signed [15:0]
int32intlogic signed [31:0]bit signed [31:0]
int64longintlogic signed [63:0]bit signed [63:0]
booleanbyte unsignedlogic [0:0]bit [0:0]
fixed-point

The port is sign extended to a built-in C type, such as int, int unsigned, byte, byte unsigned, etc.

logic [n-1:0]

logic signed [n-1:0]

The logic vector length (n) is equal to the wordlength. The sign is inherited from the fixed point type.

bit [n-1:0]

bit signed [n-1:0]

The bit vector length (n) is equal to the wordlength. The sign is inherited from the fixed point type.

singleshortreal
doublereal
complex

You can choose between a SystemVerilog struct data type or flattened ports for real and imaginary parts in the SystemVerilog interface. To choose between these options, in the left pane of the Configuration Parameters dialog box, select Code Generation > SystemVerilog DPI, and then set the Composite data type parameter to structure or flattened.

vectors, matrices

You can choose between SystemVerilog arrays or scalar ports. To choose between these options, in the left pane of the Configuration Parameters dialog box, select Code Generation > SystemVerilog DPI, and then select the Scalarize matrix and vector ports parameter.

For example, a two-element vector of type uint32 in Simulink generates this SystemVerilog vector port:

input logic [31:0] vecInput [0:1]

When you select Scalarize matrix and vector ports, the generated SystemVerilog includes these two ports, each of type logic [31:0]:

input logic [31:0] vecInput_0,
input logic [31:0] vecInput_1

When generating vector and array ports, the coder flattens matrices in column-major order.

nonvirtual bus

You can choose between a SystemVerilog struct type or flattened ports for separate component signals in the SystemVerilog interface. To choose between these options, in the left pane of the Configuration Parameters dialog box, select Code Generation > SystemVerilog DPI section, and set Composite data type to structure or flattened.

enumerated data typesenum

Limitations

  • By default, HDL Verifier converts matrices and vectors to one-dimensional arrays in SystemVerilog. For example, a 4-by-2 matrix in Simulink is converted to a one-dimensional array of eight elements in SystemVerilog. To generate multiple scalar ports in the SystemVerilog interface, select Scalarize matrix and vector ports in the configuration parameters.

  • The uvmbuild function ignores Simulink subsystems that are not specified as a DUT, sequence, scoreboard, driver, monitor, or predictor subsystems. When you connect one of the UVM subsystems to a block or subsystem not mentioned above, the generated UVM component will have an unconnected port.

  • You can use feedback loops inside any of the subsystems. You can also create feedback from the scoreboard to the sequencer by using a Sequence Feedback block. Other feedback loops between subsystems are not allowed.

  • The sequence, scoreboard, and predictor subsystems must operate at a single rate, and the fundamental sample times of their subsystems must be equal. For more information about sample times, see Sample Times in Systems and Subsystems (Simulink).

  • The fundamental sample times of the driver, DUT, and monitor subsystems must be equal. Their ports can be multirate, but the greatest common divisor (GCD) or fundamental sample time must be the same.

  • The sample time of the sequence, scoreboard, and predictor subsystems must be greater than or equal to the fundamental sample time of the driver, DUT, and monitor.

  • You cannot set up third-party tools in MATLAB Online™, so you cannot use these features in MATLAB Online:

    • Testbench execution for DPI and UVM generation

    • Use of EDA toolchains for compiling DPI shared libraries

See Also

Related Topics

External Websites