%if EXISTS("_DSPLIB_") == 0
%assign _DSPLIB_ = 1
%assign ::MATLAB_ROOT_TMP = FEVAL("matlabroot")
%assign ::MATLAB_ROOT = FEVAL("strrep", ::MATLAB_ROOT_TMP, "//", "/")
%openfile buffer
#include "dsp_rt.h" /* DSP System Toolbox general run time support functions */
%closefile buffer
%<LibCacheDefine(buffer)>
%include FEVAL("matlabroot")+"/toolbox/shared/dsp/vision/matlab/utilities/mex/tlc_c/spcfixptlib.tlc"
codegoeshere>
codegoeshere>
%function JustCreatedCompiledModelRecord(recordName) void
%assign fullRecordName = "::CompiledModel." + recordName
%if !EXISTS("%<fullRecordName>")
%assign retval = 1
%assign %<recordName> = 1
%assign ::CompiledModel = ::CompiledModel + %<recordName>
%undef %<recordName>
%else
%assign retval = 0
%endif
%return retval
%endfunction
%function (block, libName) void
%assign recName = libName + "_include"
%if JustCreatedCompiledModelRecord(recName)
%openfile buffer
%assign fileDotH = libName + ".h"
#include "%<fileDotH>" /* DSP System Toolbox run time support library */
%closefile buffer
%<LibCacheDefine(buffer)>
%endif
%endfunction
%function getModelName() void
%if EXISTS(::CompiledModel.OrigName)
%assign modelName = ::CompiledModel.OrigName
%else
%assign modelName = CompiledModel.Name
%endif
%return modelName
%endfunction
%function ModifyBuildInfo(product, path, hdrFiles, srcFiles, nonBuildFiles, linkFlags) void
%assign foobar = FEVAL("dspModifyBuildInfo", "%<getModelName()>", "%<product>", "%<path>", "%<hdrFiles>", "%<srcFiles>", "%<nonBuildFiles>", "%<linkFlags>")
%endfunction
%function MAX(a,b)
%return ((a > b) ? a : b)
%endfunction
%function MIN(a,b)
%return ((a < b) ? a : b)
%endfunction
%function (sfcnTID) Output
%<LibTaskComment(LibGetGlobalTIDFromLocalSFcnTID(sfcnTID))>/
%endfunction
%function LibBlockCopyInputsToOutputs(INPORT, OUTPORT) Output
%assign inDT = FixPt_GetInputDataType(INPORT)
%assign DTYPE_ID = LibBlockInputSignalDataTypeId(INPORT)
%assign DTYPE_STR = LibBlockInputSignalDataTypeName(INPORT,"%<tRealPart>")
%assign OUT_COMPLEX = LibBlockOutputSignalIsComplex(OUTPORT)
%assign INP_COMPLEX = LibBlockInputSignalIsComplex(INPORT)
%assign INP_WIDTH = LibBlockInputSignalWidth(INPORT)
%assign NUM_REAL_INP_ELEMENTS = INP_WIDTH * (1 + INP_COMPLEX)
%assign outputDTSameAsInput = (DTYPE_ID == LibBlockOutputSignalDataTypeId(OUTPORT))
%if (outputDTSameAsInput)
%if (INP_COMPLEX == OUT_COMPLEX)
%if INP_WIDTH > 1
memcpy( %<LibBlockOutputSignalAddr(OUTPORT, "", "", 0)>, /
%<LibBlockInputSignalAddr( INPORT, "", "", 0)>, /
(%<NUM_REAL_INP_ELEMENTS> * sizeof(%<DTYPE_STR>)) );
%else
%<LibBlockOutputSignal(OUTPORT, "", "", 0)> = %<LibBlockInputSignal( INPORT, "", "", 0)>;
%endif
%else
%if INP_COMPLEX
%if INP_WIDTH > 1
{
const byte_T *uTemp = (const byte_T *)%<LibBlockInputSignalAddr( INPORT, "", "", 0)>;
byte_T *yTemp = (byte_T *)%<LibBlockOutputSignalAddr(OUTPORT, "", "", 0)>;
int_T inpIdx = %<INP_WIDTH>;
while (inpIdx-- > 0) {
memcpy(yTemp, uTemp, sizeof(%<DTYPE_STR>));
yTemp += sizeof(%<DTYPE_STR>);
uTemp += 2*sizeof(%<DTYPE_STR>); /* Skip imaginary part */
}
}
%else
%<LibBlockOutputSignal(OUTPORT, "", "", 0)> = %<LibBlockInputSignal( INPORT, "", "", "%<tRealPart>0")>;
%endif
%else
%if INP_WIDTH > 1
{
%if LibIsDataTypeMultiWordFixpt(DTYPE_ID)
const %<DTYPE_STR> zero = %<FixPt_GetGroundValueOrNameFromDataTypeRec(FixPt_GetOutputDataType(OUTPORT), TLC_FALSE)>;
%else
const %<DTYPE_STR> zero = %<SLibGetGroundValueFromId(DTYPE_ID)>;
%endif
const byte_T *uTemp = (const byte_T *)%<LibBlockInputSignalAddr( INPORT, "", "", 0)>;
byte_T *yTemp = (byte_T *)%<LibBlockOutputSignalAddr(OUTPORT, "", "", 0)>;
int_T inpIdx = %<INP_WIDTH>;
while (inpIdx-- > 0) {
memcpy(yTemp, uTemp, sizeof(%<DTYPE_STR>));
uTemp += sizeof(%<DTYPE_STR>);
yTemp += sizeof(%<DTYPE_STR>);
memcpy(yTemp, &zero, sizeof(%<DTYPE_STR>));
yTemp += sizeof(%<DTYPE_STR>);
}
}
%else
%<LibBlockOutputSignal(OUTPORT, "", "", "%<tRealPart>0")> = %<LibBlockInputSignal( INPORT, "", "", 0)>;
%if LibIsDataTypeMultiWordFixpt(DTYPE_ID)
%<LibBlockOutputSignal(OUTPORT, "", "", "%<tImagPart>0")> = %<FixPt_GetGroundValueOrNameFromDataTypeRec(FixPt_GetOutputDataType(OUTPORT), TLC_FALSE)>;
%else
%<LibBlockOutputSignal(OUTPORT, "", "", "%<tImagPart>0")> = %<SLibGetGroundValueFromId(DTYPE_ID)>;
%endif
%endif
%endif
%endif
%else
%assign outLabel_re = LibBlockOutputSignal(OUTPORT, "idxSPL", "", "%<tRealPart>0")
%assign outLabel_im = LibBlockOutputSignal(OUTPORT, "idxSPL", "", "%<tImagPart>0")
%assign inLabel_re = LibBlockInputSignal( INPORT, "idxSPL", "", "%<tRealPart>0")
%assign inLabel_im = LibBlockInputSignal( INPORT, "idxSPL", "", "%<tImagPart>0")
%assign outDT = FixPt_GetOutputDataType(OUTPORT)
{
int idxSPL=0;
for (; idxSPL<%<INP_WIDTH>; idxSPL++) {
%<FixPt_Fix2FixAlwaysOutput(outLabel_re, outDT, inLabel_re, inDT, FixPtRoundingMode, FixPtSaturationMode)>/
%if OUT_COMPLEX
%if INP_COMPLEX
%<FixPt_Fix2FixAlwaysOutput(outLabel_im, outDT, inLabel_im, inDT, FixPtRoundingMode, FixPtSaturationMode)>/
%else
%<outLabel_im> = %<FixPt_GetGroundValueOrNameFromDataTypeRec(outDT, TLC_FALSE)>;
%endif
%else
%if INP_COMPLEX
/* Discarding imaginary part of input */
%endif
%endif
}
}
%endif
%endfunction
%endif