If you have a Simulink® Coder™ license, you can generate a Universal Verification Methodology (UVM) test bench 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 test bench to test an HDL DUT by replacing the generated behavioral DUT with your detailed HDL design.
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 Subsystem from Selection (Simulink).
Simulink Model Structure
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 Test Bench from Simulink.
Use the uvmbuild
function
to generate this structure of UVM components.
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.
Scoreboard – The UVM scoreboard is generated from your Simulink scoreboard subsystem.
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, illustrated in red in the figure, is included to monitor that signal.
Sequencer – This module controls the flow of sequence transactions to the DUT.
Driver – This module transforms each transaction to the desired protocol and drives the transaction to the DUT.
Monitor – This passive entity samples DUT signals.
For more information about the UVM components and structure, see UVM reference guide.
When generating UVM components, HDL Verifier generates SystemVerilog DPI components from your DUT, sequence, and scoreboard subsystems. The artifacts of DPI generation are placed in three directories, one for each subsystem: DUT, sequence, and scoreboard. For each one of the three subsystems, a folder is created with these contents.
– This folder contains the
generated SVDPI components for each one of the three subsystems (DUT, sequence or
scoreboard). The folder name is
subsystem
_build
, where subsystem is replaced
by DUT, sequence or scoreboard. Each folder includes:subsystem
_build
– SystemVerilog
package file with function declarations for the componentsubsystem
_dpi_pkg.sv
– The generated
SystemVerilog componentsubsystem
_dpi.sv
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
After generating three folders for the specified subsystems, a fourth folder is created
for additional UVM component files and execution scripts. The folder is named
,
where top-model-name
_uvmbuild/uvm_testbenchtop-model-name
is the name of your top Simulink model. This folder includes several subfolders.
DPI_dut
– This folder contains a copy of the SystemVerilog
package, module files, and a .dll file from the
folder.dut
_build
scoreboard
– This folder contains a copy of the SystemVerilog
package and a .dll file from the
folder. This folder
also includes the scoreboard class.scoreboard
_build
sequence
– This folder contains a copy of the SystemVerilog
package and a .dll file from the
folder. This folder also
includes the sequence class, type definitions, and a boilerplate sequencer class.sequence
_build
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_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_
– This file
contains a UVM object that defines the input transaction type for the
scoreboard.DUT
_trans.sv
mw_
– 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.DUT
_if.sv
mw_
– This file
includes a pass-through UVM driver.DUT
_driver.sv
mw_
– This
file includes a pass-through UVM monitor. The monitor samples signals from the
driver to the scoreboard.DUT
_monitor_input.sv
mw_
– This file
includes a pass-through UVM monitor. The monitor samples signals from the DUT to the
scoreboard.DUT
_monitor.sv
mw_
– This file includes a
UVM agent that instantiates sequence, driver, and monitor.DUT
_agent.sv
mw_
– This file
includes a UVM environment, that instantiates an agent and a scoreboard.DUT
_environment.sv
mw_
– This file includes a
UVM test, that instantiates an environment and sequence. The test module starts the
transactions by calling DUT
_test.svseq.start
.
Supported Simulink data types are converted to SystemVerilog data types, as shown in this table.
Simulink Data Type | SystemVerilog Data Type |
---|---|
uint8 | byte unsigned |
uint16 | shortint unsigned |
uint32 | int unsigned |
uint64 | longint unsigned |
int8 | byte |
int16 | shortint |
int32 | int |
int64 | longint |
single | shortreal |
double | real |
boolean | byte unsigned |
complex | You can choose between a SystemVerilog |
vectors, matrices | arrays For example, a 4-by-2 matrix in Simulink is converted to a one-dimensional array of eight elements in SystemVerilog. The coder flattens matrices in column-major order. |
nonvirtual bus | You can choose between a SystemVerilog |
enumerated data types | enum |
fixed-point | You can choose a bit vector, logic vector, or a compatible C type. On the Configuration Parameters dialog box, select Code Generation > SystemVerilog DPI. In the SystemVerilog Ports section, set Fixed-point data type. |
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.
UVM component generation does not support multirate subsystems.
Simulink components that are not specified as a DUT, sequence, or scoreboard subsystems are ignored.
Feedback loops are allowed inside each one of the subsystems, but not between them.