%% %% Function-Call Code Generation for the DSP Blockset %% %% dsp_blkutils.tlc - Utility functions used in constructing %% individual block TLC files. %% %% Author: D. Orofino %% Copyright (c) 1995-2000 The MathWorks, Inc. %% $Revision: 1.7 $ % $Date: 2000/05/09 19:16:57 $ %include "dsp_iolists.tlc" %% Function: DSPInitialize ==================================================== %% Abstract: %% Register block instance with the database. Must be %% called during BlockInstanceSetup from every block TLC %% function participating in function-call optimization. %% %function DSPInitialize(block) void %% Add the port parameters to the block since they are %% required code-gen options: %% %assign cplx = GetPortComplexities(block) %% a vector, one per port %assign nSamps = GetAllPort_nSamps(block) %% also a vector, one per port %assign nChans = GetAllPort_nChans(block) %% also a vector, one per port %assign SharedIOBuffers = (LibBlockInputSignalBufferDstPort(0) == 0) %% a scalar! %assign block = block + cplx + nSamps + nChans + SharedIOBuffers %% Create CGFcnArg records for each code-gen option: %% % %% Register the block with the M-file database manager: %% %assign isFirst = FEVAL("dsp_cgfcdb","begin",block) %if isFirst %' options file.")> %endif %endfunction %% DSPInitialize %% Function: DSPTerminate ===================================================== %% Abstract: %% Remove block instance from database. Must be %% during Terminate from every block TLC function %% participating in function-call optimization. %% %function DSPTerminate(block) void %assign lastInstance = FEVAL("dsp_cgfcdb","end",block) %if lastInstance %% Flush function-call code cache: % %% Flush S-Function parameter cache: % %endif %endfunction %% DSPTerminate %% Function: DSPAddExternFcnDeclaration ===================================================== %% Abstract: %% Make the necessary external function declarations for dsp blocks. %% %function DSPAddExternFcnDeclaration(fcn) void %% %switch fcn %case "dspfft" %if !EXISTS("dspfft_extern") %assign ::dspfft_extern = 1 %openfile buffer /* DSP Blockset FFT function */ extern void dspfft(const int_T n, creal_T *y); %closefile buffer %% % %% %% Needed to keep prototype around in case model_dsp.c is genreated. % %% %endif %break %default %error("Unhandled external function declaration") %break %endswitch %endfunction %% DSPAddExternFcnDeclaration %% Function: MergeComplexCode ================================================= %% Abstract: %% Return the user preference for combining real/complex code %% (e.g., should both the real and complex codes to be placed %% into one code body, or split into multiple functions?) %% %function MergeComplexCode(block) void %return block.CGFcnArgs[0].value %% Cplx is hard coded to be index 0 %endfunction %% MergeComplexCode %% Function: MergeWidthCode =================================================== %% Abstract: %% Return the user preference for combining variable port width code %% %function MergeWidthCode(block) void %return block.CGFcnArgs[1].value %% nSamps is hard coded to be index 1 %endfunction %% MergeWidthCode %% Function: MergeChanCode =================================================== %% Abstract: %% Return the user preference for combining variable port chan code %% %function MergeChanCode(block) void %return block.CGFcnArgs[2].value %% nChans is hard coded to be index 2 %endfunction %% MergeChanCode %% Function: ErrorIfMergeSharedIOBuffers ======================================= %% Abstract: %% Generate an error if we ever attempt to merge function calls %% for shared and non-shared IO buffers. It does not appear to be %% practical to support this situation %% %function ErrorIfMergeSharedIOBuffers(block) void %if block.CGFcnArgs[2].value %error Cannot merge function calls for both shared and non-shared I/O buffers. %endif %endfunction %% ErrorIfMergeSharedIOBuffers %% Function: DSPDeclareAllInlinedVars ========================================= %% Abstract: %% Generate declarations and values of all inlined variables. %% (i.e., those variables that are not being passed through %% a function argument list). %% %% Inlined code can thus rely on the same variables to be %% present and defined as if the code was contained inside %% a function that defined *all* of the variables. %% %% NOTE: If all of these declarations are not required in the %% inlined code, the individual component functions may %% be called as needed. %% %function DSPDeclareAllInlinedVars(block, xArgs) Output %% % \ % \ % %% %endfunction %% DSPDeclareAllInlinedVars %% [EOF] dsp_blkutils.tlc