Template-based AADL platform irrelevant code generation method

By introducing a platform-independent abstraction layer into automatic code generation technology, mapping the AADL model to the abstract layer template code, solving the problem of large development work caused by platform changes or new platforms, and achieving rapid migration of the system between multiple platforms and efficient code generation.

CN120029615AInactive Publication Date: 2025-05-23BEIJING INST OF COMP TECH & APPL

Patent Information

Application Number
CN202510187633.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-20
Publication Date
2025-05-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In automatic code generation technology, a large amount of development work caused by platform changes or new platforms leads to low development efficiency and high maintenance costs.

Method used

By introducing platform-independent abstraction layers, map the AADL model to the abstract layer template code, thereby generating code that is suitable for different platforms. This abstract layer is designed with a general template, which can adapt to the requirements of specific platforms and reduce the development workload during platform replacement.

Benefits of technology

It significantly reduces the cost of code reconstruction when platform updates, improves the system's rapid migration ability between multiple platforms and the compatibility and stability of cross-platform development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029615A_ABST
    Figure CN120029615A_ABST
Patent Text Reader

Abstract

The invention relates to a template-based AADL platform irrelevant code generation method, and belongs to the field of automatic code generation. According to the method, an analyzer reads an AADL model and extracts model elements described in the AADL model, the model elements comprise system architecture, component information, inter-component connection and related attributes, and necessary data support is provided for subsequent mapping steps; defining a mapping relation between the AADL model and the platform-independent abstraction layer according to structures and requirements of the AADL model and the platform-independent abstraction layer; the method specifically comprises the steps that component types, connection relations and related attributes involved in the AADL model are matched with corresponding elements in an abstraction layer, so that it is ensured that the abstraction layer can completely describe the function and structure of the AADL model; according to the mapping rule formulated in the second step, the analyzed AADL model elements are converted into corresponding elements in the abstraction layer one by one, and abstraction layer template codes irrelevant to a platform are generated. According to the invention, the expansibility and flexibility of code generation are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of automatic code generation, and in particular relates to a template-based AADL platform-independent code generation method. Background Art

[0002] With the rapid development of embedded systems, the diversity and complexity of hardware platforms have made the development of embedded systems face more and more challenges. Traditional embedded system development usually relies on manual coding for specific platforms, which is not only inefficient but also has high maintenance costs. When facing multi-platform support, developers need to write a lot of repetitive code for each platform, which not only increases the development cycle, but also easily leads to duplication and consistency problems of code between platforms.

[0003] In order to improve the development efficiency of embedded systems, automatic code generation technology has emerged. This technology effectively simplifies the system design and development process by automatically generating platform-related code from high-level models (such as AADL models). However, a key challenge faced in the automatic code generation process is how to cope with platform change requirements, especially when the AADL model itself remains unchanged. Traditional code generation methods usually require separate development and adjustment for each target platform, resulting in a lot of code refactoring every time the platform changes.

[0004] In order to address the above challenges, a new method is urgently needed to efficiently map the AADL model to a platform-independent abstract layer, so as to generate code that adapts to different platforms and improve the efficiency of automatic code generation. In response to this demand, the present invention proposes a solution based on a platform-independent abstract layer. This method simplifies the migration between platforms by defining a platform-independent system model. In this method, the platform-independent abstract layer serves as a general template that adapts to the requirements of a specific platform, making the generation process of platform-specific code more efficient and standardized. By introducing this abstract layer, the problem of comprehensive code reconstruction caused by platform changes can be effectively avoided, thereby significantly improving the development efficiency and maintenance flexibility of the system. Summary of the invention

[0005] 1. Technical issues to be resolved

[0006] The technical problem to be solved by the present invention is how to provide a template-based AADL platform-independent code generation method to solve the problem of a large amount of development work caused by platform changes or new platforms in automatic code generation technology.

[0007] (II) Technical solution

[0008] In order to solve the above technical problems, the present invention proposes a template-based AADL platform-independent code generation method, which includes the following steps:

[0009] Step 1: Parsing the AADL model

