Main Content

addFunctionReplacement

Class: coder.FixPtConfig
Namespace: coder

Replace floating-point function with fixed-point function during fixed-point conversion

Syntax

addFunctionReplacement(floatFn,fixedFn)

Description

addFunctionReplacement(floatFn,fixedFn) specifies a function replacement in a coder.FixPtConfig object. During floating-point to fixed-point conversion in the HDL code generation workflow, the conversion process replaces the specified floating-point function with the specified fixed-point function. The fixed-point function must be in the same folder as the floating-point function or on the MATLAB® path.

Input Arguments

expand all

Name of floating-point function, specified as a string.

Name of fixed-point function, specified as a string.

Examples

expand all

Create a fixed-point code configuration object, fxpCfg, with a test bench, myTestbenchName.

fxpCfg = coder.config('fixpt');
fxpCfg.TestBenchName = 'myTestbenchName';
fxpCfg.addFunctionReplacement('min', 'fi_min');
codegen -float2fixed fxpCfg designName 

Specify that the floating-point function, min, should be replaced with the fixed-point function, fi_min.

fxpCfg.addFunctionReplacement('min', 'fi_min');

When you generate code, the code generator replaces instances of min with fi_min during floating-point to fixed-point conversion.

Alternatives

You can specify function replacements in the HDL Workflow Advisor. See Function Replacements.