Main Content

hdlsaveparams

Save nondefault block- and model-level HDL parameters

Description

example

hdlsaveparams(dut) displays nondefault block- and model-level HDL parameters.

example

hdlsaveparams(dut,filename) saves nondefault block- and model-level HDL parameters to a MATLAB® script.

example

hdlsaveparams(dut,filename,force_overwrite) saves nondefault block- and model-level HDL parameters to a MATLAB script and specifies whether to overwrite the previously saved parameters MATLAB script.

example

varname = hdlsaveparams(dut) saves the nondefault block- and model-level HDL parameters to a structure array, varname.

Examples

collapse all

Open the model.

sfir_fixed

Set HDL-related model parameters for the symmetric_fir subsystem.

hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3)
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5)

Display HDL-related nondefault model parameters for the symmetric_fir subsystem.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

% Set SubSystem HDL parameters
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5);
hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3);

The output identifies the subsystem and displays its HDL-related parameter values.

This example shows how to set HDL parameters on a model and save the parameters in a MATLAB® script.

Set Model HDL Parameters

Open the sfir_fixed model.

sfir_fixed

Verify that model parameters have default values.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

Set HDL-related model parameters for the symmetric_fir subsystem.

hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3)
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5)

Save Model HDL Parameters

Verify that model parameters are set.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

% Set SubSystem HDL parameters
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5);
hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3);

Save the model parameters to a MATLAB® script, sfir_saved_params.m.

hdlsaveparams('sfir_fixed/symmetric_fir', 'sfir_saved_params.m')

Verify Saved Parameters

Reset HDL-related model parameters to default values.

hdlrestoreparams('sfir_fixed/symmetric_fir')

Verify that model parameters have default values.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed');

Restore the saved model parameters from sfir_saved_params.m.

hdlrestoreparams('sfir_fixed/symmetric_fir', 'sfir_saved_params.m')

Verify that the saved model parameters are restored

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

% Set SubSystem HDL parameters
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5);
hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3);

This example shows how to set HDL parameters on a model, save the parameters in a MATLAB® script, and then overwrite the saved parameters.

Set Model HDL Parameters

Open the sfir_fixed model.

sfir_fixed

Verify that model parameters have default values.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

Set HDL-related model parameters for the symmetric_fir subsystem.

hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3)
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5)

Save Model HDL Parameters

Verify that model parameters are set.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

% Set SubSystem HDL parameters
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5);
hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3);

Save the model parameters to a MATLAB® script, sfir_saved_params.m.

hdlsaveparams('sfir_fixed/symmetric_fir', 'sfir_saved_params.m')

Verify Saved Parameters

Reset HDL-related model parameters to default values.

hdlrestoreparams('sfir_fixed/symmetric_fir')

Verify that model parameters have default values.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed');

Restore the saved model parameters from sfir_saved_params.m.

hdlrestoreparams('sfir_fixed/symmetric_fir', 'sfir_saved_params.m')

Verify that the saved model parameters are restored

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');

% Set SubSystem HDL parameters
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5);
hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 3);

Modify Saved HDL Parameters

Modify HDL-related model parameters set for the symmetric_fir subsystem.

hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 4)
hdlset_param('sfir_fixed/symmetric_fir', 'OutputPipeline', 2)
hdlset_param('sfir_fixed', 'ShareAdders', 'on')

Overwrite Saved Parameters File

Set the force_overwrite flag to true to overwrite the parameters file sfir_saved_parameters.m with the new parameters. If you do not specify this flag, HDL Coder™ generates an error and doesn't overwrite the parameter values. When you run hdlsaveparams with the parameter set to true, HDL Coder™ generates a warning that it overwrites the file.

hdlsaveparams('sfir_fixed/symmetric_fir', 'sfir_saved_params.m','true')
Warning: HDL parameters file 'sfir_saved_params.m' already exists. By
overwriting it now, you will lose any parameter settings made earlier. 

Verify Resaved Parameters

Reset HDL-related model parameters to default values.

hdlrestoreparams('sfir_fixed/symmetric_fir')

Verify that model parameters have default values.

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed');

Restore the saved model parameters from sfir_saved_params.m.

hdlrestoreparams('sfir_fixed/symmetric_fir', 'sfir_saved_params.m')

Verify that the saved model parameters are restored

hdlsaveparams('sfir_fixed/symmetric_fir')
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');
hdlset_param('sfir_fixed', 'ShareAdders', 'on');

% Set SubSystem HDL parameters
hdlset_param('sfir_fixed/symmetric_fir', 'InputPipeline', 5);
hdlset_param('sfir_fixed/symmetric_fir', 'OutputPipeline', 2);
hdlset_param('sfir_fixed/symmetric_fir', 'SharingFactor', 4);

This example shows how to save non-default HDL model and block parameters in a structure array and access individual parameters.

Open the model

sfir_single
sim('sfir_single')

Save HDL Model and Block parameters

hparams = hdlsaveparams('sfir_single/symmetric_fir');
%% Set Model 'sfir_single' HDL parameters
hdlset_param('sfir_single', 'FloatingPointTargetConfiguration', hdlcoder.createFloatingPointTargetConfig('NATIVEFLOATINGPOINT' ...
,  'MantissaMultiplyStrategy', 'FullMultiplier') ...
);
hdlset_param('sfir_single', 'HDLSubsystem', 'sfir_single/symmetric_fir');

% Set SubSystem HDL parameters
hdlset_param('sfir_single/symmetric_fir', 'InputPipeline', 1);
hdlset_param('sfir_single/symmetric_fir', 'OutputPipeline', 1);

View and Access Block Parameters

hparams
hparams = 

  1x4 struct array with fields:

    object
    parameter
    value

To see specific non-default parameters saved in the structure, you can access individual elements of the structure.

hparams(2)
ans = 

  struct with fields:

       object: 'sfir_single'
    parameter: 'HDLSubsystem'
        value: 'sfir_single/symmetric_fir'

To view the parameters and values specified for the model, in the MATLAB™ Worksplace, double-click the hparams variable. You see the fields of the structure array and the corresponding values in the MATLAB Editor.

Input Arguments

collapse all

DUT subsystem name, specified as a character vector, with full hierarchical path.

Example: 'modelname/subsysTarget'

Example: 'modelname/subsysA/subsysB/subsysTarget'

Name of file to which you are saving model parameters, specified as a character vector.

Example: 'mymodel_saved_params.m'

Specify whether to overwrite the previously saved parameters file as a boolean.

Example: 'true'

Output Arguments

collapse all

Specify the name of the variable that contains the saved model parameters. The variable are saved as a structure array.

Example: 'hparams'

Introduced in R2012b