Floating-Point Design Structure

The original floating-point design and testbench have the following relationship.

For floating-point to fixed-point conversion, the following requirements apply to the original design and the testbench:

The testbench 'mlhdlc_filter_tb.m' (1) must be a script or a function with no inputs.

The design 'mlhdlc_filter.m' (2) must be a function.

There must be at least one call to the design from the testbench. All call sites contribute when determining the proposed fixed-point types.

Both the design and testbench can call other sub-functions within the file or other functions on the MATLAB path. Functions that exist within matlab/toolbox are not converted to fixed-point.

In the current example, the MATLAB testbench 'mlhdlc_filter_tb' has a single call to the design function 'mlhdlc_filter'. The testbench calls the design with floating-point inputs and accumulates the floating-point results for plotting.

Validate Types

During the type validation step, fixed-point code is generated for this design and complied to verify that there are no errors when applying the types. The output files will have the following structure.

The following steps are performed during fixed-point type validation process:

All user-written functions called in the floating-point design are converted to fixed-point and included in the generated design file.

A new design wrapper file is created, called 'mlhdlc_filter_wrapper_FixPt.m' (2). This file converts the floating-point data values supplied by the testbench to the fixed-point types determined for the design inputs during the conversion step. These fixed-point values are fed into the converted fixed-point design, 'mlhdlc_filter_FixPt.m'.

'mlhdlc_filter_FixPt.m' will be used for HDL code generation.

All the generated fixed-point files are stored in the output directory 'codegen/filter/fixpt'.

Click the links to the generated code in the Workflow Advisor log window to examine the generated fixed-point design, wrapper, and test bench.

MATLAB and Simulink are registered trademarks of The MathWorks, Inc. Please see www.mathworks.com/trademarks for a list of other trademarks owned by The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective owners.