A method and apparatus for merging OBJ files of a custom TLC model compilation

By declaring variables and properties with the same name in the Simulink model and packaging them into a static library file, symbol conflicts and linking errors when merging custom TLC model code and default TLC model code are resolved, achieving accurate merging of model code.

CN122086409APending Publication Date: 2026-05-26CHANGZHOU ECTEK AUTOMOTIVE ELECTRONICS LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHANGZHOU ECTEK AUTOMOTIVE ELECTRONICS LTD
Filing Date
2025-12-30
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

During the Simulink model compilation process, when merging the model compilation code of a custom TLC with the model compilation code of the default TLC, linking errors such as symbol conflicts, address mismatches, and unresolved signals can easily occur.

Method used

By declaring variable attributes with the same name in the model files of the custom TLC and the default TLC, packaging the model compilation file of the default TLC into a static library file, modifying the attributes to be consistent with the format of the custom TLC model compilation file, and declaring and calling the library file in the custom TLC model compilation file, the interaction interface is merged.

Benefits of technology

This solution resolves linking errors such as symbol conflicts, address misalignment, and unresolved signals when merging custom TLC model and default TLC model code, ensuring the accuracy of the merged results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086409A_ABST
    Figure CN122086409A_ABST
Patent Text Reader

Abstract

This application discloses a method and apparatus for merging OBJ files of a custom TLC model. The method includes: obtaining the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B; compiling the Simulink model file of the custom TLC and the Simulink model file of the default TLC respectively to generate corresponding model source code files; creating a compilation project file for model A and a static library file for model B; merging the static library file and the compilation project file, integrating the logic calls, and performing overall compilation, linking, and conversion to generate an executable file. Applying the solution provided in this application, the compilation code of the custom TLC Simulink model can be accurately merged with the compilation code of the default TLC Simulink model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of file merging technology, and more specifically, to a method and apparatus for merging OBJ files compiled from a custom TLC model. Background Technology

[0002] In the Simulink model compilation process, it is often necessary to merge the compiled code of a Simulink model with a custom TLC and the compiled code of a Simulink model with the default TLC. For example, the main model A uses a custom TLC language, and the child model B uses the default Simulink TLC language. They need to interact, meaning the main model A outputs signals to the child model B as input, and the child model B outputs signals to the main model A as input. The typical model compilation process involves parsing the Simulink model into source code files such as .c / .h files using TLC, then generating intermediate files such as .obj files through the compiler, and finally linking them into executable files such as .elf and .hex files.

[0003] However, the methods described above, due to the different TLC code generation methods, directly merging the model compilation files (.obj) or library files (.a) in the compiler to generate the executable file will lead to linking errors such as symbol conflicts, address corruption, and unresolved signals. Therefore, how to accurately merge the Simulink model compilation code of the custom TLC with the Simulink model compilation code of the default TLC has become a pressing technical problem to be solved. Summary of the Invention

[0004] This application provides a method and apparatus for merging OBJ files of a custom TLC model, so as to accurately merge the Simulink model compilation code of the custom TLC with the Simulink model compilation code of the default TLC. The specific technical solution is as follows.

[0005] In a first aspect, embodiments of this application provide a method for merging OBJ files compiled from a custom TLC model, the method comprising: Obtain the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; wherein, the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B; The Simulink model files of the custom TLC and the default TLC are compiled separately to generate corresponding model source code files; In the compiler of Model A, a compilation project file for Model A is created based on the controller's underlying project file and the model source code file generated by Model A. In the compiler of Model B, a static library file is created based on the model source code file generated by Model B. The attributes of the static library file are consistent with the project attributes of the compilation project file of Model A. The static library file and the compiled project file are merged, the logical calls are integrated, and the entire process is compiled, linked, and transformed to generate the final executable file.

[0006] In one embodiment of this application, the step of creating a static library file based on the model source code file generated by model B in the compiler of model B includes: In the compiler of Model B, the model source code file generated by Model B is compiled to generate a .obj file, and the libModel_B.a static library file is generated based on the .obj file.