[0010] The parser reads the AADL model and extracts the model elements described therein, including: system architecture, component information, connections between components, and related properties, providing necessary data support for subsequent mapping steps;

[0011] Step 2: Design the mapping rules from AADL model to platform-independent abstraction layer code

[0012] Define the mapping relationship between the AADL model and the platform-independent abstraction layer according to their structure and requirements; specifically, match the component types, connection relationships, and related properties involved in the AADL model with the corresponding elements in the abstraction layer to ensure that the abstraction layer can fully describe the functions and structure of the AADL model;

[0013] Step 3: Automatically convert to abstract layer template code

[0014] According to the mapping rules formulated in the second step, the parsed AADL model elements are converted one by one into corresponding elements in the abstract layer, generating platform-independent abstract layer template code.

[0015] (III) Beneficial effects

[0016] The present invention proposes a template-based AADL platform-independent code generation method. The present invention proposes a template-based AADL platform-independent code generation technology, which mainly has the following characteristics:

[0017] (1) By introducing a platform-independent abstract layer, an intermediate transition structure from the AADL model to the target platform code generation is realized. The abstract layer is designed in a general template manner and can adapt to the requirements of specific platforms. Therefore, when supporting a new platform, only the conversion part from the abstract layer to the target platform needs to be adjusted, which greatly reduces the development workload when the platform is changed and improves the scalability and flexibility of code generation.

[0018] (2) By mapping the components, connections, and properties of the AADL model to platform-independent abstract templates, duplicate development work is avoided, thereby significantly reducing the cost of code refactoring when the platform is updated.

[0019] (3) By uniformly defining and standardizing the abstract layer templates, not only can the system be quickly migrated between multiple platforms, but also good compatibility and stability can be maintained in cross-platform development. It is especially suitable for embedded projects with diversified hardware platforms and high software porting requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flow chart of the template-based AADL platform-independent code generation method of the present invention;

[0021] Figure 2 Model a diagram for a temperature control system;

[0022] Figure 3 A diagram of the relationship between the symbol table and data structures constructed during the parsing of the AADL model;

[0023] Figure 4 A diagram of the generation process of converting thread components into intermediate abstract platform templates in the AADL model;

[0024] Figure 5 Portions of the code files generated for the thread. DETAILED DESCRIPTION

[0025] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

[0026] In view of the fact that a large amount of redevelopment is required when updating or changing the target platform during the automatic code generation process based on the AADL model, the present invention parses the AADL model and formulates a set of systematic mapping rules to map the AADL model to a platform-independent abstract layer. This abstract layer, as a general template for platform-specific code generation, can effectively avoid repeated development work caused by platform updates. By introducing a platform-independent abstract layer, the present invention provides a unified and extensible template for subsequent code generation, effectively solves the adaptation problem during platform updates, and ensures the compatibility and stability of the system between different platforms.

[0027] The purpose of the present invention is to solve the problem of a large amount of development work caused by platform changes or new platforms in automatic code generation technology. By introducing a platform-independent abstract layer, automatic generation of abstract layer template code from AADL model is achieved, the complexity of platform migration is reduced, and the efficiency and adaptability of code generation are improved.

[0028] This technology focuses on the processing of AADL software components, especially thread components and their port-based communication mechanism. Therefore, the present invention mainly discusses thread components in AADL models and the communication between them, component properties (Periodic, Sporadic), and the mapping and conversion of data components.

[0029] Step 1: Parsing the AADL model

[0030] The parser reads the AADL model and extracts model elements such as the system architecture, component information (such as name, type and interface, etc.), connections between components and related properties described therein, providing necessary data support for subsequent mapping steps.

[0031] Step 2: Design the mapping rules from AADL model to platform-independent abstraction layer code

[0032] Based on the structure and requirements of the AADL model and the platform-independent abstraction layer, define the mapping relationship between the two. Specifically, it includes matching the component types, connection relationships, and related properties involved in the AADL model with the corresponding elements in the abstraction layer to ensure that the abstraction layer can fully describe the functions and structure of the AADL model.

