Fixed-point variables are implemented using
uint
variables (sint8
,sint16
,sint32
), with hardcoded shift values. Data is allocated according to thewordSize
of the variable:
All calls to functions or expressions requiring integer values are done through an FXP-to-int cast, including the test driver / panel driver. Specifically, the operators “ROUND” and “TRUNC” are called with an FXP-to-int cast.
For example, given a fixed-point variable
fxp_var
, an integer variableint_var
, and the following actions:The generated code is as follows, if you specify fixed-point mode:
INT_VAR = RS_FXP2FXP16(FXP_VAR + LS_FXP2FXP16(0x4,
0, FXP_VAR_FXP_SHIFT), FXP_VAR_FXP_SHIFT, 0);
FXP_VAR = LS_FXP2FXP16(INT_VAR / 0x5, 0, FXP_VAR_FXP_SHIFT);