DUT Subsystem Guidelines - MATLAB & Simulink (original) (raw)

Main Content

You can follow these guidelines to learn some best practices on how you can model the DUT for HDL code and testbench generation. Each guideline has a severity level that indicates the level of compliance requirements. To learn more, see HDL Modeling Guidelines Severity Levels.

DUT Subsystem Considerations

Guideline ID

1.2.1

Severity

Strongly Recommended

Description

The DUT is the Subsystem that contains the algorithm for which you want to generate code. Generally, you specify the top-level Subsystem as the DUT. See also Partition Model into DUT and Test Bench.

Consider using these recommended settings when you design the DUT Subsystem for HDL code generation.

Convert DUT Subsystem to Model Reference for Testbenches with Continuous Blocks

Guideline ID

1.2.2

Severity

Strongly Recommended

Description

In some cases, parts of the Simulink™ testbench can contain Simscape™ blocks or other blocks from the Simulink library that operate at a continuous sample time. To simulate these blocks, you must specify a continuous solver setting for your model. The solver settings that you specify applies to all blocks in your model. This means that the DUT Subsystem uses a continuous solver, which is not supported for HDL code generation. To generate HDL code, convert the DUT Subsystem to a model reference, and then use a fixed-step discrete solver for the referenced model. As the parent model and the referenced model use different solver settings, you must convert the sample time by inserting Zero-Order Hold and Rate Transition blocks at the DUT boundary.

For example, open the model hdlcoder_testbench_continuous.slx. The model uses ode45, which is a continuous solver setting. You see that the DUT is a Model block. Zero-Order Hold and Rate Transition blocks at the boundary convert the sample time.

open_system('hdlcoder_testbench_continuous') set_param('hdlcoder_testbench_continuous','SimulationCommand','Update') get_param('hdlcoder_testbench_continuous', 'Solver')

To see the referenced model hdlcoder_DUT_discrete, double-click the DUT block. You see that the DUT uses a discrete solver setting.

open_system('hdlcoder_testbench_continuous/DUT') get_param('hdlcoder_DUT_discrete', 'Solver')

ans =

'FixedStepDiscrete'

Guideline ID

1.2.3

Severity

Informative

Description

You can reuse a pre-verified RTL IP or insert your handwritten HDL code into the Simulink® modeling environment by using these methods:

See Also

Functions

Topics