Fixed-Point Code Generation Support
Introduction
All fixed-point blocks support code generation, except particular simulation features. The sections that follow describe the code generation support that the Fixed-Point Designer™ software provides. You must have a Simulink® Coder™ license to generate C code or a HDL Coder™ license to generate HDL code.
Languages
C code generation is supported with the use of Simulink Coder. HDL code generation is supported with the use of HDL Coder.
Data Types
Fixed-point code generation supports all integer and fixed-point data types that are supported by simulation. Word sizes of up to 65,535 bits are supported in simulation. See Supported Data Types.
Rounding Modes
All rounding modes — Ceiling
, Convergent
,
Floor
, Nearest
, Round
,
Simplest
, and Zero
— are supported.
Overflow Handling
Saturation and wrapping are supported.
Wrapping generates the most efficient code.
Currently, you cannot choose to exclude saturation code automatically when hardware saturation is available. Select wrapping in order for the Simulink Coder product to exclude saturation code.
Blocks
All blocks generate code for all operations with a few exceptions. The Lookup
Table Dynamic block generates code for all lookup methods except
Interpolation-Extrapolation
.
The Simulink Block Data Type Support table summarizes characteristics of blocks in the Simulink block library, including whether they support fixed-point data types and any limitations that apply for C code generation. To view the table, enter the following command at the MATLAB® command line:
showblockdatatypetable
Scaling
Any binary-point-only scaling and [Slope Bias] scaling that is supported in simulation is supported, bit-true, in code generation.