%% %% Function-Call Code Generation for the DSP Blockset %% %% dsp_mdlsections.tlc - Generates "mdl*" block functions, %% including mdlOutputs, mdlUpdate, mdlStart, etc. %% %% Author: D. Orofino %% Copyright (c) 1995-1999 The MathWorks, Inc. All Rights Reserved. %% $Revision: 1.8 $ % $Date: 1999/09/10 15:53:06 $ %include "dsp_cgargs.tlc" %% Function: GenerateMdlCode ============================================== %% Abstract: %% Generate code that is placed in the mdlOutputs section. %% %function GenerateMdlCode(block, system, mdlSection, xArgs) Output %% % %% Generate list of arguments for functions and add them to block record % % %% %if !CGInlineFcn % %else % %endif %% %endfunction %% GenerateMdlCode %% Function: DSPCreateMdlFcnIfNeeded ============================================= %% Abstract: %% Generate code for function instance if there is more than one block %% instance with a set of registered parameters identical to this block, %% *and* this block is the first such registered block: %% %function DSPCreateMdlFcnIfNeeded(block, system, mdlSection, xArgs) void %if Need2CreateFcn_cache(block) %% Create function: %% %openfile buffer % % %closefile buffer % %% Create extern reference: %% %openfile buffer extern %; %closefile buffer % %endif %endfunction %% DSPCreateMdlFcnIfNeeded %% Function: CallFcnFromMdlCode =========================================== %% Abstract: %% Generate call to function. %% %function CallFcnFromMdlCode(block,system,mdlSection, xArgs) Output /* DSP Blockset % (%) - % */ %% %% Manage commas between argument lists %% %assign args1 = DSPArgListForFcnCall(block,system, xArgs) %assign args2 = CGArgListForFcnCall(block,system, xArgs) %assign args3 = MultiRateArgListForFcnCall(block,system) %% %assign c1 = WHITE_SPACE(args1) ? "" : ",\n" %assign c2 = (WHITE_SPACE(args2) || WHITE_SPACE(args3) ) ? "" : ",\n" %assign argList = args1 + c1 + args2 + c2 + args3 %% %(%);\ %% %endfunction %% CallFcnFromMdlCode %% Function: MdlFcnCallProto ============================================== %% Abstract: %% Generate function prototype of function-call interface. %% %function MdlFcnCallProto(block, system, mdlSection, xArgs) Output %% %% Manage commas between argument lists %% %assign args1 = DSPArgListForFcnCallProto(block,system, xArgs) %assign args2 = CGArgListForFcnCallProto(block,system, xArgs) %assign args3 = MultiRateArgListForFcnCallProto(block,system) %% %assign c1 = WHITE_SPACE(args1) ? "" : ",\n" %assign c2 = (WHITE_SPACE(args2) || WHITE_SPACE(args3) ) ? "" : ",\n" %assign argList = args1 + c1 + args2 + c2 + args3 %% void %(%)\ %% %endfunction %% MdlFcnCallProto %% Function: CoreMdlCode ========================================== %% Abstract: %% This is conceptually equivalent to executing: %% %Code(block,system)> %% but that of course does not work! %% %function CoreMdlCode(block,system,mdlSection, xArgs) Output %% %% mdlSection is a string containing the name of the %% Core***Code function, such as: %% "Outputs", "Update", "Start", etc. %% %% { %% The var declaration needs to be scoped with { } % %% %% %assign sfcnName = block.ParamSettings.FunctionName %assign func = "Core" + mdlSection + "Code" %if !GENERATE_TYPE_FUNCTION_EXISTS(block, func, sfcnName) %assign msg = "Could not find function '%' in TLC file for " +\ "S-Function '%'." %exit % %endif %% %\ } %% %endfunction %% CoreMdlCode %% Function: InlineBodyInMdlCode ========================================== %% Abstract: %% Generate content of the function for inline constructions. %% %function InlineBodyInMdlCode(block,system,mdlSection, xArgs) Output %% When inlining, make every variable explicit in the code, %% i.e., don't pass any variables through a function interface %% (because there is no function interface!) %% /* Block: % */ % % %% %endfunction %% InlineBodyInOutputsCode %% Function: MdlFcnCallBody ====================================================== %% Abstract: %% Generate content of the function for function call constructions. %% %function MdlFcnCallBody(block,system,mdlSection, xArgs) Output %% % %% %endfunction %% OutputsFcnCallBody %% Function: GetMdlFcnCallName ============================================ %% Abstract: %% Generate function call name %% %% This must generate a unique name, given the %% parameters of the non-inlined function call. %% Based on descriptive name of function and parameters. %% %function GetMdlFcnCallName(block,system,mdlSection) void %assign sfcnName = block.ParamSettings.FunctionName %% Serialization of names: %% %assign FcnCallName = sfcnName + "_" + mdlSection \ + "_" + GetFcnCallSerialNum(block) %return FcnCallName %endfunction %% GetMdlFcnCallName %% Function: CoreMdlCodeComment %% Abstract: %% Generate standard comment for core outputs code sections. %% %function CoreMdlCodeComment(block,mdlSection) Output %% Construct comment describing this code body /* * DSP Blockset % (%) * % Function %\ %\ */ %endfunction %% CoreMdlCodeComment %% [EOF] dsp_mdlsections.tlc