Creating a TLC file for S-function
33 views (last 30 days)
Show older comments
I have simulink model and inside this simulink model, there is a ''S-Function'' block which reads .m (matlab file). I want to build this simulink model in OPAL RT (real time software) but i get the following error:
__________________________________________________________________________________________________________________
??? Error using tlc_new
Error: File: C:\Program Files\MATLAB\R2019b\rtw\c\tlc\lib\utillib.tlc Line: 1626 Column: 8
%exit directive: Simulink Coder Fatal in block:
"mg_5vocs_2019b_17_07_1_sm_calculation/SM_Calculation/VOC_10/V control/P_sync_8/S-Function", block type "S-Function": MFile S-functions without a corresponding TLC file are not supported.
You can inline your S-function (dis_consensus_68) by creating a TLC file for it.
You can also remap your S-function to C by creating a corresponding C Mex source file and a dis_consensus_68.tlc file in the same directory as the MFile S-function which contains (on the first line):
%% CallAsCMexLevel1
or
%% CallAsCMexLevel2
__________________________________________________________________________________________________________________
I have no idea how to creat s TLC file from the S-function. I do not have good programming skills. Can anyone please help me with this issue? I would appreciate it.
0 Comments
Answers (1)
Anavi Somani
on 18 Jul 2023
Hi Saba,
Go through this link once and try attempting it again, this document might help.
7 Comments
Anavi Somani
on 18 Jul 2023
To create a TLC file for the provided code, you can follow these steps:
1. Open a text editor or an Integrated Development Environment (IDE) that supports TLC file creation.
2. Create a new file and save it with a ".tlc" extension, such as "dis_consensus.tlc".
3. In the TLC file, you need to define the target-specific code that corresponds to the MATLAB code provided. The TLC file is responsible for generating code specific to a target language (e.g., C, C++).
4. Start by defining the TLC file header, which typically includes information about the target language, version, and other relevant details.
5. Define the entry point for the generated code by using the `entry` keyword, followed by the name of the generated function. In this case, the entry point would be the `dis_consensus` function.
6. Within the `dis_consensus` entry point, you can start defining the TLC code that corresponds to the MATLAB code. This involves implementing the necessary TLC constructs to handle the different cases specified in the provided code (flag values 0 and 3).
7. For each case, you will need to define the TLC code that corresponds to the MATLAB code within that case. This includes defining the input and output sizes, initializing variables, and implementing the necessary calculations.
8. Pay attention to any specific requirements or constraints of the target language you are generating code for. This may include syntax differences, data type considerations, or any other language-specific details.
9. Save the TLC file and use it with the appropriate code generation tool or environment to generate the desired code in the target language.
It's recommended to consult the documentation or resources specific to your code generation environment for more detailed guidance.
I hope this helps you get started with creating a TLC file for the provided code.
See Also
Categories
Find more on Target Language Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!