How To create TLC file for S-Function

3 views (last 30 days)
VIKAS
VIKAS on 4 Apr 2017
Answered: Anshuman on 4 Dec 2024
Hello Everyone I Have a *.C file and using the command "mex -g *.C", I am able to generate the *.mexw64 file to be used in S-Function. I need the *.TLC file too for the code generation. Could you please help me how to generate the *.TLC file either using the *.C file or *.mexw64.
Thanks in advance... Vikas

Answers (1)

Anshuman
Anshuman on 4 Dec 2024
Hello Vikas,
There isn't any automatic way to generate a TLC file from a '.C' file or a '.mexw64' file directly. Instead, you need to write the TLC file manually. You can start by creating a new text file with the '.tlc' extension. Name it the same as your S-Function (e.g., myFunction.tlc).
A TLC file typically contains several key sections:
  • Header: Includes metadata about the TLC file.
  • Block Outputs: Describes how to compute the outputs of the S-Function.
  • Block Parameters: Describes how to handle parameters.
  • Block States: Describes state handling if your S-Function maintains state.
  • Custom Code: Any custom code snippets needed for code generation.
Here's a basic TLC file template that you can refer and modify as per your requirements:
%% File: myFunction.tlc
% The header section
%function myFunction(block, system)
%assign blockName = block.BlockType
%assign blockPath = block.BlockPath
%function Outputs(block, system)
% Output computations
%endfunction
%function Derivatives(block, system)
% Derivative computations
%endfunction
%function Update(block, system)
% Update computations
%endfunction
%function Terminate(block, system)
% Termination actions
%endfunction
These functions like 'Outputs', 'Derivatives', 'Update', 'Terminate' are standard functions and needs to be there in every TLC file.
Hope it helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!