[0007] In one embodiment of this application, the step of integrating logic calls includes: In the source code file of model A, declare and call the initialize and step functions of model B, and link the static library file.

[0008] In one embodiment of this application, in the Simulink model file of the custom TLC, the variable of model A referencing model B is defined in model A with the attribute StorageClass = 'ImportedExtern'; the variable of model A outputting to model B is defined in model A with the attribute StorageClass = 'ExportedGlobal'. In the Simulink model file of the default TLC, the variables of Model B that reference Model A are defined in Model B with the attribute StorageClass = 'ImportedExtern'; the variables of Model B that output to Model A are defined in Model B with the attribute StorageClass = 'ExportedGlobal'.

[0009] In one embodiment of this application, the model source code files are preset .c and .h files.

[0010] Secondly, embodiments of this application provide a device for merging OBJ files of a custom TLC model compilation, the device comprising: The code acquisition module is used to acquire the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; wherein, the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B; The code compilation module is used to compile the Simulink model file of the custom TLC and the Simulink model file of the default TLC respectively, and generate the corresponding model source code file. The file generation module is used to create a compilation project file for model A in the compiler of model A based on the controller's underlying project file and the model source code file generated by model A, and to create a static library file in the compiler of model B based on the model source code file generated by model B; wherein the attributes of the static library file are consistent with the project attributes of the compilation project file of model A. The file merging module is used to merge the static library file and the compiled project file, integrate the logical calls, and perform overall compilation, linking and conversion to generate the final executable file.

[0011] In one embodiment of this application, the file generation module is specifically used for: In the compiler of Model B, the model source code file generated by Model B is compiled to generate a .obj file, and the libModel_B.a static library file is generated based on the .obj file.

[0012] In one embodiment of this application, the file merging module is specifically used for: In the source code file of model A, declare and call the initialize and step functions of model B, and link the static library file.

[0013] In one embodiment of this application, in the Simulink model file of the custom TLC, the variable of model A referencing model B is defined in model A with the attribute StorageClass = 'ImportedExtern'; the variable of model A outputting to model B is defined in model A with the attribute StorageClass = 'ExportedGlobal'. In the Simulink model file of the default TLC, the variables of Model B that reference Model A are defined in Model B with the attribute StorageClass = 'ImportedExtern'; the variables of Model B that output to Model A are defined in Model B with the attribute StorageClass = 'ExportedGlobal'.

[0014] In one embodiment of this application, the model source code files are preset .c and .h files.

[0015] Thirdly, embodiments of this application provide a computer device, including: a memory and a processor, wherein the memory and the processor are coupled together; The memory is used to store one or more computer instructions; The processor is used to execute one or more computer instructions to implement the custom TLC model compilation OBJ file merging method as described in the first aspect.

[0016] Fourthly, embodiments of this application provide a computer-readable storage medium storing one or more computer instructions that are executed by a processor to implement the custom TLC model compilation OBJ file merging method as described in the first aspect above.

[0017] Fifthly, this application provides a computer program product, which includes a computer program that, when executed by a processor, implements the custom TLC model compilation OBJ file merging method described in the first aspect.

[0018] In this embodiment, a reference interface between the custom TLC Simulink model and the default model is provided by mutually declaring variable attributes with the same name. By packaging the default model compilation file (.obj) into a static library file (.a) and modifying its attributes to be consistent with the format of the custom TLC model compilation file, the library file of the default model is declared and called in the custom TLC model compilation file. This enables the merging of the .obj files of the interactive interface, thereby solving linking errors such as symbol conflicts, address corruption, and unresolved signals when merging the code of the custom TLC model with the Simulink default TLC model code. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0020] Figure 1 This paper illustrates a flowchart of a method for merging OBJ files in a custom TLC model compilation according to an embodiment of this application. Figure 2 This illustration shows a schematic diagram of a custom TLC model compilation OBJ file merging device provided in an embodiment of this application; Figure 3 A schematic diagram of a computer device provided in an embodiment of this application is shown. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0022] It should be noted that the terms "comprising" and "having," and any variations thereof, in the embodiments and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.