[0033] Step 3: Automatically convert to abstract layer template code

[0034] According to the mapping rules formulated in the second step, the parsed AADL model elements are converted one by one into corresponding elements in the abstract layer, generating platform-independent abstract layer template code.

[0035] Embodiment 1:

[0036] Figure 1 FIG. 1 is a flow chart of a generation process of converting the AADL model of the present invention into an abstract platform template code. Figure 1 As shown in the figure, the template-based AADL platform-independent code generation method is mainly reflected in the AADL model, the model information step obtained after parsing the XML file, the step of formulating corresponding mapping rules, and the step of generating abstract platform template code. The specific implementation details are as follows:

[0037] Step 1: Parsing the AADL model

[0038] Use the modeling tool OSATE to model the system, such as Figure 2 As shown, a visual interface of a temperature control system is shown. The parser receives an AADL model as input, which defines the architecture of the system, including components (such as Thread, Process, etc.), their characteristics (such as Feature), connections (such as connection), and attribute configurations (Periodic, Sporadic), etc. In the method proposed in the invention, the AADL model is usually transmitted in the form of IR (Intermediate Representation), that is, a representation of an abstract syntax tree (AST), and an input parameter example is "valmodel:ir.Aadl=".

[0039] The core task of the parsing process is to convert the various elements (component, feature, connection, etc.) in the AADL model into a structured data form and parse the relevant information of these elements. During the parsing process, the symbol table (SymbolTable) is first built to store the information of all elements in the model, including all components, features, connections, etc. It translates the high-level abstract concepts of the AADL model into the low-level specific information required for target code generation. Next, the parser will traverse all components in the model and store them in the data structure componentMap. Each component contains its name, category, characteristics, etc. Then, the parser will parse the characteristics of the component, including data ports, event ports, etc. The parser will also identify and parse the connections between components in the model, which define the data flow and control flow between components. During the parsing process, it will verify whether the connection is legal, for example, whether the source port and the target port match, whether the connection characteristics exist, etc. If the AADL model contains additional libraries (Annexe Libraries), the parser also needs to process these additional contents. Additional libraries can define specific behaviors or constraints, which are usually used to extend the functions of the AADL model. The parser accesses these additional libraries through the AnnexVisitor, parses the clauses in them, and stores this information in the corresponding data structure. After the parsing is completed, multiple data structures are generated as the parsing results. Figure 3 The relationship between the symbol table and other data structures is shown. These results include:

[0040] SymbolTable: Contains information about parsed elements (such as components, features, connections, etc.) for subsequent parsing queries and use.

[0041] ComponentMap: Stores information about all components in the model, including a detailed description of each component, such as name, properties, etc.

[0042] FeatureMap: stores the features of components, including data ports, event ports, etc.

[0043] ConnectionMap: describes the connection information between components and records the relationship between ports and features.

[0044] AnnexeLibInfo: Stores the parsed additional library content and additional terms, ensuring that additional functions and constraints are processed correctly.

[0045] Step 2: Design the mapping rules from AADL model to platform-independent abstraction layer code

[0046] Clarify the functions and semantics of key elements (such as components, attributes, connections, etc.) defined in the AADL standard, define a platform-independent abstract layer structure, and determine the expression form of key elements such as component types, interfaces, and attributes in the abstract layer. Specify the mapping rules from the AADL model to the abstract layer, including:

[0047] 1. The components in the AADL model are the core elements of the system, which are mapped to the corresponding object-oriented code framework "object process / thread_name{}" in the abstract layer. This code framework provides the basic structure of the components and their interaction mechanism, but does not contain specific application logic. Developers can supplement and improve the specific application logic based on the functional requirements of the system to realize the complete functions of the components.

[0048] 2. The communication between components in the AADL model is realized through ports and connection relationships, which are converted into the corresponding communication interface API call methods "api.get_port_name() / api.put_port_name()" in the abstract layer. Among them, the input / output ports of data and events are mapped to the "read" and "write" interfaces in the abstract layer, and the connections between components are converted into API calls or message passing code frameworks in the abstract layer.

