%% $RCSfile: sdspsreg.tlc,v $ %% $Revision: 1.4 $ %% $Date: 1999/03/24 14:56:32 $ %% %% Copyright (c) 1995-1999 The MathWorks, Inc. All Rights Reserved. %% %% Abstract: Shift contents of a memory register and store %% input samples into start of register. %implements sdspsreg "C" %% Function: InitializeConditions ============================================= %% %function InitializeConditions(block, system) Output /* DSP Blockset Shift Register (%) - % */ %% %assign INPORT = 0 %assign OUTPORT = 0 %% %assign CONTIG = IsInputPortContiguous(block,INPORT) %% We do not support discontiguous inputs %if (!CONTIG) % %endif %% %assign numIC = SIZE(SFcnParamSettings.IC, 1) %assign cplx_ic = TYPE(SFcnParamSettings.IC[0]) == "Complex" %assign dtype_ic = cplx_ic ? "creal_T" : "real_T" %% %assign cplx_in = (LibBlockInputSignalIsComplex(INPORT) != 0) %assign dtype_in = cplx_in ? "creal_T" : "real_T" %assign nChans = CAST("Number",LibDataInputPortWidth(INPORT)) %assign regsiz = CAST("Number", SFcnParamSettings.RegSiz) %assign reglen = nChans * regsiz %% { % *outBuf = %; %if (numIC <= 1) %% %% Scalar IC: %% %assign IC_re = (numIC == 0) ? 0.0 : % %if (cplx_in) %assign IC_im = ((numIC == 0) | (!cplx_ic)) ? 0.0 : % %endif %% /* Scalar IC */ %if reglen > 1 int_T i; for (i=0; i++ < %; ) { %endif %if !cplx_in *outBuf++ = %<(numIC == 0) ? 0.0 : "%">; %else outBuf->re = %; (outBuf++)->im = %; %endif %if reglen > 1 } %endif %% %else %% %% Vector and Matrix ICs %% %% Write out ICs in formatted, vector form %if (cplx_ic) %assign ic_str = "" %foreach Idx = numIC-1 %if ((Idx != 0) & ((Idx%10) == 0)) %assign ic_str = ic_str + "{%,%},\n" %else %assign ic_str = ic_str + "{%,%}," %endif %endforeach %assign ic_str = ic_str + "{%,%}" const creal_T ic[%] = {%}; %% %elseif (cplx_in) %assign ic_str = "" %foreach Idx = numIC-1 %if ((Idx != 0) & ((Idx%10) == 0)) %assign ic_str = ic_str + "{%,0.0},\n" %else %assign ic_str = ic_str + "{%,0.0}," %endif %endforeach %assign ic_str = ic_str + "{%,0.0}" const creal_T ic[%] = {%}; %% %else %assign ic_str = "" %foreach Idx = numIC-1 %if ((Idx != 0) & ((Idx%10) == 0)) %assign ic_str = ic_str + "%,\n" %else %assign ic_str = ic_str + "%," %endif %endforeach %assign ic_str = ic_str + "%" const real_T ic[%] = {%}; %% %endif %% %% Copy ICs to buffer: %% %if (numIC == regsiz) /* Vector IC */ %if nChans != 1 int_T i; for (i=0; i++ < %; ) { %endif memcpy(outBuf, ic, %*sizeof(%)); outBuf += %; %if nChans != 1 } %endif %else /* Matrix IC */ memcpy(outBuf, ic, %*sizeof(%)); %endif %endif } %endfunction %% InitializeConditions %% Function: Outputs ========================================================== %% %function Outputs(block, system) Output /* DSP Blockset Shift Register(%) - % */ %% %assign INPORT = 0 %assign OUTPORT = 0 %% %assign cplx = (LibBlockInputSignalIsComplex(INPORT) != 0) %assign dtype = cplx ? "creal_T" : "real_T" %assign nChans = CAST("Number",LibDataInputPortWidth(INPORT)) %assign regsiz = CAST("Number", SFcnParamSettings.RegSiz) %assign reglen = nChans * regsiz %% { % *outBuf = %; /* Move ALL samples up by one */ % *p0 = outBuf; % *p1 = p0 + 1; int_T i; for(i=0; i++ < %; ) { *p0++ = *p1++; } /* Place input in last element of register for each channel*/ { % *p0 = outBuf-1; % *u = %; %if nChans != 1 int_T i; for(i=0; i++ < %; ) { %endif *(p0+=%) = *u++; %if nChans != 1 } %endif } /* Copy contents of buffer to the output */ { % *y = %; memcpy((char_T *)y, (char_T *)outBuf, %*sizeof(%)); } } %endfunction %% Outputs %% [EOF] sdspsreg.tlc