[0023] This application discloses a method and apparatus for merging OBJ files of a custom TLC model, which can accurately merge the Simulink model compilation code of the custom TLC with the Simulink model compilation code of the default TLC. The embodiments of this application are described in detail below.

[0024] Figure 1 This paper illustrates a flowchart of a method for merging OBJ files of a custom TLC model compilation according to an embodiment of this application. This method can be applied to electronic devices and specifically includes the following steps: S110: Obtain the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; wherein, the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B. S120: Compile the Simulink model files of the custom TLC and the default TLC respectively to generate the corresponding model source code files; S130: In the compiler of model A, a compilation project file for model A is created based on the controller's underlying project file and the model source code file generated by model A. In the compiler of model B, a static library file is created based on the model source code file generated by model B. The attributes of the static library file are consistent with the project attributes of the compilation project file of model A. S140: Merge static library files and compiled project files, integrate logical calls, and perform overall compilation, linking, and transformation to generate the final executable file.

[0025] In this embodiment of the application, in order to solve the linking errors such as symbol conflicts, address misalignment, and unresolved signals when merging the code of the custom TLC model with the Simulink default TLC model code, the two parts of the code can be declared with double variables in advance, that is, the variables that reference each other are declared with the same name in the Simulink model data dictionary of the other party.

[0026] For example, we can define the main model A as a custom TLC language and the sub-model B as the default TLC language built into Simulink. Then, in the Simulink model file of the custom TLC, variables referenced by model A from model B are defined with the attribute StorageClass = 'ImportedExtern' in model A; variables exported from model A to model B are declared normally in their own data dictionary, i.e., defined with the attribute StorageClass = 'ExportedGlobal' in model A. Similarly, in the Simulink model file of the default TLC, variables referenced by model B from model A are defined with the attribute StorageClass = 'ImportedExtern' in model B; variables exported from model B to model A are defined with the attribute StorageClass = 'ExportedGlobal' in model B.

[0027] During the file merging process, the Simulink model file of the custom TLC in Model A and the Simulink model file of the default TLC in Model B are obtained. After merging the files, the Simulink model files of the custom TLC and the default TLC can be compiled separately to generate the corresponding model source code files.

[0028] Specifically, you can compile the Simulink model files of the custom TLC and the default TLC separately to generate all the necessary .c and .h files, which are the model source code files.

[0029] Furthermore, in the compiler of model A, a compilation project file for model A can be created based on the controller's underlying project file and the model source code file generated by model A. In the compiler of model B, a static library file can be created based on the model source code file generated by model B. The attributes of the static library file of model B are consistent with the project attributes of the compilation project file of model A.

[0030] For example, in the compiler of Model B, the model source code file generated by Model B can be compiled into a .obj file, and a libModel_B.a static library file can be generated from the .obj file. Here, "lib" is an automatically generated prefix, ".a" is the file name, and the middle name "Model_B" can be the same as the model name. When the model name changes, the middle name will also change accordingly.

[0031] Finally, the static library files of model B and the compiled project files of model A can be merged, the logic calls can be integrated, and the entire process can be compiled, linked, and transformed to generate the final executable file.

[0032] Specifically, taking the example of Model A calling the default TLC Simulink model file in Model B, the .a static library file of Model B can be added to the Model A project, and the logic calls can be integrated. For example, the initialize and step functions of Model B can be declared and called in the .c file of Model A, as well as the static library file can be linked. Finally, the .obj files of Model A and Model B (in .a file form) are merged to generate the final executable file, and the underlying merged files are updated.

