MATLAB: Specifying Data Type for Code Generation with IQmath Library

c2000dataEmbedded Coderfixdtfixedfixed-pointformatiqmathpointqtitype

How do I specify the output data type for a Simulink block to be in the Q format, as used in the TI IQmath library? I am using the Embedded Coder Support Package for TI C2000 Processors.

Best Answer

The correct way to configure a block to use the Q format is to specify a fixed-point output data type that matches the particular Q format in use. For example, to configure a block for a Q23 representation, specify the data type as "fixdt(1, 32, 23)" under Block Parameters > Signal Attributes > Output data type. This indicates a signed 32-bit fixed-point number with 23 fraction bits, which matches the Q23 representation. This is described on the following documentation page, under the heading "Q Format Notation":
Please see the documentation page of "fixdt" for more information on creating Fixed-Point Numbers in Simulink:
Additionally, please refer to the user's guide for the _C28x IQmath Library - A Virtual Floating Point Engine_, Literature Number SPRC087, available at the Texas Instruments Web site for more information on the IQmath library.