[0049] 3. The properties of the components in the AADL model (Periodic, sporadic) are mapped to the corresponding function definitions, parameters or configuration files in the abstract layer. For components with periodic behavior, their properties are mapped to the function framework of timed execution "deftimeTriggered(:):Unit={}", and the execution period is configured as a parameter in the task object; for components with sporadic behavior, their properties are mapped to the event trigger function "defhandle_port_name(:):Unit={}", and dynamic response is achieved through the event mechanism.

[0050] 4. Data types are divided into simple data types (Boolean, character, enumeration, integer, string, etc.) and complex data types (structure, enumeration, etc.). In the AADL model, the simple data types of data components are mapped to simple data types in the abstract layer, and complex data types are mapped to complex data types in the abstract layer. For example, when data component A is a structure type, it is mapped to the form of "objectA_i{...}" in the abstract layer, and when data component B is an enumeration type, it is mapped to the form of "enum object B{...}" in the abstract layer. The following table shows an example of the mapping of simple data types.

[0051]

[0052] Step 3: Automatically convert to abstract layer template code

[0053] Based on the information extracted from the data structure obtained in the first step, and according to the mapping rules established in the second step, the components, connections and related properties in the system are converted into general templates in the abstract layer. The template is organized in the form of structured code snippets, which comprehensively describe the key contents such as the system architecture, component definitions and their connection relationships. The final generated abstract layer template code is the output result. Each thread belongs to a task created in the process, and each thread generates ThreadName_i_tnp_threadName.scala, where tnp represents the process to which the thread belongs. Figure 5 Shown is part of the code file generated by the thread.

[0054] Beneficial effects:

[0055] The present invention proposes a template-based AADL platform-independent code generation technology, which has the following main features:

[0056] (1) By introducing a platform-independent abstract layer, an intermediate transition structure from the AADL model to the target platform code generation is realized. The abstract layer is designed in a general template manner and can adapt to the requirements of specific platforms. Therefore, when supporting a new platform, only the conversion part from the abstract layer to the target platform needs to be adjusted, which greatly reduces the development workload when the platform is changed and improves the scalability and flexibility of code generation.

[0057] (2) By mapping the components, connections, and properties of the AADL model to platform-independent abstract templates, duplicate development work is avoided, thereby significantly reducing the cost of code refactoring when the platform is updated.

[0058] (3) By uniformly defining and standardizing the abstract layer templates, not only can the system be quickly migrated between multiple platforms, but also good compatibility and stability can be maintained in cross-platform development. It is especially suitable for embedded projects with diversified hardware platforms and high software porting requirements.

[0059] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A template-based AADL platform-independent code generation method, characterized in that: The method comprises the following steps: Step 1: Parsing the AADL model The parser reads the AADL model and extracts the model elements described therein, including: system architecture, component information, connections between components, and related properties, providing necessary data support for subsequent mapping steps; Step 2: Design the mapping rules from AADL model to platform-independent abstraction layer code Define the mapping relationship between the AADL model and the platform-independent abstraction layer according to their structure and requirements; specifically, match the component types, connection relationships, and related properties involved in the AADL model with the corresponding elements in the abstraction layer to ensure that the abstraction layer can fully describe the functions and structure of the AADL model; Step 3: Automatically convert to abstract layer template code According to the mapping rules formulated in the second step, the parsed AADL model elements are converted one by one into corresponding elements in the abstract layer, generating platform-independent abstract layer template code.

2. The template-based AADL platform-independent code generation method according to claim 1, characterized in that: The component information in the first step includes: name, type and interface.

3. The template-based AADL platform-independent code generation method according to claim 1, characterized in that: The first step includes: the parser receives an AADL model as input, the model defines the architecture of the system, including components, characteristics, connections and property configurations of the components, and the AADL model is transmitted in the form of IR (Intermediate Representation).

