Technical data
3
Writing Target Language Files
3-16
%function BlockInstanceSetup(block, system) void
%% Rename S-function parameter so that the TLC and
%% generated code is more readable (P1 --> Gain)
%<LibRenameParameter(block, P1, "Gain")>
%% Define the RWork vector to make the code more
%% readable, and to allow the RWork to be rolled
%% inside the %roll construct.
%<LibDefineRWork(block, "PrevU", LibDataInputPortWidth(0))>
%endfunction
Now you can reference P1 as PrevU in the Target Language Compiler. For
example,
%function Outputs(block, system) Output
%assign PrevU = LibBlockParameter(PrevU, ucv, lcv, sigIdx)
.
.
.
%endfunction
And, the generated code produces "rtP.foo.PrevU" instead of "rtP.foo.P1".
BlockTypeSetup(block, system)
BlockTypeSetup executes once per block type before code generation begins.
That is, if there are 10 Lookup Table blocks in the model, the
BlockTypeSetup
function in
look_up.tlc is only called one time. Use this function to perform
general work for all blocks of a given type.
See Chapter 4, “Target Language Compiler Function Library Reference,” for a
list of relevant functions to call from inside this block function. See
look_up.tlc for an example of the BlockTypeSetup function.
Syntax:
BlockTypeSetup(block, system) void
block
= Reference to a Simulink block
system = Reference to a nonvirtual Simulink subsystem