[0033] In other words, the model files (.c / .h) can be automatically compiled by the compiler to generate binary intermediate files (.obj / .o, .d, files that are inconvenient to modify directly), then automatically linked into executable files (.out / .elf), and then automatically converted to generate a burning file (.hex). All three steps are performed automatically by the compiler. Therefore, generating the libModel_B.a static library file in model B is equivalent to compiling a part of the files in advance and then jumping in to continue the compilation and integration, thereby ensuring the accuracy of the merged result.

[0034] In this embodiment, a reference interface between the custom TLC Simulink model and the default model is provided by mutually declaring variable attributes with the same name. By packaging the default model compilation file (.obj) into a static library file (.a) and modifying its attributes to be consistent with the format of the custom TLC model compilation file, the library file of the default model is declared and called in the custom TLC model compilation file. This enables the merging of the .obj files of the interactive interface, thereby solving linking errors such as symbol conflicts, address corruption, and unresolved signals when merging the code of the custom TLC model with the Simulink default TLC model code.

[0035] Figure 2 This illustration shows a schematic diagram of a custom TLC model compilation OBJ file merging device provided in an embodiment of this application. The device includes: The code acquisition module 210 is used to acquire the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; wherein, the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B; The code compilation module 220 is used to compile the Simulink model file of the custom TLC and the Simulink model file of the default TLC respectively, and generate the corresponding model source code file. The file generation module 230 is used to create a compilation project file for model A in the compiler of model A based on the controller's underlying project file and the model source code file generated by model A, and to create a static library file in the compiler of model B based on the model source code file generated by model B; wherein the attributes of the static library file are consistent with the project attributes of the compilation project file of model A. The file merging module 240 is used to merge the static library file and the compiled project file, integrate the logical calls, and perform overall compilation, linking and conversion to generate the final executable file.

[0036] In one embodiment of this application, the file generation module 230 is specifically used for: In the compiler of Model B, the model source code file generated by Model B is compiled to generate a .obj file, and the libModel_B.a static library file is generated based on the .obj file.

[0037] In one embodiment of this application, the file merging module 240 is specifically used for: In the source code file of model A, declare and call the initialize and step functions of model B, and link the static library file.

[0038] In one embodiment of this application, in the Simulink model file of the custom TLC, the variable of model A referencing model B is defined in model A with the attribute StorageClass = 'ImportedExtern'; the variable of model A outputting to model B is defined in model A with the attribute StorageClass = 'ExportedGlobal'. In the Simulink model file of the default TLC, the variables of Model B that reference Model A are defined in Model B with the attribute StorageClass = 'ImportedExtern'; the variables of Model B that output to Model A are defined in Model B with the attribute StorageClass = 'ExportedGlobal'.

[0039] In one embodiment of this application, the model source code files are preset .c and .h files.

[0040] In this embodiment, a reference interface between the custom TLC Simulink model and the default model is provided by mutually declaring variable attributes with the same name. By packaging the default model compilation file (.obj) into a static library file (.a) and modifying its attributes to be consistent with the format of the custom TLC model compilation file, the library file of the default model is declared and called in the custom TLC model compilation file. This enables the merging of the .obj files of the interactive interface, thereby solving linking errors such as symbol conflicts, address corruption, and unresolved signals when merging the code of the custom TLC model with the Simulink default TLC model code.

[0041] The following describes a computer device provided in an embodiment of this application. Please refer to [link / reference needed]. Figure 3 , Figure 3 A schematic diagram of a computer device provided in an embodiment of this application, the computer device comprising: One or more processors 40; The processor 40 is coupled to a storage device 41, which stores one or more programs. When the one or more programs are executed by the processor 40, the electronic device enables the electronic device to perform the following functions: Figure 1 The technical solution of the custom TLC model compilation OBJ file merging method is described above.

[0042] This application also provides a computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement... Figure 1 The technical solution of the custom TLC model compilation OBJ file merging method is described above.

[0043] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the following: Figure 1 The technical solution of the custom TLC model compilation OBJ file merging method is described above.

[0044] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of one embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application.

