Main Content

Floating-Point Tolerance Parameters

This page describes configuration parameters that reside in the HDL Code Generation > Test Bench tab of the Configuration Parameters dialog box. Using the parameters in this tab, you can specify the floating-point tolerance strategy and the tolerance value.

Floating point tolerance check based on

When you map your design to the native floating-point libraries or the floating-point target libraries, specify the floating-point tolerance check option.

Settings

Default: relative error

Select one of these options from the drop-down menu:

  • relative error: This is the default option. When you verify the generated code by using HDL Testbench, HDL Coder™ checks for the floating-point tolerance of the native floating-point library or the floating-point target library that your design mapped to based on the relative error.

  • ulp error: When you verify the generated code by using HDL Testbench, HDL Coder checks for the floating-point tolerance of the native floating-point library or the floating-point target library that your design mapped to based on the ULP error.

Dependency

This option is disabled if you select the entire model. Select the DUT instead for Generate HDL for setting.

Command-Line Information

Property: FPToleranceStrategy
Type: character vector
Value: 'relative' | 'ULP'
Default: 'relative'

To set this property, use hdlset_param or makehdltb. To view the property value, use hdlget_param.

For example, to specify the floating-point tolerance value for a model, use the hdlset_param function to specify the tolerance strategy, and then enter the tolerance value. For example, to check the floating-point tolerance based on ULP error and enter the tolerance value:

% Check for floating-point tolerance based on ULP
hdlset_param('sfir_single', 'FPToleranceStrategy', 'ULP');   

% When using ULP, optionally enter tolerance value >= 0       
hdlset_param('FP_test_16a', 'FPToleranceValue', 1);

% Generate HDL testbench with specified tolerance setting
makehdltb('sfir_single/symmetric_fir')

Tolerance Value

Enter the tolerance value based on the floating-point tolerance check setting that you specify.

Settings

Default: 1e-07

The value must be a positive integer or a double data type.

The default tolerance value depends on the floating-point tolerance check setting that you specify. When you set the Floating point tolerance check based on to:

  • relative error, the default is a Tolerance Value of 1e-07. When you use this floating-point tolerance check setting, specify the tolerance value as a double data type. You can specify a Tolerance Value, N, that is less than or equal to 1e-07.

  • ulp error, the default is a Tolerance Value of 0. When you use this floating-point tolerance check setting, specify the tolerance value as an integer. You can specify a Tolerance Value, N, that is greater than or equal to 0.

Command-Line Information

Property: FPToleranceValue
Type: double | integer
Default: 1e-07

To set this property, use hdlset_param or makehdltb. To view the property value, use hdlget_param.

For example, to specify the floating-point tolerance value for a model, use the hdlset_param function to specify the tolerance strategy, and then enter the tolerance value. For example, to check the floating-point tolerance based on ULP error and enter the tolerance value:

% Check for floating-point tolerance based on ULP
hdlset_param('sfir_single', 'FPToleranceStrategy', 'ULP');   

% When using ULP, optionally enter tolerance value >= 0       
hdlset_param('FP_test_16a', 'FPToleranceValue', 1);

% Generate HDL testbench with specified tolerance setting
makehdltb('sfir_single/symmetric_fir')