4. The template-based AADL platform-independent code generation method according to claim 1, characterized in that: In the first step, the core task of the parsing process is to convert each element in the AADL model into a structured data form and parse the relevant information of these elements; During the parsing process, the symbol table SymbolTable is first constructed to store the information of all elements in the model, including all components, features, and connection information, translating the high-level abstract concepts of the AADL model into the low-level specific information required for target code generation; Next, the parser will traverse all components in the model and store them in the data structure componentMap. Each component contains its name, category, and feature information. The parser then parses the features of the components, including data ports and event ports. The parser also identifies and parses the connections between components in the model, which define the data and control flows between components. During the parsing process, the legitimacy of the connection will be verified; If the AADL model contains additional libraries, the parser also needs to process these additional contents; the additional libraries define specific behaviors or constraints to extend the functionality of the AADL model; the parser accesses these additional libraries through the AnnexVisitor, parses the clauses in them, and stores this information in the corresponding data structure; After parsing is completed, multiple data structures will be generated as parsing results.

5. The template-based AADL platform-independent code generation method according to claim 4, characterized in that: In the first step, the analysis results include: SymbolTable: contains information about parsed elements for subsequent parsing queries and use; ComponentMap: stores information about all components in the model, including a detailed description of each component; FeatureMap: stores the features of components, including data ports and event ports; ConnectionMap: describes the connection information between components and records the relationship between ports and features; AnnexeLibInfo: Stores the parsed additional library content and additional terms, ensuring that additional functions and constraints are processed correctly.

6. The template-based AADL platform-independent code generation method according to any one of claims 1 to 5, characterized in that: In the second step, the components in the AADL model are the core elements, which are mapped to the corresponding object-oriented code framework "object process / thread_name{}" in the abstract layer; this code framework provides the basic structure of the component and its interaction mechanism, but does not contain specific application logic; developers supplement and improve the specific application logic based on the functional requirements of the system to realize the complete functionality of the component.

7. The template-based AADL platform-independent code generation method according to claim 6, characterized in that: In the second step, the communication between components in the AADL model is realized through ports and connection relationships, which are converted into corresponding communication interface API call methods "api.get_port_name() / api.put_port_name()" in the abstract layer; among them, the input / output ports of data and events are mapped to the "read" and "write" interfaces in the abstract layer, and the connections between components are converted into API calls or message passing code frameworks in the abstract layer.

8. The template-based AADL platform-independent code generation method according to claim 7, characterized in that: In the second step, the properties of the components in the AADL model are mapped to the corresponding function definitions, parameters or configuration files in the abstract layer; for components with periodic behavior, their properties are mapped to the function framework of timed execution "deftimeTriggered(:):Unit={}", and the execution period is configured as a parameter in the task object; for components with sporadic behavior, their properties are mapped to the event trigger function "defhandle_port_name(:):Unit={}", and dynamic response is achieved through the event mechanism.

9. The template-based AADL platform-independent code generation method according to claim 8, characterized in that: In the second step, data types are divided into simple data types and complex data types. Simple data types include: Boolean value, character type, enumeration type, integer and string, and complex data types include: structure and enumeration. In the AADL model, the simple data types of data components are mapped to simple data types in the abstract layer, and complex data types are mapped to complex data types in the abstract layer. When data component A is a structure type, it is mapped to the form of "objectA_i{...}" in the abstract layer, and when data component B is an enumeration type, it is mapped to the form of "enum object B{...}" in the abstract layer.

10. The template-based AADL platform-independent code generation method according to claim 9, characterized in that: The third step includes: based on the information extracted from the data structure obtained in the first step and in accordance with the mapping rules established in the second step, the components, connections and related attributes in the system are converted into a general template in the abstract layer; the template is organized in the form of structured code fragments to comprehensively describe the system architecture, component definitions and their connection relationships; the abstract layer template code is finally generated as the output result.

Citation Information

Patent Citations

  • AADL generation embedded system code method based on middle model

    CN108563439A

  • AADL model refinement and C code automatic generation method supported by the AADL model refinement for aerospace application

    CN109558117A

  • Embedded operating system platform related code generation method based on AADL model

    CN119440514A

  • Platform runtime abstraction

    US20150012669A1

Cited By

  • Fault monitoring code generation method and device, medium and program product

    CN121680835A