%if EXISTS("_FIXPTLIB_") == 0
%assign _FIXPTLIB_ = 1
%include "fixpt_version.tlc"
%addtorecord ::CompiledModel IncludeFloatDotH 0
%if EXISTS("FixPtLookup_opt_pow2") == 0
%assign FixPtLookup_opt_pow2 = 1
%endif
%assign SupportDataTypes = 1
%include "fixpttarget.tlc"
%function LibCacheFixptOddSizeTypedefs(buffer) void
%if !ISFIELD(::CompiledModel, "FixptOddSizeTypedefs")
%addtorecord ::CompiledModel FixptOddSizeTypedefs ""
%endif
%assign ::CompiledModel.FixptOddSizeTypedefs = ::CompiledModel.FixptOddSizeTypedefs + buffer
%endfunction
%assign PreDefinedIntegerType = [8,16,32]
%function FixPt_RegisterLongAsBuiltInType( ) void
%assign ::CompiledModel.tSS_LONG = ::CompiledModel.DataTypes.NumDataTypes
%assign ::CompiledModel.tSS_ULONG = ::CompiledModel.DataTypes.NumDataTypes + 1
%assign ::CompiledModel.DataTypes.NumDataTypes = ::CompiledModel.DataTypes.NumDataTypes + 2
%assign newDTName = "int%<IntegerSizes.LongNumBits>_T"
%assign newCDTName = "cint%<IntegerSizes.LongNumBits>_T"
%assign newEnuName = "SS_INT%<IntegerSizes.LongNumBits>"
%assign dtSize = IntegerSizes.LongNumBits / IntegerSizes.CharNumBits
%addtorecord ::CompiledModel.DataTypes /
DataType { /
ActualBits %<IntegerSizes.LongNumBits> /
Bias 0 /
ComplexGroundName "" /
ComplexGroundReqInMemory 0 /
ComplexName newCDTName /
ConvertBetweenTLCFcnFile "" /
ConvertBetweenTLCFcnName "SLibConvertBetweenBuiltin" /
DTName newDTName /
DataTypeName newDTName /
Enum newEnuName /
FixedExp 0 /
FracSlope 1 /
GroundHasNonZero 0 /
GroundInit "" /
GroundName "" /
GroundReqInMemory 0 /
GroundValue 0 /
HasObject 0 /
HeaderFile "" /
Id %<::CompiledModel.tSS_LONG> /
IdAliasedThruTo %<::CompiledModel.tSS_LONG> /
IdAliasedTo -10 /
IsBus 0 /
IsEnumType 0 /
IsFixedPoint 0 /
IsPositiveTLCFcnFile "" /
IsPositiveTLCFcnName "SLibIsPositiveBuiltin" /
IsSigned 1 /
Name newDTName /
NativeType newDTName /
NumElements 0 /
RequiredBits %<IntegerSizes.LongNumBits> /
SignTLCFcnFile "" /
SignTLCFcnName "SLibSignBuiltin" /
Size %<dtSize> /
StorageId %<::CompiledModel.tSS_LONG> /
}
%assign newDTName = "uint%<IntegerSizes.LongNumBits>_T"
%assign newCDTName = "cuint%<IntegerSizes.LongNumBits>_T"
%assign newEnuName = "SS_UINT%<IntegerSizes.LongNumBits>"
%addtorecord ::CompiledModel.DataTypes /
DataType { /
ActualBits %<IntegerSizes.LongNumBits> /
Bias 0 /
ComplexGroundName "" /
ComplexGroundReqInMemory 0 /
ComplexName newCDTName /
ConvertBetweenTLCFcnFile "" /
ConvertBetweenTLCFcnName "SLibConvertBetweenBuiltin" /
DTName newDTName /
DataTypeName newDTName /
Enum newEnuName /
FixedExp 0 /
FracSlope 1 /
GroundHasNonZero 0 /
GroundInit "" /
GroundName "" /
GroundReqInMemory 0 /
GroundValue 0U /
HasObject 0 /
HeaderFile "" /
Id %<::CompiledModel.tSS_ULONG> /
IdAliasedThruTo %<::CompiledModel.tSS_ULONG> /
IdAliasedTo -10 /
IsBus 0 /
IsEnumType 0 /
IsFixedPoint 0 /
IsPositiveTLCFcnFile "" /
IsPositiveTLCFcnName "SLibIsPositiveBuiltin" /
IsSigned 0 /
Name newDTName /
NativeType newDTName /
NumElements 0 /
RequiredBits %<IntegerSizes.LongNumBits> /
SignTLCFcnFile "" /
SignTLCFcnName "SLibSignBuiltin" /
Size %<dtSize> /
StorageId %<::CompiledModel.tSS_ULONG> /
}
%openfile utilityDef
#ifndef SS_INT%<IntegerSizes.LongNumBits>
#define SS_INT%<IntegerSizes.LongNumBits> %<::CompiledModel.tSS_LONG>
#endif
#ifndef SS_UINT%<IntegerSizes.LongNumBits>
#define SS_UINT%<IntegerSizes.LongNumBits> %<::CompiledModel.tSS_ULONG>
#endif
%closefile utilityDef
%<LibCacheFixptOddSizeTypedefs(utilityDef)>/
%undef utilityDef
%assign ::PreDefinedIntegerType = FEVAL("union",::PreDefinedIntegerType, IntegerSizes.LongNumBits)
%endfunction
%function FixPt_RegisterLongLongAsBuiltInType( ) void
%assign ::CompiledModel.tSS_LONG_LONG = ::CompiledModel.DataTypes.NumDataTypes
%assign ::CompiledModel.tSS_ULONG_LONG = ::CompiledModel.DataTypes.NumDataTypes + 1
%assign ::CompiledModel.DataTypes.NumDataTypes = ::CompiledModel.DataTypes.NumDataTypes + 2
%assign newDTName = "int%<IntegerSizes.LongLongNumBits>_T"
%assign newCDTName = "cint%<IntegerSizes.LongLongNumBits>_T"
%assign newEnuName = "SS_INT%<IntegerSizes.LongLongNumBits>"
%assign dtSize = IntegerSizes.LongLongNumBits / IntegerSizes.CharNumBits
%addtorecord ::CompiledModel.DataTypes /
DataType { /
ActualBits %<IntegerSizes.LongLongNumBits> /
Bias 0 /
ComplexGroundName "" /
ComplexGroundReqInMemory 0 /
ComplexName newCDTName /
ConvertBetweenTLCFcnFile "" /
ConvertBetweenTLCFcnName "SLibConvertBetweenBuiltin" /
DTName newDTName /
DataTypeName newDTName /
Enum newEnuName /
FixedExp 0 /
FracSlope 1 /
GroundHasNonZero 0 /
GroundInit "" /
GroundName "" /
GroundReqInMemory 0 /
GroundValue 0 /
HasObject 0 /
HeaderFile "" /
Id %<::CompiledModel.tSS_LONG_LONG> /
IdAliasedThruTo %<::CompiledModel.tSS_LONG_LONG> /
IdAliasedTo -10 /
IsBus 0 /
IsEnumType 0 /
IsFixedPoint 0 /
IsPositiveTLCFcnFile "" /
IsPositiveTLCFcnName "SLibIsPositiveBuiltin" /
IsSigned 1 /
Name newDTName /
NativeType newDTName /
NumElements 0 /
RequiredBits %<IntegerSizes.LongLongNumBits> /
SignTLCFcnFile "" /
SignTLCFcnName "SLibSignBuiltin" /
Size %<dtSize> /
StorageId %<::CompiledModel.tSS_LONG_LONG> /
}
%assign newDTName = "uint%<IntegerSizes.LongLongNumBits>_T"
%assign newCDTName = "cuint%<IntegerSizes.LongLongNumBits>_T"
%assign newEnuName = "SS_UINT%<IntegerSizes.LongLongNumBits>"
%addtorecord ::CompiledModel.DataTypes /
DataType { /
ActualBits %<IntegerSizes.LongLongNumBits> /
Bias 0 /
ComplexGroundName "" /
ComplexGroundReqInMemory 0 /
ComplexName newCDTName /
ConvertBetweenTLCFcnFile "" /
ConvertBetweenTLCFcnName "SLibConvertBetweenBuiltin" /
DTName newDTName /
DataTypeName newDTName /
Enum newEnuName /
FixedExp 0 /
FracSlope 1 /
GroundHasNonZero 0 /
GroundInit "" /
GroundName "" /
GroundReqInMemory 0 /
GroundValue 0U /
HasObject 0 /
HeaderFile "" /
Id %<::CompiledModel.tSS_ULONG_LONG> /
IdAliasedThruTo %<::CompiledModel.tSS_ULONG_LONG> /
IdAliasedTo -10 /
IsBus 0 /
IsEnumType 0 /
IsFixedPoint 0 /
IsPositiveTLCFcnFile "" /
IsPositiveTLCFcnName "SLibIsPositiveBuiltin" /
IsSigned 0 /
Name newDTName /
NativeType newDTName /
NumElements 0 /
RequiredBits %<IntegerSizes.LongLongNumBits> /
SignTLCFcnFile "" /
SignTLCFcnName "SLibSignBuiltin" /
Size %<dtSize> /
StorageId %<::CompiledModel.tSS_ULONG_LONG> /
}
%openfile utilityDef
#ifndef SS_INT%<IntegerSizes.LongLongNumBits>
#define SS_INT%<IntegerSizes.LongLongNumBits> %<::CompiledModel.tSS_LONG_LONG>
#endif
#ifndef SS_UINT%<IntegerSizes.LongLongNumBits>
#define SS_UINT%<IntegerSizes.LongLongNumBits> %<::CompiledModel.tSS_ULONG_LONG>
#endif
%closefile utilityDef
%<LibCacheFixptOddSizeTypedefs(utilityDef)>/
%undef utilityDef
%assign ::PreDefinedIntegerType = FEVAL("union",::PreDefinedIntegerType, IntegerSizes.LongLongNumBits)
%endfunction
%assign GeneratedMultiWordTypes = [8,16,32]
%function FixPt_RegisterMultiWordTypes(nChunks, chunkType) void
%assign nBits = nChunks*LargestIntegerNumBits
%assign definedInt = FEVAL("intersect",::GeneratedMultiWordTypes,nBits)
%if !ISEMPTY(definedInt)
%return
%endif
%assign tSS_TYPE = ::CompiledModel.DataTypes.NumDataTypes
%assign tSS_UTYPE = ::CompiledModel.DataTypes.NumDataTypes + 1
%assign ::CompiledModel.DataTypes.NumDataTypes = ::CompiledModel.DataTypes.NumDataTypes + 2
%assign newDTName = "int%<nBits>m_T"
%assign newCDTName = "cint%<nBits>m_T"
%if IntegerSizes.LongNumBits == LargestIntegerNumBits
%assign newEnuName = "SS_INT%<IntegerSizes.LongNumBits>"
%else
%assign newEnuName = "SS_INT%<IntegerSizes.LongLongNumBits>"
%endif
%assign dtSize = nBits / IntegerSizes.CharNumBits
%addtorecord ::CompiledModel.DataTypes /
DataType { /
ActualBits %<nBits> /
Bias 0 /
ComplexGroundName "" /
ComplexGroundReqInMemory 0 /
ComplexName newCDTName /
ConvertBetweenTLCFcnFile "" /
ConvertBetweenTLCFcnName "SLibConvertBetweenBuiltin" /
DTName newDTName /
DataTypeName newDTName /
Enum newEnuName /
FixedExp 0 /
FracSlope 1 /
GroundHasNonZero 0 /
GroundInit "" /
GroundName "" /
GroundReqInMemory 0 /
GroundValue 0 /
HasObject 0 /
HeaderFile "" /
Id %<tSS_TYPE> /
IdAliasedThruTo %<tSS_TYPE> /
IdAliasedTo -10 /
IsBus 0 /
IsEnumType 0 /
IsFixedPoint 1 /
IsPositiveTLCFcnFile "" /
IsPositiveTLCFcnName "SLibIsPositiveBuiltin" /
IsSigned 1 /
Name newDTName /
NativeType newDTName /
NumElements 0 /
RequiredBits %<nBits> /
SignTLCFcnFile "" /
SignTLCFcnName "SLibSignBuiltin" /
Size %<dtSize> /
StorageId %<tSS_TYPE> /
}
%addtorecord ::CompiledModel.DataTypes.DataType[tSS_TYPE] /
Elements { /
Name "chunks" /
NumDimensions 1 /
Dimensions %<nChunks> /
DataTypeId %<chunkType> /
Padding 0 /
IsComplex 0 /
IsFixedPoint 0 /
Width %<nChunks> /
Offset 0 /
}
%assign ::CompiledModel.DataTypes.DataType[tSS_TYPE] .NumElements = 1
%assign newDTName = "uint%<nBits>m_T"
%assign newCDTName = "cuint%<nBits>m_T"
%assign newEnuName = "SS_UINT%<LargestIntegerNumBits>"
%addtorecord ::CompiledModel.DataTypes /
DataType { /
ActualBits %<nBits> /
Bias 0 /
ComplexGroundName "" /
ComplexGroundReqInMemory 0 /
ComplexName newCDTName /
ConvertBetweenTLCFcnFile "" /
ConvertBetweenTLCFcnName "SLibConvertBetweenBuiltin" /
DTName newDTName /
DataTypeName newDTName /
Enum newEnuName /
FixedExp 0 /
FracSlope 1 /
GroundHasNonZero 0 /
GroundInit "" /
GroundName "" /
GroundReqInMemory 0 /
GroundValue 0U /
HasObject 0 /
HeaderFile "" /
Id %<tSS_UTYPE> /
IdAliasedThruTo %<tSS_UTYPE> /
IdAliasedTo -10 /
IsBus 0 /
IsEnumType 0 /
IsFixedPoint 1 /
IsPositiveTLCFcnFile "" /
IsPositiveTLCFcnName "SLibIsPositiveBuiltin" /
IsSigned 0 /
Name newDTName /
NativeType newDTName /
NumElements 0 /
RequiredBits %<nBits> /
SignTLCFcnFile "" /
SignTLCFcnName "SLibSignBuiltin" /
Size %<dtSize> /
StorageId %<tSS_UTYPE> /
}
%addtorecord ::CompiledModel.DataTypes.DataType[tSS_UTYPE] /
Elements { /
Name "chunks" /
NumDimensions 1 /
Dimensions %<nChunks> /
DataTypeId %<chunkType> /
Padding 0 /
IsComplex 0 /
IsFixedPoint 0 /
Width %<nChunks> /
Offset 0 /
}
%assign ::CompiledModel.DataTypes.DataType[tSS_UTYPE] .NumElements = 1
%assign ::GeneratedMultiWordTypes = FEVAL("union",::GeneratedMultiWordTypes, nBits)
%endfunction
%function fxpIsPreDefinedIntegerType( ActualBits ) void
%assign definedInt = FEVAL("intersect",::PreDefinedIntegerType,ActualBits)
%if ISEMPTY(definedInt)
%return TLC_FALSE
%else
%return TLC_TRUE
%endif
%endfunction
%function FixPt_RegisterHalfAsBuiltInType( index ) void
%assign curDT = FixPt_GetDataTypeFromIndex(index)
%<fcnSetDataTypeName(curDT, "real16_T", TLC_FALSE)>
%<SLibSetDataTypeEnum(curDT, "SS_HALF")>
%<SLibSetDataTypeConvertBetweenTLCFcnName(curDT, "Fixpt_HalfPrecisionConvertBetween")>
%<SLibSetDataTypeIsPositiveTLCFcnName(curDT, "Fixpt_HalfPrecisionIsPositive")>
%<SLibSetDataTypeSignTLCFcnName(curDT, "Fixpt_HalfPrecisionSign")>
%<LibAddToCompiledModel("tSS_HALF", curDT.Id)>
%assign gndName = "%<::CompiledModel.Name>_R16GND"
%<SLibSetDataTypeGroundName(curDT, gndName)>
%<SLibSetDataTypeGroundValue(curDT, "floatToHalf(0.0F)")>
%<SLibSetDataTypeGroundInit(curDT, "{ 0U }")>
%<SLibSetDataTypeGroundHasFloats(curDT, 1)>
%<SLibSetDataTypeComplexName(curDT, "creal16_T")>
%<SLibSetDataTypeComplexGroundName(curDT, gndName + "_Complex")>
%<DeclareHalfPrecisionUsage(TLC_TRUE)>
%openfile utilityDef
#ifndef SS_HALF
#define SS_HALF %<::CompiledModel.tSS_HALF>
#endif
%closefile utilityDef
%<LibCacheFixptOddSizeTypedefs(utilityDef)>/
%undef utilityDef
%endfunction
%function FixPt_DefineSingleWordDTLargerThanInt( dataTypeRec ) void
%assign curBits = FixPt_RequiredBits_2_ActualBits(dataTypeRec.RequiredBits)
%if curBits == IntegerSizes.LongNumBits
%if !fxpIsPreDefinedIntegerType(IntegerSizes.LongNumBits) && (ISFIELD(::CompiledModel, "tSS_LONG"))
%<FixPt_RegisterLongAsBuiltInType()>
%endif
%elseif (curBits == IntegerSizes.LongLongNumBits) && (IntegerSizes.LongLongMode == 1)
%if!fxpIsPreDefinedIntegerType(IntegerSizes.LongLongNumBits) && (ISFIELD(::CompiledModel, "tSS_LONG_LONG"))
%<FixPt_RegisterLongLongAsBuiltInType()>
%endif
%endif
%if !LibIsBuiltInWordSize(curBits)
%if curBits == IntegerSizes.LongNumBits
%if dataTypeRec.IsSigned
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_LONG
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_LONG].Enum
%else
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_ULONG
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_ULONG].Enum
%endif
%elseif (curBits == IntegerSizes.LongLongNumBits) && (IntegerSizes.LongLongMode == 1)
%if dataTypeRec.IsSigned
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_LONG_LONG
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_LONG_LONG].Enum
%else
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_ULONG_LONG
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_ULONG_LONG].Enum
%endif
%endif
%endif
%endfunction
%function FixPt_PoundDefineOverSizedDataType( dataTypeRec ) void
%<FixPt_DefineSingleWordDTLargerThanInt(dataTypeRec)>
%assign curBits = FixPt_RequiredBits_2_ActualBits(dataTypeRec.RequiredBits)
%if curBits >= LargestIntegerNumBits
%if LargestIntegerNumBits == IntegerSizes.LongNumBits
%if!fxpIsPreDefinedIntegerType(IntegerSizes.LongNumBits) && ISFIELD(::CompiledModel, "tSS_LONG") ...
&& (curBits > IntegerSizes.LongNumBits)
%<FixPt_RegisterLongAsBuiltInType()>
%endif
%else
%if!fxpIsPreDefinedIntegerType(IntegerSizes.LongLongNumBits) && ISFIELD(::CompiledModel, "tSS_LONG_LONG") ...
&& (curBits > IntegerSizes.LongLongNumBits)
%<FixPt_RegisterLongLongAsBuiltInType()>
%endif
%endif
%if curBits > LargestIntegerNumBits
%if !LibIsBuiltInWordSize(LargestIntegerNumBits)
%if LargestIntegerNumBits == IntegerSizes.LongNumBits
%assign chunkType = ::CompiledModel.tSS_ULONG
%else
%assign chunkType = ::CompiledModel.tSS_ULONG_LONG
%endif
%else
%switch LargestIntegerNumBits
%case 32
%assign chunkType = ::CompiledModel.tSS_UINT32
%break
%default
%break
%endswitch
%endif
%assign curNumChunks = FixPt_NumChunks(curBits)
%assign dataTypeRec.NumElements = 1
%addtorecord dataTypeRec /
Elements { /
Name "chunks" /
NumDimensions 1 /
Dimensions %<curNumChunks> /
DataTypeId %<chunkType> /
Padding 0 /
IsComplex 0 /
IsFixedPoint 0 /
Width %<curNumChunks> /
Offset 0 /
}
%assign maxChunks = FixPt_NumChunks(::CompiledModel.LargestMultiwordBits)
%foreach chunkStep = (maxChunks - 1)
%assign nChunks = chunkStep + 2
%<FixPt_RegisterMultiWordTypes(nChunks, chunkType)>
%endforeach
%endif
%if curBits == LargestIntegerNumBits ...
&& !LibIsBuiltInWordSize(LargestIntegerNumBits)
%if LargestIntegerNumBits == IntegerSizes.LongNumBits
%if dataTypeRec.IsSigned
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_LONG
%else
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_ULONG
%endif
%else
%if dataTypeRec.IsSigned
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_LONG_LONG
%else
%assign dataTypeRec.IdAliasedTo = ::CompiledModel.tSS_ULONG_LONG
%endif
%endif
%endif
%if !LibIsBuiltInWordSize(LargestIntegerNumBits)
%if LargestIntegerNumBits == IntegerSizes.LongNumBits
%if dataTypeRec.IsSigned
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_LONG].Enum
%else
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_ULONG].Enum
%endif
%else
%if dataTypeRec.IsSigned
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_LONG_LONG].Enum
%else
%assign dataTypeRec.Enum = ::CompiledModel.DataTypes.DataType[::CompiledModel.tSS_ULONG_LONG].Enum
%endif
%endif
%elseif dataTypeRec.Enum == ""
%if(curBits <= 8)
%if dataTypeRec.IsSigned
%assign dataTypeRec.Enum = "SS_INT8"
%else
%assign dataTypeRec.Enum = "SS_UINT8"
%endif
%elseif(curBits <= 16)
%if dataTypeRec.IsSigned
%assign dataTypeRec.Enum = "SS_INT16"
%else
%assign dataTypeRec.Enum = "SS_UINT16"
%endif
%else
%if dataTypeRec.IsSigned
%assign dataTypeRec.Enum = "SS_INT32"
%else
%assign dataTypeRec.Enum = "SS_UINT32"
%endif
%endif
%endif
%endif
%endfunction
%assign FixPt_int_label = "int%<IntegerSizes.IntNumBits>_T"
%assign FixPt_uint_label = "uint%<IntegerSizes.IntNumBits>_T"
%assign FixPt_long_label = "int%<IntegerSizes.LongNumBits>_T"
%assign FixPt_ulong_label = "uint%<IntegerSizes.LongNumBits>_T"
%assign FixPt_long_long_label = "int%<IntegerSizes.LongLongNumBits>_T"
%assign FixPt_ulong_long_label = "uint%<IntegerSizes.LongLongNumBits>_T"
%assign FixPt_double_label = "real_T"
%assign FixPt_single_label = "real32_T"
%assign standardFixPointFields = [ ...
"DataTypeName", ...
"IsSigned", ...
"RequiredBits", ...
"ActualBits", ...
"FixedExp", ...
"FracSlope", ...
"Bias", ...
"NativeType" ...
]
%if IntegerSizes.CharNumBits < IntegerSizes.ShortNumBits
%assign NativeWordSizes = []
%assign NativeWordSizes = NativeWordSizes + IntegerSizes.CharNumBits
%assign NativeWordSizes = NativeWordSizes + IntegerSizes.ShortNumBits
%else
%assign NativeWordSizes = []
%assign NativeWordSizes = NativeWordSizes + IntegerSizes.ShortNumBits
%endif
%if IntegerSizes.IntNumBits > IntegerSizes.ShortNumBits
%assign NativeWordSizes = NativeWordSizes + IntegerSizes.IntNumBits
%endif
%if IntegerSizes.LongNumBits > IntegerSizes.IntNumBits
%assign NativeWordSizes = NativeWordSizes + IntegerSizes.LongNumBits
%endif
%if (IntegerSizes.LongLongNumBits > IntegerSizes.LongNumBits && IntegerSizes.LongLongMode == 1)
%assign NativeWordSizes = NativeWordSizes + IntegerSizes.LongLongNumBits
%endif
%foreach idx = SIZE(NativeWordSizes, 1)
%if ( NativeWordSizes[idx] % 8 )
%assign errTxt = "Simulink Coder only supports word sizes that are " ...
"a multiple of 8. Illegal word size: "+STRING(NativeWordSizes[idx])
%exit Simulink Coder Fatal: %<errTxt>
%endif
%endforeach
%assign errTxt = ""
%if !EXISTS("FixPtUtils")
%createrecord FixPtUtils { ...
NothingMacro 1}
%else
%exit Simulink Coder Fatal: FixPtUtils already exists.
%endif
%function FLib_ReImIdx(sigIdx,iCase) void
%if iCase == 0
%assign riSigIdx = tRealPart + STRING(sigIdx)
%elseif iCase == 1
%assign riSigIdx = tImagPart + STRING(sigIdx)
%else
%assign riSigIdx = sigIdx
%endif
%return riSigIdx
%endfunction
%function FixPt_DataTypesSame(aDT,bDT)
%if !FixPt_SpecifiedContainerSame(aDT,bDT) || ...
aDT.FixedExp != bDT.FixedExp || ...
aDT.FracSlope != bDT.FracSlope || ...
aDT.Bias != bDT.Bias
%return 0
%else
%return 1
%endif
%endfunction
%function FixPt_SpecifiedContainerSame(aDT,bDT)
%if aDT.NativeType != bDT.NativeType || ...
aDT.RequiredBits != bDT.RequiredBits || ...
aDT.IsSigned != bDT.IsSigned || ...
FixPt_DataTypeIsBoolean">FixPt_DataTypeIsBoolean(aDT) != FixPt_DataTypeIsBoolean">FixPt_DataTypeIsBoolean(bDT)
%return 0
%else
%return 1
%endif
%endfunction
%function FixPt_FracSlopesSame(aFracSlope,bFracSlope)
%if aFracSlope == bFracSlope
%return 1
%endif
%if aFracSlope > bFracSlope
%assign ferror = ( aFracSlope - bFracSlope )
%else
%assign ferror = ( bFracSlope - aFracSlope )
%endif
%return ( ferror < 1.164153218269348e-010 )
%endfunction
%function FixPt_DataTypeSetup(index) void
%with ::CompiledModel
%assign curDT = FixPt_GetDataTypeFromIndex(index)
%assign dTypeId = curDT.Id
%if curDT.IsNumericType
%<FixPt_DataTypePolish(index)>/
%assign curDT = FixPt_GetDataTypeFromIndex(index)
%if !LibIsBuiltInDataType(dTypeId)
%assign dTypeRec = FixPt_GetDataTypeFromIndex(dTypeId)
%assign dTypeName = curDT.NativeType
%if ISFIELD(dTypeRec,"GroundName")
%if dTypeRec.GroundName == ""
%assign dTypeRecNeedsAdditions = 1
%else
%assign dTypeRecNeedsAdditions = 0
%endif
%else
%assign dTypeRecNeedsAdditions = 1
%endif
%if dTypeRecNeedsAdditions
%if !LibIsAliasDataType(dTypeId) || LibIsDataTypeNewLongestFixpt(dTypeId)
%<fcnSetDataTypeName(dTypeRec, dTypeName, TLC_FALSE)>
%endif
%<SLibSetDataTypeConvertBetweenTLCFcnName(dTypeRec, "FixPt_DtConvertBetween")>
%<SLibSetDataTypeIsPositiveTLCFcnName( dTypeRec, "FixPt_DtIsPositive")>
%<SLibSetDataTypeSignTLCFcnName(dTypeRec, "FixPt_DtSign")>
%foreach nativeDtId = ::CompiledModel.DataTypes.NumSLBuiltInDataTypes
%if curDT.NativeType == LibGetDataTypeNameFromId(nativeDtId)
%assign enum = LibGetDataTypeEnumFromId(nativeDtId)
%<SLibSetDataTypeEnum(dTypeRec, enum)>
%undef enum
%break
%endif
%endforeach
%if ISFIELD(curDT,"StoredIntegerZero")
%assign storedIntegerZero = curDT.StoredIntegerZero
%else
%assign storedIntegerZero = FixPt_Dbl2StoredInt(0.0,curDT)
%endif
%assign grndLabel = ::CompiledModel.Name + "_" +curDT.DTName + "_GND"
%<SLibSetDataTypeGroundName(dTypeRec, grndLabel)>
%<SLibSetDataTypeGroundValue(dTypeRec, storedIntegerZero)>
%if !LibIsAliasDataType(dTypeId)
%<SLibSetDataTypeComplexName(dTypeRec, "c" + dTypeName)>
%endif
%<SLibSetDataTypeComplexGroundName(dTypeRec, grndLabel + "_Complex")>
%endif
%endif
%endif
%endwith
%endfunction
%function FixPt_Setup(block, system) void
%assign MaskBlockName = "'" + Name + "'"
%assign block = block + MaskBlockName
%if ISFIELD(block,"FixPtRoundingMode")
%switch FixPtRoundingMode
%case 0
%assign block.FixPtRoundingMode = "Zero"
%break
%case 1
%assign block.FixPtRoundingMode = "Nearest"
%break
%case 2
%assign block.FixPtRoundingMode = "Ceiling"
%break
%case 3
%assign block.FixPtRoundingMode = "Floor"
%break
%case 4
%assign block.FixPtRoundingMode = "Simplest"
%break
%case 5
%assign block.FixPtRoundingMode = "Round"
%break
%case 6
%assign block.FixPtRoundingMode = "Convergent"
%break
%default
%exit Simulink Coder Fatal: Unknown Rounding Mode: %<FixPtRoundingMode>
%endswitch
%endif
%if ISFIELD(block,"FixPtSaturationMode")
%switch FixPtSaturationMode
%case 0
%assign block.FixPtSaturationMode = "Wrap"
%break
%case 1
%assign block.FixPtSaturationMode = "Saturate"
%break
%default
%exit Simulink Coder Fatal: Unknown Saturation Mode: %<FixPtSaturationMode>
%endswitch
%endif
%endfunction
%function FixPt_NumChunks(requiredBits) void
%assign nChunks = requiredBits / LargestIntegerNumBits
%if requiredBits % LargestIntegerNumBits != 0
%assign nChunks = nChunks + 1
%endif
%return nChunks
%endfunction
%function FixPt_RequiredBits_2_ActualBits(requiredBits) void
%if requiredBits <= IntegerSizes.CharNumBits
%assign actualBits = IntegerSizes.CharNumBits
%elseif requiredBits <= IntegerSizes.ShortNumBits
%assign actualBits = IntegerSizes.ShortNumBits
%elseif requiredBits <= IntegerSizes.IntNumBits
%assign actualBits = IntegerSizes.IntNumBits
%elseif requiredBits <= IntegerSizes.LongNumBits
%assign actualBits = IntegerSizes.LongNumBits
%elseif (requiredBits <= IntegerSizes.LongLongNumBits && IntegerSizes.LongLongMode == 1)
%assign actualBits = IntegerSizes.LongLongNumBits
%else
%assign nChunks = FixPt_NumChunks(requiredBits)
%assign actualBits = LargestIntegerNumBits * nChunks
%endif
%return actualBits
%endfunction
%function FixPt_ActualBits_TooBig(actualBits) void
%return ( actualBits > LibMaxCodeGenWordSize() )
%endfunction
%function FixPt_DataTypePolish(index) void
%assign dataTypeRec = FixPt_GetDataTypeFromIndex(index)
%assign dataTypeRecAliasThru = FixPt_GetAliasedThruDataTypeFromIndex(index)
%if !(ISFIELD(dataTypeRec,"NativeType"))
%assign validType = 1
%assign dtName = "%<dataTypeRecAliasThru.DTName>"
%if ISFIELD(dataTypeRec, "Enum") && dataTypeRec.Enum == "SS_DOUBLE"
%assign actualBits = dataTypeRec.RequiredBits
%assign nativeType = "real_T"
%elseif ISFIELD(dataTypeRec, "Enum") && dataTypeRec.Enum == "SS_SINGLE"
%assign actualBits = dataTypeRec.RequiredBits
%assign nativeType = "real32_T"
%elseif ISFIELD(dataTypeRec, "Enum") && dataTypeRec.Enum == "SS_HALF"
%assign actualBits = dataTypeRec.RequiredBits
%assign nativeType = "real16_T"
%else
%assign actualBits = FixPt_RequiredBits_2_ActualBits(dataTypeRec.RequiredBits)
%if FixPt_ActualBits_TooBig(actualBits)
%if Accelerator
%openfile errTxt
This model can't be used with the Accelerator. The Data Type
%<dtName> requires %<dataTypeRec.RequiredBits> bits, but the maximum supported
with the Accelerator on this computer is %<LibMaxCodeGenWordSize()> bits.
%closefile errTxt
%<LibReportFatalError(errTxt)>/
%endif
%endif
%assign dtStart = dtName[0]+dtName[1]+dtName[2]
%if dtStart == "flt"
%assign nativeType = "real_T"
%else
%assign nChunk = FixPt_NumChunks(actualBits)
%if nChunk > 1
%assign typeDenotation = "%<actualBits>m"
%else
%assign typeDenotation = "%<actualBits>"
%endif
%if dataTypeRec.IsSigned
%assign nativeType = "int%<typeDenotation>_T"
%else
%assign nativeType = "uint%<typeDenotation>_T"
%endif
%<FixPt_PoundDefineOverSizedDataType( dataTypeRec )>/
%endif
%endif
%assign dtRec = FixPt_GetDataTypeFromIndex(index)
%addtorecord dtRec DataTypeName dtName
%addtorecord dtRec ActualBits actualBits
%addtorecord dtRec NativeType nativeType
%endif
%endfunction
%function FixPt_DefineDataType(dataTypeRec) void
%assign dtName = "%<dataTypeRec.DataTypeName>"
%if ISFIELD(dataTypeRec, "Enum") && dataTypeRec.Enum == "SS_DOUBLE"
%assign actualBits = dataTypeRec.RequiredBits
%assign nativeType = "real_T"
%elseif ISFIELD(dataTypeRec, "Enum") && dataTypeRec.Enum == "SS_SINGLE"
%assign actualBits = dataTypeRec.RequiredBits
%assign nativeType = "real32_T"
%else
%assign actualBits = FixPt_RequiredBits_2_ActualBits(dataTypeRec.RequiredBits)
%if FixPt_ActualBits_TooBig(actualBits)
%if Accelerator
%openfile errTxt
This model can't be used with the Accelerator. The Data Type
%<dtName> requires %<dataTypeRec.RequiredBits> bits, but the maximum supported
with the Accelerator on this computer is %<IntegerSizes.LongNumBits> bits.
%closefile errTxt
%<LibReportFatalError(errTxt)>/
%else
%openfile errTxt
This model can't generate code for the intended TARGET C Compiler. The
Data Type %<dtName> requires %<dataTypeRec.RequiredBits> bits, but
the maximum supported by the TARGET C Compiler is %<IntegerSizes.LongNumBits>
bits.
%closefile errTxt
%<LibReportFatalError(errTxt)>/
%endif
%endif
%assign dtStart = dtName[0]+dtName[1]+dtName[2]
%if dtStart == "flt"
%assign nativeType = "real_T"
%else
%if dataTypeRec.IsSigned
%assign nativeType = "int%<actualBits>_T"
%else
%assign nativeType = "uint%<actualBits>_T"
%endif
%endif
%endif
%if !(ISFIELD(dataTypeRec,"DataTypeName"))
%addtorecord dataTypeRec DataTypeName dtName
%else
%<SETFIELD(dataTypeRec,"DataTypeName",dtName)>/
%endif
%if !(ISFIELD(dataTypeRec,"ActualBits"))
%addtorecord dataTypeRec ActualBits actualBits
%else
%<SETFIELD(dataTypeRec,"ActualBits",actualBits)>/
%endif
%if !(ISFIELD(dataTypeRec,"NativeType"))
%addtorecord dataTypeRec NativeType nativeType
%else
%<SETFIELD(dataTypeRec,"NativeType",nativeType)>/
%endif
%endfunction
%function FixPt_IndexStruct(width, ucv, lcv, idx) void
%if width == 1
%return ""
%endif
%if TYPE(ucv) != "String"
%assign ucvStr = "%<ucv>"
%else
%assign ucvStr = ucv
%endif
%if ucvStr != ""
%return "%<ucvStr>"
%elseif lcv != ""
%if idx != 0
%return "%<idx>+%<lcv>"
%else
%return "%<lcv>"
%endif
%else
%return "%<idx>"
%endif
%endfunction
%function FixPt_GetDataTypeFromIndex(dataTypeIdx) void
%assign curDT = ::CompiledModel.DataTypes.DataType[dataTypeIdx]
%return curDT
%endfunction
%function FixPt_GetAliasedThruDataTypeFromIndex(dataTypeIdx) void
%assign dataTypeIdxAliasThru = LibGetDataTypeIdAliasedThruToFromId(dataTypeIdx)
%assign curDT = ::CompiledModel.DataTypes.DataType[dataTypeIdxAliasThru]
%return curDT
%endfunction
%function FixPt_GetInputDataType(portIdx) void
%assign dataTypeIdx = LibGetDataTypeIdAliasedThruToFromId(LibBlockInputSignalDataTypeId(portIdx))
%assign curDT = FixPt_GetDataTypeFromIndex(dataTypeIdx)
%return curDT
%endfunction
%function FixPt_CopyDataTypeWithBoolReplace(aDT) void
%assign aIsBoolean = FixPt_DataTypeIsBoolean(aDT)
%if aIsBoolean
%assign localUint8DT = FixPt_GetDataTypeFromIndex(tSS_UINT8)
%copyrecord aTempDT localUint8DT
%else
%copyrecord aTempDT aDT
%endif
%return aTempDT
%endfunction
%function FixPt_GetOutputDataTypeId(portIdx) void
%assign dataTypeIdx = LibBlockOutputSignalDataTypeId(portIdx)
%return LibGetDataTypeIdAliasedThruToFromId(dataTypeIdx)
%endfunction
%function FixPt_GetOutputDataType(portIdx) void
%assign op = FcnGetOutputPortRecord(portIdx)
%if (IDNUM(op.SignalSrc[0])[0] == "F")
%return ""
%else
%assign dataTypeIdx = LibGetDataTypeIdAliasedThruToFromId(FixPt_GetOutputDataTypeId(portIdx))
%assign curDT = FixPt_GetDataTypeFromIndex(dataTypeIdx)
%return curDT
%endif
%endfunction
%function FixPt_GetParameterDataTypeId(dataTypeIdMat,iRow,iCol) void
%assign nRows = SIZE(dataTypeIdMat,0)
%assign nCols = SIZE(dataTypeIdMat,1)
%if (nRows == 1) && (nCols == 1)
%assign iRow = 0
%assign iCol = 0
%endif
%if (nRows <= iRow) && (nCols <= iCol)
%assign errTxt = "Specified row and/or column exceeds parameter size"
%exit Simulink Coder Fatal: %<errTxt>
%endif
%assign retRes = dataTypeIdMat[iRow][iCol]
%return retRes
%endfunction
%function FixPt_GetParameterDataType(dataTypeIdMat,iRow,iCol) void
%assign nRows = SIZE(dataTypeIdMat,0)
%assign nCols = SIZE(dataTypeIdMat,1)
%if (nRows > 1) || (nCols > 1)
%error "No matrix data types"
%endif
%assign dataTypeIdx = FixPt_GetParameterDataTypeId(dataTypeIdMat,iRow,iCol)
%assign curDT = FixPt_GetDataTypeFromIndex(dataTypeIdx)
%return curDT
%endfunction
%function FixPt_GetGroundValueOrNameFromDataTypeRec(rec, isComplex) void
%if ISFIELD(rec,"IdAliasedThruTo") && ISFIELD(rec,"IsFixedPoint")
%if FixPt_DataTypeIsMultiWord(rec) || isComplex
%assign grndValueOrName = SLibGetDtGroundName(rec.IdAliasedThruTo, isComplex, "")
%if isComplex
%<SLibSetDataTypeComplexGroundReqInMemory(rec.IdAliasedThruTo)>
%endif
%else
%assign grndValueOrName = SLibGetGroundValueFromId(rec.IdAliasedThruTo)
%endif
%else
%if isComplex
%<LibReportFatalError("The data type may not be complex.")>
%endif
%if FixPt_DataTypeIsFloat(rec)
%if FixPt_DataTypeIsSingle(rec)
%assign grndValueOrName = 0.0F
%else
%assign grndValueOrName = 0.0
%endif
%else
%if ISFIELD(rec,"Bias") && rec.Bias != 0.0
%<LibReportFatalError("The data type may not have bias.")>
%endif
%if FixPt_DataTypeIsUnsignedFixPt(rec)
%assign grndValueOrName = 0U
%else
%assign grndValueOrName = 0
%endif
%endif
%endif
%return grndValueOrName
%endfunction
%function FixPt_GetParameterDataTypeRec(param) void
%assign dataTypeIdx = param.OriginalDataTypeIdx
%assign curDT = FixPt_GetDataTypeFromIndex(dataTypeIdx)
%return curDT
%endfunction
%function FixPt_IsParameterDataSizeLargerThan32(param) void
%assign curDT = FixPt_GetParameterDataTypeRec(param)
%if fxpIsDataTypeFixPt(curDT) && curDT.RequiredBits > 32
%return 1
%else
%return 0
%endif
%endfunction
%function fxpIsDataTypeFixPt(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( dataType.NativeType != "real_T" && ...
dataType.NativeType != "real32_T" )
%endfunction
%function fxpIsDataTypeBoolean(dataType) void
%assign res = TLC_FALSE
%if ISFIELD(dataType,"Id")
%assign uDTAliasThru = FixPt_GetAliasedThruDataTypeFromIndex(dataType.Id)
%if uDTAliasThru.Id == tSS_BOOLEAN
%assign res = TLC_TRUE
%endif
%endif
%return res
%endfunction
%function FixPt_DataTypeIsDouble(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( dataType.NativeType == "real_T" )
%endfunction
%function FixPt_DataTypeIsSingle(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( dataType.NativeType == "real32_T" )
%endfunction
%function FixPt_DataTypeIsHalf(dataType) void
%assert TYPE(dataType) == "Scope"
%return ISFIELD(dataType,"NativeType") && (dataType.NativeType == "real16_T")
%endfunction
%function fxpIsDataTypeFixPtNonBool(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( fxpIsDataTypeFixPt(dataType ) && ...
!fxpIsDataTypeBoolean(dataType ) )
%endfunction
%function fxpIsDataTypeFloatOrSclDbl(dataType) void
%return ( FixPt_DataTypeIsDouble(dataType) || ...
FixPt_DataTypeIsSingle(dataType) || ...
FixPt_DataTypeIsHalf(dataType) )
%endfunction
%function fhpIsDataTypeNoScaleNoBits(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( ISEQUAL(dataType.RequiredBits, 0 ) && ...
ISEQUAL(dataType.FixedExp, 0 ) && ...
ISEQUAL(dataType.FracSlope, 1.0) && ...
ISEQUAL(dataType.Bias, 0.0) )
%endfunction
%function fxpIsDataTypeScaledDouble(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( fxpIsDataTypeFloatOrSclDbl( dataType) && ...
!fhpIsDataTypeNoScaleNoBits(dataType) )
%endfunction
%function FixPt_DataTypeIsFloat(dataType) void
%return ( fxpIsDataTypeFloatOrSclDbl( dataType) )
%endfunction
%function FixPt_DataTypeIsBoolean(dataType) void
%return fxpIsDataTypeBoolean(dataType)
%endfunction
%function FixPt_DataTypeIsMultiWord(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( dataType.IsFixedPoint && ...
dataType.RequiredBits > LargestIntegerNumBits && ...
!FixPt_DataTypeIsFloat(dataType) )
%endfunction
%function FixPt_DataTypeIsUnsignedFixPt(dataType) void
%assert TYPE(dataType) == "Scope"
%return ( !dataType.IsSigned && ...
fxpIsDataTypeFixPt(dataType) )
%endfunction
%function LibFixPointFormDataTypeName(isSigned,requiredBits,fixedExp) void
%if isSigned
%assign dataTypeName = "sfix%<requiredBits>_"
%else
%assign dataTypeName = "ufix%<requiredBits>_"
%endif
%if fixedExp < 0
%assign dataTypeName = dataTypeName + "En%<-fixedExp>"
%elseif fixedExp > 0
%assign dataTypeName = dataTypeName + "E%<fixedExp>"
%endif
%return dataTypeName
%endfunction
%function FixPt_IsZeroNumericOrString(in) void
%if ISEQUAL(0.0,in)
%return TLC_TRUE
%elseif TYPE(in) == "String"
%if in[0] != "("
%assign in = "(" + in + ")"
%endif
%if in[0] == "(" && in[1] =="("
%assign strLen = SIZE(in, 1)
%if in[strLen - 1] == ")" && in[strLen - 2] == ")"
%assign in[0] = " "
%assign in[strLen - 1] =" "
%assign in = FEVAL("strtrim", in)
%endif
%endif
%if ISEQUAL("(0)",in)
%return TLC_TRUE
%elseif in[1] == "0"
%if in[2] == "."
%return ISEQUAL("(0.0)", in) || ...
ISEQUAL("(0.0F)", in) || ...
ISEQUAL("(0.0f)", in)
%elseif in[2] == "U"
%return ISEQUAL("(0U)", in) || ...
ISEQUAL("(0UL)", in) || ...
ISEQUAL("(0Ul)", in)
%elseif in[2] == "L"
%return ISEQUAL("(0L)", in) || ...
ISEQUAL("(0LU)", in) || ...
ISEQUAL("(0Lu)", in)
%elseif in[2] == "u"
%return ISEQUAL("(0u)", in) || ...
ISEQUAL("(0uL)", in) || ...
ISEQUAL("(0ul)", in)
%elseif in[2] == "l"
%return ISEQUAL("(0l)", in) || ...
ISEQUAL("(0lU)", in) || ...
ISEQUAL("(0lu)", in)
%elseif in[2] == "x"
%return ISEQUAL("(0x0)", in) || ...
ISEQUAL("(0x00)", in) || ...
ISEQUAL("(0x0000)", in) || ...
ISEQUAL("(0x00000000)", in)
%else
%return TLC_FALSE
%endif
%else
%return TLC_FALSE
%endif
%else
%return TLC_FALSE
%endif
%endfunction
%function FixPt_DtConvertBetween(dTypeOut,dTypeIn,inLabel,options,outLabel) Output
%assign roundMode = "Nearest"
%assign satMode = "Saturate"
%if TYPE(options) == "Scope"
%if ISFIELD(options,"roundMode")
%assign roundMode = options.roundMode
%endif
%if ISFIELD(options,"satMode")
%assign satMode = options.satMode
%endif
%endif
%assign inDT = FixPt_GetDataTypeFromIndex(dTypeIn )
%assign outDT = FixPt_GetDataTypeFromIndex(dTypeOut)
%<FixPt_Fix2FixAlwaysOutput(outLabel,outDT,inLabel,inDT,roundMode,satMode)>/
%return 1
%endfunction
%function FixPt_DtIsPositive(dTypeIn,inLabel,options,outLabel) Output
%assign inDT = FixPt_GetDataTypeFromIndex(dTypeIn)
%if !LibIsDataTypeMultiWordFixpt(dTypeIn)
%if inDT.Bias == 0.0
%assign storedIntegerZero = "0"
%else
%assign storedIntegerZero = STRING(FixPt_Dbl2StoredInt(0.0,inDT))
%endif
%<outLabel> = ( (%<inLabel>) > (%<storedIntegerZero>) );
%return 1
%else
%<boolDT.NativeType> %<tmpCmp1>;
%<FixPt_MultiWordCompGT(tmpCmp1, boolDT, inLabel, inDT, storedIntegerZero, inDT, "Simplest", "Saturate")>
%<outLabel> = %<tmpCmp1>;
%endif
%endfunction
%function FixPt_DtSign(dTypeIn,inLabel,options,outLabel) Output
%assign inDT = FixPt_GetDataTypeFromIndex(dTypeIn)
%if !LibIsDataTypeMultiWordFixpt(dTypeIn)
%if inDT.Bias == 0.0
%assign storedIntegerZero = "0"
%else
%assign storedIntegerZero = STRING(FixPt_Dbl2StoredInt(0.0,inDT))
%endif
%if !(inDT.IsSigned) && ( inDT.Bias >= 0.0 )
%<outLabel> = ( (%<inLabel>) > (%<storedIntegerZero>) );
%else
%<outLabel> = ( ((%<inLabel>)<(%<storedIntegerZero>)) ? (-1) : ((%<inLabel>)>(%<storedIntegerZero>)) );
%endif
%return 1
%else
%assign boolDT = DataTypes.DataType[tSS_BOOLEAN]
%assign storedIntegerZero = FixPt_GetGroundValueOrNameFromDataTypeRec(inDT, TLC_FALSE)
%assign tmpCmp1 = "tmpCmp1"
%assign tmpCmp2 = "tmpCmp2"
{
%if !(inDT.IsSigned) && ( inDT.Bias >= 0.0 )
%<boolDT.NativeType> %<tmpCmp1>;
%<FixPt_MultiWordCompGT(tmpCmp1, boolDT, inLabel, inDT, storedIntegerZero, inDT, "Simplest", "Saturate")>
%<outLabel> = %<tmpCmp1>;
%else
%<boolDT.NativeType> %<tmpCmp1>, %<tmpCmp2>;
%<FixPt_MultiWordCompGT(tmpCmp1, boolDT, inLabel, inDT, storedIntegerZero, inDT, "Simplest", "Saturate")>
%<FixPt_MultiWordCompLT(tmpCmp2, boolDT, inLabel, inDT, storedIntegerZero, inDT, "Simplest", "Saturate")>
%<outLabel> = ( (%<tmpCmp2>) ? (-1) : (%<tmpCmp1>) );
%endif
}
%return 1
%endif
%endfunction
%function FixPt_helperUtilityNameAppendDT(yDT) void
%if FixPt_DataTypeIsFloat(yDT)
%assign utilityName = yDT.NativeType
%elseif FixPt_DataTypeIsBoolean(yDT)
%assign utilityName = "Bool"
%else
%if yDT.IsSigned
%assign utilityName = "S"
%else
%assign utilityName = "U"
%endif
%assign utilityName = utilityName + STRING(yDT.RequiredBits)
%endif
%return utilityName
%endfunction
%function FixPt_UtilityNameAppendDT(utilityName,yDT) void
%assign utilityName = utilityName + "_" + FixPt_helperUtilityNameAppendDT(yDT)
%return utilityName
%endfunction
%function FixPt_UtilityMakeName(name) void
%if CodeFormat == "S-Function"
%assign name = ::CompiledModel.Name + "_"+name
%endif
%return name
%endfunction
%function FixPt_LoadFixPtUtils() void
%if SLibIsValidCoderContext()
%assign rtwCtx = ::CompiledModel.RTWContext
%assign dummy = FEVAL("rtwprivate", "retrieveMultiWordUtilitiesAndFunctions", "%<::CompiledModel.MasterSharedCodeManagerFile>", 0, "")
%if FEVAL("rtwprivate", "rtwcgtlc", "WriteFixptUtilsFile", rtwCtx)
%include "%<LibGetModelName()>_fixpt_util.tlc"
%<CGIRBlockRegisterFixPointFunctions()>
%assign nMaxMWBits = FEVAL("rtwprivate", "rtwcgtlc", ...
"fixPtWordSizeUsage", rtwCtx)
%<DeclareFixedPointWordSizeUsage(nMaxMWBits)>
%else
%error "Failure to write the fixpoint utility TLC file"
%endif
%endif
%endfunction
%function FixPt_UnaryOp(unaryOp, yLabel, yDT, uLabel, uDT, ...
roundMode, satMode) void
%if SLibIsValidCoderContext()
%assign rtwCtx = ::CompiledModel.RTWContext
%assign retVal = FEVAL("rtwprivate", "rtwcgtlc", unaryOp, rtwCtx, ...
yLabel, yDT, uLabel, uDT, roundMode, satMode)
%assign headers = retVal[3]
%foreach idx = SIZE(headers, 1)
%<FcnTrackHeaderFileUsage(headers[idx], TLC_FALSE, TLC_FALSE)>
%endforeach
%return retVal
%else
%error "This fixpoint operator is not available if the TLC command is invoked offline"
%endif
%endfunction
%function FixPt_BinaryOp(binaryOp, yLabel, yDT, ...
u1Label, u1DT, u2Label, u2DT, roundMode, satMode) void
%if SLibIsValidCoderContext()
%assign rtwCtx = ::CompiledModel.RTWContext
%assign retVal = FEVAL("rtwprivate", "rtwcgtlc", binaryOp, rtwCtx, ...
yLabel, yDT, u1Label, u1DT, u2Label, u2DT, roundMode, satMode)
%assign headers = retVal[3]
%foreach idx = SIZE(headers, 1)
%<FcnTrackHeaderFileUsage(headers[idx], TLC_FALSE, TLC_FALSE)>
%endforeach
%return retVal
%else
%error "This fixpoint operator is not available if the TLC command is invoked offline"
%endif
%endfunction
%function Fixpt_HalfPrecisionConvertBetween(outDType,inDType,inLabel,options,outLabel) Output
%assert LibIsHalfDataType(inDType)
%assign outDTypeName = LibGetDataTypeNameFromId(outDType)
%<outLabel> = (%<outDTypeName>) halfToFloat(%<inLabel>);
%return 1
%endfunction
%function Fixpt_HalfPrecisionIsPositive(inDType, inLabel, options, outLabel) Output
%assert LibIsHalfDataType(inDType)
%assign zero = SLibGetFormattedValueFromId(tSS_SINGLE, 0)
%<outLabel> = halfToFloat(%<inLabel>) > %<zero>;
%return 1
%endfunction
%function Fixpt_HalfPrecisionSign(inDType, inLabel, options, outLabel) Output
%assert LibIsHalfDataType(inDType)
%assign zero = SLibGetFormattedValueFromId(tSS_SINGLE, 0)
if (halfToFloat(%<inLabel>) > %<zero>) {
%<outLabel> = 1;
} else if (halfToFloat(%<inLabel>) < %<zero>) {
%<outLabel> = -1;
} else {
%<outLabel> = 0;
}
%return 1
%endfunction
%assign searchTrivial = 0
%assign searchPow2 = 1
%assign searchEven = 2
%assign searchUneven = 3
%assign interpolateTrivial = 0
%assign interpolateBigProduct = 1
%assign interpolateLambda = 2
%assign interpolatePow2 = 3
%include "fixptmul.tlc"
%include "fixptdiv.tlc"
%include "fixptcast.tlc"
%include "fixptadd.tlc"
%include "fixpterror.tlc"
%include "fixpt_tunable_param_cast.tlc"
%include "fixpt_code_gen_time_calc.tlc"
%include "fixpt_preprocessor_guards.tlc"
%include "fixptmultiword.tlc"
%include "fixptcomment.tlc"
%endif