Main Content

Set and View HDL Model and Block Parameters

You can view and set HDL-related block properties, such as implementation and implementation parameters, at the model level and at the individual block level.

Set HDL Block Properties

To set the HDL Block parameters from the UI, open the HDL Block Properties dialog box, and modify the block properties. To open the HDL Properties dialog box, either:

  • In the Apps tab, select HDL Coder. The HDL Code tab appears. Select the block for which you want to see the HDL parameters and then select HDL Property Inspector > HDL Block Properties.

  • Right-click the block and select HDL Code > HDL Block Properties.

A standalone HDL Block Properties window pops up that displays the HDL block properties of the selected block.

To set the HDL-related parameters at the command line, use hdlset_param. hdlset_param(path,Name, Value) sets HDL-related parameters in the block or model referenced by path. One or more Name,Value pair arguments specify the parameters to be set, and their values. You can specify several name and value pair arguments in any order as Name1,Value1,…,NameN,ValueN.

For example, to set the sharing factor to 2 and the architecture to Tree for a block in your model:

  1. Open the model and select the block.

  2. Enter the following at the command line:

    hdlset_param (gcb, 'SharingFactor', 2, 'Architecture', 'Tree')

To view the HDL parameters specified for a block, use hdlget_param. For example, to see the HDL architecture setting for a block, at the command line, enter:

hdlget_param(gcb, 'Architecture')

You can also assign the returned HDL block parameters to a cell array. In the following example, hdlget_param returns all HDL block parameters and values to the cell array p.

 p = hdlget_param(gcb, 'all')
p = 

    'Architecture'  'Linear'  'InputPipeline'  [0]  'OutputPipeline'  [0]

Set HDL Block Properties Using HDL Property Inspector

Since R2024b

You can also edit the HDL block properties of a block or a subsystem by using HDL Property Inspector pane. To open the HDL Property Inspector from the Simulink® Toolstrip:

  1. Open the HDL Coder app from the Apps menu.

  2. In the HDL Code tab, click HDL Property Inspector.

The HDL Property Inspector opens as a pane in the current Simulink Editor window. Select the block for which you want to see the HDL properties, HDL Properties Inspector displays the HDL properties of the respective block. The HDL Property Inspector enables you to use a single interface to edit HDL properties for any model element.

HDL Property Inspector pane opened in Simulink Editor window.

You can drag the HDL Property Inspector from the default location and dock it in another location in the editor. The down arrow to the right of the pane title provides options to undock, minimize, and open help for the pane. The HDL Property Inspector lets you quickly set properties as you work.

The values set for the HDL block properties by using command line function hdlset_param, HDL Block Properties, or HDL Property Inspector techniques take effect immediately and are reflected in both UI and CLI options.

You can also assign values to HDL block properties that take numeric value by using the variables declared in MATLAB® base workspace, mask workspace, or model workspace.

Set HDL Block Parameters for Multiple Blocks Programmatically

For models that contain a large number of blocks, using the HDL Block Properties dialog box to select block implementations or set implementation parameters for individual blocks may not be practical. It is more efficient to set HDL-related model or block parameters for multiple blocks programmatically. You can use the find_system function to locate the blocks of interest. Then, use a loop to call hdlset_param to set the desired parameters for each block.

The following example uses the sfir_fixed model to demonstrate how to locate a group of blocks in a subsystem and specify the same output pipeline depth for all the blocks.

open_system('sfir_fixed')

% Find all Product blocks in the model
prodblocks = find_system('sfir_fixed/symmetric_fir', ... 
                            'BlockType', 'Product')

% Set the output pipeline to 2 for the blocks
for ii=1:length(prodblocks)
    hdlset_param(prodblocks{ii}, 'OutputPipeline', 2)
end

prodblocks =

  4×1 cell array

    {'sfir_fixed/symmetric_fir/m1'}
    {'sfir_fixed/symmetric_fir/m2'}
    {'sfir_fixed/symmetric_fir/m3'}
    {'sfir_fixed/symmetric_fir/m4'}

To verify the settings, use hdlget_param to display the value of the OutputPipeline parameter for the blocks.

% Get the output pipeline to 2 for the blocks
for ii=1:length(prodblocks)
    hdlget_param(prodblocks{ii}, 'OutputPipeline')
end
ans =

     2


ans =

     2


ans =

     2


ans =

     2

View All HDL Block Parameters

hdldispblkparams displays the HDL block parameters available for a specified block.

The following example displays HDL block parameters and values for the currently selected block.

hdldispblkparams(gcb,'all')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HDL Block Parameters ('simplevectorsum/vsum/Sum of
Elements')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Implementation

	Architecture  : Linear

Implementation Parameters

	InputPipeline : 0
	OutputPipeline : 0

See also hdldispblkparams.

View Non-Default HDL Block Parameters

The following example displays only HDL block parameters that have non-default values for the currently selected block.

hdldispblkparams(gcb)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HDL Block Parameters ('simplevectorsum/vsum/Sum of
Elements')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Implementation

	Architecture : Linear

Implementation Parameters

	OutputPipeline : 3

View HDL Model Parameters

To display the names and values of HDL-related properties in a model, use the hdldispmdlparams function.

The following example displays HDL-related properties and values of the current model, in alphabetical order by property name.

hdldispmdlparams(bdroot,'all')
%%%%%%%%%%%%%%%%%%%%%%%%%
HDL CodeGen Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%

AddPipelineRegisters                  : 'off'
Backannotation                        : 'on'
BlockGenerateLabel                    : '_gen'
CheckHDL                              : 'off'
ClockEnableInputPort                  : 'clk_enable'
.
.
.
VerilogFileExtension                  : '.v'

The following example displays only HDL-related properties that have non-default values.

hdldispmdlparams(bdroot)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HDL CodeGen Parameters (non-default)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CodeGenerationOutput           : 'GenerateHDLCodeAndDisplayGeneratedModel'
HDLSubsystem                   : 'simplevectorsum/vsum'
ResetAssertedLevel             : 'Active-low'
Traceability                   : 'on'

See Also

Functions

Related Topics