[0045] Those skilled in the art will understand that the modules in the apparatus of the embodiments can be distributed in the apparatus of the embodiments as described in the embodiments, or they can be located in one or more devices different from this embodiment with corresponding changes. The modules of the above embodiments can be combined into one module, or they can be further divided into multiple sub-modules.

[0046] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for merging OBJ files of a custom TLC model compilation, characterized in that, The method includes: Obtain the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; wherein, the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B; The Simulink model files of the custom TLC and the default TLC are compiled separately to generate corresponding model source code files; In the compiler of Model A, a compilation project file for Model A is created based on the controller's underlying project file and the model source code file generated by Model A. In the compiler of Model B, a static library file is created based on the model source code file generated by Model B. The attributes of the static library file are consistent with the project attributes of the compilation project file of Model A. The static library file and the compiled project file are merged, the logical calls are integrated, and the entire process is compiled, linked, and transformed to generate the final executable file.

2. The method according to claim 1, characterized in that, The step of creating a static library file based on the model source code file generated by model B in the compiler of model B includes: In the compiler of Model B, the model source code file generated by Model B is compiled to generate a .obj file, and the libModel_B.a static library file is generated based on the .obj file.

3. The method according to claim 1, characterized in that, The steps of the integrated logic call include: In the source code file of model A, declare and call the initialize and step functions of model B, and link the static library file.

4. The method according to claim 1, characterized in that, In the Simulink model file of the custom TLC, the variable referenced by model A from model B is defined in model A with the attribute StorageClass = 'ImportedExtern'; the variable output by model A to model B is defined in model A with the attribute StorageClass = 'ExportedGlobal'. In the Simulink model file of the default TLC, the variables of Model B that reference Model A are defined in Model B with the attribute StorageClass = 'ImportedExtern'; the variables of Model B that output to Model A are defined in Model B with the attribute StorageClass = 'ExportedGlobal'.

5. The method according to any one of claims 1-4, characterized in that, The model source code files are preset .c and .h files.

6. A device for merging OBJ files of a custom TLC model compilation, characterized in that, The device includes: The code acquisition module is used to acquire the Simulink model file of the custom TLC in model A and the Simulink model file of the default TLC in model B; wherein, the Simulink model file of the custom TLC has completed the preset attribute definition in the data dictionary of model A; the Simulink model file of the default TLC has completed the preset attribute definition in the data dictionary of model B; The code compilation module is used to compile the Simulink model file of the custom TLC and the Simulink model file of the default TLC respectively, and generate the corresponding model source code file. The file generation module is used to create a compilation project file for model A in the compiler of model A based on the controller's underlying project file and the model source code file generated by model A, and to create a static library file in the compiler of model B based on the model source code file generated by model B; wherein the attributes of the static library file are consistent with the project attributes of the compilation project file of model A. The file merging module is used to merge the static library file and the compiled project file, integrate the logical calls, and perform overall compilation, linking and conversion to generate the final executable file.

7. The apparatus according to claim 6, characterized in that, The file generation module is specifically used for: In the compiler of Model B, the model source code file generated by Model B is compiled to generate a .obj file, and the libModel_B.a static library file is generated based on the .obj file.

8. The apparatus according to claim 6, characterized in that, The file merging module is specifically used for: In the source code file of model A, declare and call the initialize and step functions of model B, and link the static library file.

9. The apparatus according to claim 6, characterized in that, In the Simulink model file of the custom TLC, the variable referenced by model A from model B is defined in model A with the attribute StorageClass = 'ImportedExtern'; the variable output by model A to model B is defined in model A with the attribute StorageClass = 'ExportedGlobal'. In the Simulink model file of the default TLC, the variables of Model B that reference Model A are defined in Model B with the attribute StorageClass = 'ImportedExtern'; the variables of Model B that output to Model A are defined in Model B with the attribute StorageClass = 'ExportedGlobal'.

10. The apparatus according to any one of claims 6-9, characterized in that, The model source code files are preset .c and .h files.