Fixed-Point Blockset | ![]() ![]() |
Generating Pure Integer Code
All blocks generate pure integer code except for the FixPt Gateway In, FixPt Gateway In Inherited, and FixPt Gateway Out blocks. These blocks must generate floating-point code when handling floating-point input or output. However, if the input or output is an integer and the block is configured to treat the input or output as a stored integer, then these blocks will also generate pure integer code.
Example: Generating Pure Integer Code
This example outlines the steps you should take when generating pure integer code for your Fixed-Point Blockset model. The steps follow the description in the fxpdemo_code_only
demo, which includes the model shown below.
If your original model includes blocks that represent hardware, analog
systems, and other blocks not related to embedded software, then you must
create a new model. This new model contains only the fixed-point portion,
which represents the software that will be running on the fixed-point
processor. For example, the digital controller subsystem shown above
contains the fixed-point blocks from the fxpdemo_feedback
model used for
code generation.
Real World Value
to Stored Integer
. This does not change the signal's value, but it is needed to "tag" integers with fixed point scaling information. The FixPt Gateway In block dialog box for this configuration is shown below.int8
data type.Real World Value
to Stored Integer
. This does not change the signal's value, but it is needed to "strip" fixed-point scaling information from the integer. Also, configure the Output date type: parameter to use the appropriate integer data type. The FixPt Gateway Out block dialog box for this configuration is shown below.Fixed-step
and discrete (no continuous states)
, and configure Fixed step size: to the required value. The Solver window for this configuration is shown below.ert.tlc
. The Template makefile and Make command parameters are automatically updated. This configuration is shown below.Launch the System Target File Browser by selecting the Browse button in the Configuration panel. If it is available, select Embedded-C Real-Time Target as the system target file and hit the OK button. The System Target File Browser for this configuration is shown below.
The Fixed-Point Blockset supports all targets except those that generate Ada code. Note that you may not have ERT code generation capability. If this is the case, you should select the Generic Real-Time Target.
![]() | Code Generation Support | Using the Simulink Accelerator | ![]() |