Main Content

Guidelines for Model Setup and Checking Model Compatibility

Use these guidelines to setup your Simulink® model for HDL code generation compatibility and verify that your design is ready to generate code.

Each guideline has a severity level that indicates the level of compliance requirements. To learn more, see HDL Modeling Guidelines Severity Levels.

Customize hdlsetup Function Based on Target Application

Guideline ID

1.1.5

Severity

Strongly Recommended

Description

Before generating code, you must configure the model. To configure the model, you can use the hdlsetup function. The hdlsetup function uses the set_param function to set up models for HDL code generation. The settings include using a fixed-step discrete solver, specifying ASIC/FPGA as the hardware type, and so on. To see the settings that hdlsetup function saves on the model, run this command:

edit hdlsetup.m

Some of the settings that the hdlsetup function saves on the model may not be suitable for your target application. In such cases, you can customize the hdlsetup.m file such that it runs only those commands required for your target application. For example, you can disable some of the solver settings in the Configuration Parameters and instead enable certain model parameters such as displaying port data types, and so on.

% following config parameters are disabled.
%     'Solver',                'fixedstepdiscrete', ...
%     'SaveTime',              'off', ...
%     'SaveOutput',            'off', ...
%     'DataTypeOverride',      'ForceOff',...

% Following model parameters are enabled.
set_param(model, 'ShowLineDimensions', 'on')
set_param(model, 'ShowPortDataTypes', 'on')
set_param(model, 'SampleTimeColors', 'on')
set_param(model, 'WideLines', 'on')

To see a custom hdlsetup function that consists of these commands and specifies some of the HDL-specific settings required for HDL code generation, open the file myhdlsetup.m.

edit myhdlsetup.m

You see that this custom myhdlsetup file also saves some HDL-specific parameters by using hdlset_param on the model.

Check Subsystem for HDL Compatibility

Guideline ID

1.1.6

Severity

Strongly Recommended

Description

The compatibility checker generates a report specified system for compatibility problems, such as use of unsupported blocks, illegal data type usage, and so on.

To run the check for HDL compatibility:

  • From the UI, right-click the DUT Subsystem and select HDL Code > Check Subsystem for HDL compatibility.

  • At the command line, use the checkhdl function. Select the DUT Subsystem and then enter this command:

    checkhdl(gcb)

See also Check Your Model for HDL Compatibility.

When you run this command, the HDL compatibility checker generates an HDL Code Generation Check Report. The report is stored in the target hdlsrc folder. If the report does not display any errors, it indicates that your model is compatible for HDL code generation.

### Starting HDL Check.
### HDL Check Complete with 0 errors, warnings and messages.

Note

checkhdl does not detect all compatibility issues. Even if HDL check completes without any errors or warnings, HDL Coder™ can generate errors during code generation.

Run Model Checks for HDL Coder

Guideline ID

1.1.7

Severity

Strongly Recommended

Description

To see whether your DUT Subsystem is compatible for HDL code generation, run the checks in the HDL Code Advisor or the Simulink Model Advisor checks for HDL Coder.

To open the HDL Code Advisor:

  • From the UI, in the Apps tab, select HDL Coder. The HDL Code tab appears. Select the DUT Subsystem and then click HDL Code Advisor.

  • To run the model checks for the Subsystem you want to analyze, right-click that Subsystem, and in the context menu, select HDL Code > HDL Code Advisor.

  • At the command line, use the hdlmodelchecker function:

    hdlmodelchecker(gcb)

When you run this command, the HDL Code Advisor appears.

You may not have to run all checks in the HDL Code Advisor. For example, if your model does not have single or double data types, you do not have to run the checks in the Native Floating Point checks folder. To learn more about each check and whether to run the check for your model, right-click that check and select What's This?.

See Also

Functions

Modeling Guidelines

Related Topics