Generate Shared Utility Code for Fixed-Point Functions
An important set of generated functions that the model build places in the shared utility folder are the fixed-point support functions. Based on model and block properties, there are many possible versions of fixed-point utilities functions that make it impractical to provide a complete set as static files. Generating only the required fixed-point utility functions during the code generation process is an efficient alternative.
The shared utility checksum mechanism makes sure that several critical properties are identical for models that use the shared utilities. For the fixed-point functions, there are additional properties that determine function behavior. The mechanism codes these properties into the functions and file names to maintain requirements. The additional properties include:
The property-based naming convention for the fixed-point utilities is as follows:
operation + [zero protection] + output data type + output bits + [input1 data] + input1 bits + [input2 data type + input2 bits] + [shift direction] + [saturate mode] + [round mode]
The file names shown are examples of generated fixed-point utility files. The function or macro names in the file are identical to the file name without the extension.
FIX2FIX_U12_U16.c FIX2FIX_S9_S9_SR99.c ACCUM_POS_S30_S30.h MUL_S30_S30_S16.h div_nzp_s16s32_floor.c div_s32_sat_floor.c
For these examples, the table shows how the respective fields correspond.
ACCUM_POS example uses
the output variable as one of the input variables. So, the file and macro name only contain
the output and second input.
div example has
identical data type and bits for both inputs and the output. So, the file and function name
only include the output.
|Output data type|
|Input data type|