Code generation method, device and equipment for chip general input / output controller, medium and program product
By building configuration files and tables to record data, and using scripts to automatically generate general input/output controller code for system-on-a-chip, the design tediousness and time-consuming problems caused by manually writing code are solved, and efficient and accurate code generation and rapid iteration are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI BIREN TECH CO LTD
- Filing Date
- 2026-03-09
- Publication Date
- 2026-06-19
Smart Images

Figure CN122240075A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of digital circuit design technology, and in particular to a method, apparatus, device, medium, and program product for generating code for a chip general-purpose input / output controller. Background Technology
[0002] With the development of digital circuit technology, System-on-Chips (SoCs) have been widely used. A SoC is an integrated circuit that integrates multiple functional modules such as a processor, analog IP (Intellectual Property) cores, digital IP cores, and memory on a single chip. Through hardware and software collaboration, it achieves complete system-level functions and possesses core advantages such as high integration, low power consumption, high performance, low cost, and flexible customization. It has become a core driving force for the intelligent development of electronic products and is widely used in consumer electronics, mobile communications, automotive electronics, the Internet of Things, and infrastructure, among other fields.
[0003] General Purpose Input / Output (GPIO) controllers, as the most basic and flexible peripheral interface modules of system-on-a-chip (SoC), serve as a bridge connecting the chip's internal core circuitry with the external hardware environment. Through programmable configuration, they enable digital signal input acquisition and output control, while also supporting multi-scenario function multiplexing. With the continuous advancement of Moore's Law and the constant improvement of manufacturing processes, SoCs are rapidly developing towards higher computing power, lower power consumption, and higher integration. Correspondingly, the demand for the number of GPIOs is also increasing.
[0004] In related technologies, the design of general-purpose input / output (GPIO) controllers typically relies on designers manually writing hardware description language (HMR) code. This approach requires designers to be extremely familiar with the circuit structure of GPIO controllers and to write accurate code for each GPIO control circuit. When the chip size is large and the number of GPIOs is numerous, designers need to complete the code writing for each control circuit one by one, making the entire design process tedious and time-consuming. As the number of GPIOs increases and the complexity of chip design rises, the workload of designers increases significantly, and code maintenance costs also rise sharply, seriously affecting overall development efficiency and making it difficult to meet the needs of efficient system-on-a-chip (SoC) design and rapid iteration. Summary of the Invention
[0005] Therefore, it is necessary to provide a code generation method, apparatus, device, medium, and program product for a general-purpose input / output controller for chips that can meet the needs of efficient design and rapid iteration of system-on-a-chip (SoC) systems, addressing the aforementioned technical problems.
[0006] Firstly, this application provides a method for generating code for a chip-based general-purpose input / output controller. The method includes:
[0007] A configuration file is constructed to record the characteristic data of the general inputs and outputs of the system-on-a-chip.
[0008] A configuration table is constructed, which is used to record the general input and output functional data of the system-on-a-chip;
[0009] Execute the script program to read and store the feature data and function data of the configuration file and the configuration table respectively;
[0010] Based on the feature data and the functional data, the script program automatically generates the code for each module of the general input / output, thus completing the code generation for the general input / output controller of the system-on-a-chip.
[0011] In some embodiments of the method, the script program is a Python script, and the step of automatically generating the code for each module of the general input / output (GUID) based on the feature data and the functional data through the script program to complete the code generation of the GUID controller of the system-on-a-chip includes:
[0012] The configuration file is read and parsed, and the characteristic data of the general input and output of the system-on-a-chip are stored as a first data structure;
[0013] Read and parse the configuration table, and store the functional data of each general input and output into a second data structure;
[0014] Based on the first data structure and the second data structure, corresponding hardware description language-based codes for the general input / output register read / write module, general input / output model management module, general input / output control module, and general input / output clock reset module are generated according to the preset code template.
[0015] The generated module code is integrated to output the complete code for a general-purpose input / output controller.
[0016] In some embodiments of the method, the method further includes:
[0017] In response to detecting an update to the configuration file and / or the configuration table, obtain the feature data and / or function data in the updated configuration file and / or the updated configuration table;
[0018] The execution script program reads and stores the feature data and function data from the configuration file and the configuration table, respectively, including:
[0019] Execute the script program to read and store the updated feature data and / or updated function data respectively.
[0020] In some embodiments of the method, the preset code template predefines the syntax structure, interface definition, logical call relationship and comment specifications of each module code. The script program automatically fills in the data and generates the code of the corresponding module by matching the data fields in the first data structure and the second data structure with the variable fields in the code template.
[0021] In some embodiments of the method, the configuration file is a text file in markup language format, and the configuration table is a spreadsheet file; the first data structure and the second data structure are at least one of key-value pair structure, array structure, or structure.
[0022] In some embodiments of the method, the feature data includes at least one of general input / output port information, register-configurable port entry information, and register configuration sequence information; the functional data includes at least one of general input / output name information, model information, signal direction information, output enable control information, register read / write control information, pull-up / pull-down resistor control information, drive strength control information, and Schmitt trigger control information.
[0023] According to a second aspect of the present disclosure, a code generation apparatus for a chip general-purpose input / output controller is provided. The apparatus includes:
[0024] The first configuration module is used to build a configuration file, which is used to record the characteristic data of the general input and output of the system-on-a-chip.
[0025] The second configuration module is used to construct a configuration table, which is used to record the general input and output functional data of the system-on-a-chip.
[0026] The processing module is used to execute a script program, which reads the feature data and function data of the configuration file and the configuration table respectively and stores them respectively;
[0027] The code generation module is used to automatically generate the code for each module of the general input / output based on the feature data and the functional data through the script program, thereby completing the code generation of the general input / output controller of the system-on-a-chip.
[0028] According to a third aspect of the present disclosure, a computer device is provided. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0029] A configuration file is constructed to record the characteristic data of the general inputs and outputs of the system-on-a-chip.
[0030] A configuration table is constructed, which is used to record the general input and output functional data of the system-on-a-chip;
[0031] Execute the script program to read and store the feature data and function data of the configuration file and the configuration table respectively;
[0032] Based on the feature data and the functional data, the script program automatically generates the code for each module of the general input / output, thus completing the code generation for the general input / output controller of the system-on-a-chip.
[0033] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0034] A configuration file is constructed to record the characteristic data of the general inputs and outputs of the system-on-a-chip.
[0035] A configuration table is constructed, which is used to record the general input and output functional data of the system-on-a-chip;
[0036] Execute the script program to read and store the feature data and function data of the configuration file and the configuration table respectively;
[0037] Based on the feature data and the functional data, the script program automatically generates the code for each module of the general input / output, thus completing the code generation for the general input / output controller of the system-on-a-chip.
[0038] According to a fifth aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0039] A configuration file is constructed to record the characteristic data of the general inputs and outputs of the system-on-a-chip.
[0040] A configuration table is constructed, which is used to record the general input and output functional data of the system-on-a-chip;
[0041] Execute the script program to read and store the feature data and function data of the configuration file and the configuration table respectively;
[0042] Based on the feature data and the functional data, the script program automatically generates the code for each module of the general input / output, thus completing the code generation for the general input / output controller of the system-on-a-chip.
[0043] The code generation scheme for a general-purpose input / output (GPIO) controller provided in this application embodiment can record the characteristic data of GPIOs in a configuration file and the functional data of each GPIO in a configuration table. Then, a script program automatically generates code based on these two types of data, completely changing the traditional mode of relying on designers to manually write hardware description language (HTAL) code. Addressing the characteristics of a large number of GPIOs and complex configuration requirements in system-on-a-chip (SoC), this method effectively avoids omissions and errors that are prone to occur during manual coding due to repetitive workloads and tedious details. It significantly improves the accuracy of GPIO controller code generation, while greatly shortening the code development cycle and improving overall design efficiency. Furthermore, it eliminates the need for designers to have in-depth knowledge of the complex circuit structure of GPIO controllers and the details of hardware description languages, lowering the professional threshold for SoC GPIO controller design and allowing more designers to participate in related design work, better meeting the needs of efficient SoC design and rapid iteration.
[0044] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0045] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0046] Figure 1 This is a flowchart illustrating a code generation method for a chip general-purpose input / output controller according to an exemplary embodiment;
[0047] Figure 2 This is a schematic diagram illustrating the specific process of code generation steps according to an exemplary embodiment;
[0048] Figure 3 This is a flowchart illustrating the specific code generation steps according to an exemplary embodiment;
[0049] Figure 4 This is a detailed flowchart illustrating the update steps according to an exemplary embodiment;
[0050] Figure 5 This is a structural block diagram of a code generation apparatus for a chip general-purpose input / output controller according to an exemplary embodiment;
[0051] Figure 6This is a diagram illustrating the internal structure of a computer device according to an exemplary embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure. The terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded. For example, the use of terms such as "first," "second," etc., to denote names does not indicate any specific order.
[0054] In some embodiments provided in this disclosure, the execution of the code generation method for the chip's general-purpose input / output controller can be controlled by a unified controller or by multiple controllers. These controllers may include controllers on a local terminal or controllers on a remote server. In some embodiments, the controllers on the local terminal and the controllers on the server can jointly assist in completing the code generation control processing for the chip's general-purpose input / output controller. The local terminal mentioned in this disclosure may include, but is not limited to, various robotic devices, in-vehicle devices, personal computers, laptops, smartphones, tablets, wearable devices, medical devices, VR (Virtual Reality) devices, etc. The server may also be a server, server cluster, distributed subsystem, cloud processing platform, server containing blockchain nodes, or a combination thereof. The controllers described in this disclosure may include various control units capable of implementing logic processing functions, including but not limited to CPU (Central Processing Unit), PLC (Programmable Logic Controller), ECU (Electronic Control Unit), MCU (Microcontroller Unit), FPGA (Field Programmable Gate Array), and CPLD (Complex Programmable Logic Device), as well as controllers composed of one or more logic function units, chips, etc.
[0055] In some embodiments of this disclosure, a method for generating code for a chip-based general-purpose input / output controller is provided, such as... Figure 1 As shown, it includes the following steps:
[0056] S20. Construct a configuration file, which is used to record the characteristic data of the general input and output of the system-on-a-chip.
[0057] Configuration files are used to record the characteristic data of the general-purpose inputs and outputs (GPIOs) of a system-on-a-chip (SoC). In practice, designers can gradually sort out and fill in these characteristic data according to the design requirements of the SoC and the specific specifications of the GPIOs, ensuring that the configuration file can comprehensively and accurately reflect the characteristics of the GPIOs.
[0058] S22. Construct a configuration table, which is used to record the general input / output functional data of the system-on-a-chip.
[0059] The configuration table records the functional data of the general-purpose inputs and outputs (GPIOs) of the system-on-a-chip (SoC). This functional data defines in detail the specific function and configuration requirements of each GPIO. Designers can fill in the corresponding functional data in the configuration table according to the design requirements of different GPIOs, forming a complete configuration table and providing detailed functional parameter support for subsequent code generation.
[0060] S24. Execute the script program to read the feature data and function data of the configuration file and the configuration table respectively and store them respectively.
[0061] After reading feature data from the configuration file and functional data from the configuration table, the script can store these two types of data—from different sources and with different attributes—in separate storage areas or data containers according to preset rules and data structures, maintaining data integrity and correspondence, and preventing data from being mixed up. This separate storage method clearly distinguishes between common feature data of general inputs and outputs and personalized functional data of individual general inputs and outputs, ensuring the accuracy of data retrieval and the efficiency of code generation. It also facilitates the accurate location and replacement of corresponding data content when configuration data is updated, improving the flexibility of design iteration.
[0062] S26. Based on the feature data and the functional data, the code for each module of the general input / output is automatically generated by the script program to complete the code generation of the general input / output controller of the system-on-a-chip.
[0063] When generating system-on-a-chip (SoC) generic input / output (IOP) controller code, the script program uses pre-read and stored feature and functional data as its core basis. Through standardized code generation logic, it efficiently completes the automatic construction and integration of code for each module. The script program logically integrates the code of each module, eliminates interface conflicts between modules, optimizes the code structure, and finally outputs complete, standardized, and directly usable generic I / O controller code for SoC development. This achieves full automation from data configuration to code generation, significantly improving the design efficiency and reliability of the controller.
[0064] In some embodiments of this disclosure, a method is used to record the characteristic data of general-purpose inputs and outputs (GPIOs) through configuration files and the functional data of each GPIO through configuration tables. A script program then automatically generates code based on these two types of data, completely changing the traditional model that relies on designers manually writing hardware description language (HMR) code. Addressing the characteristics of a large number of GPIOs and complex configuration requirements in system-on-a-chip (SoC), this method effectively avoids oversights and errors that are prone to occur during manual coding due to repetitive workloads and intricate details. It significantly improves the accuracy of GPIO controller code generation, greatly shortens the code development cycle, and enhances overall design efficiency. Furthermore, it eliminates the need for designers to have in-depth knowledge of the complex circuit structure of GPIO controllers and the details of hardware description languages, lowering the professional threshold for SoC GPIO controller design and enabling more designers to participate in related design work, better meeting the needs of efficient SoC design and rapid iteration.
[0065] In some embodiments of this disclosure, the feature data includes at least one of general input / output port information, register-configurable port item information, and register configuration sequence information; the functional data includes at least one of general input / output name information, model information, signal direction information, output enable control information, register read / write control information, pull-up / pull-down resistor control information, drive strength control information, and Schmitt trigger control information.
[0066] In some implementations, the configuration file records the characteristics of the General Purpose Input / Output (GPIO), which may include GPIO port information, register-configurable port entry information, and register configuration order information. The configuration table records the functional data of the GPIO, which may include GPIO name information, GPIO model information, GPIO signal direction information, output enable control information, register read / write control information, pull-up / pull-down resistor control information, drive strength control information, and Schmitt trigger control information.
[0067] In some embodiments of this disclosure, the comprehensiveness and integrity of data records can be ensured, avoiding incomplete code generation or functional abnormalities due to missing data; comprehensive feature data and functional data can accurately reflect the attributes of general inputs and outputs and the functional requirements of each general input and output, so that the generated code can fully meet the design requirements, improving the reliability and effectiveness of the design.
[0068] In some embodiments of this disclosure, the script program is a Python script; based on this, refer to... Figure 2 S26 includes:
[0069] S262. Read and parse the configuration file, and store the characteristic data of the general input and output of the system-on-a-chip as a first data structure;
[0070] S264. Read and parse the configuration table, and store the functional data of each general input and output into a second data structure;
[0071] S266. Based on the first data structure and the second data structure, generate corresponding hardware description language-based codes for the general input / output register read / write module, general input / output model management module, general input / output control module, and general input / output clock reset module according to a preset code template.
[0072] S268. Integrate the generated module codes and output the complete code for a general-purpose input / output controller.
[0073] In some implementations, the script can be a Python script. Python offers advantages such as concise syntax, strong extensibility, and a rich library of third-party libraries, enabling efficient reading, parsing, and data processing of configuration files and tables. After executing the Python script, it first reads and parses the constructed configuration file, storing the feature data of the system-on-a-chip's general-purpose inputs and outputs (GPIOs) into a first data structure. This first data structure can be one or more combinations of key-value pairs, arrays, or structures, facilitating subsequent lookup, retrieval, and processing of the feature data. Next, the script reads and parses the configuration table, storing the functional data of each GPIO into a second data structure. This second data structure can also be one or more combinations of key-value pairs, arrays, or structures, adapting to the first data structure to ensure data consistency and smooth subsequent processing. This then generates hardware description language-based code for the GPIO register read / write module, GPIO model management module, GPIO control module, and GPIO clock reset module. After the code for each module is generated, the script will integrate the code, remove redundant information, ensure smooth logical connections between modules, and finally output the complete code for a general purpose input / output (GPIO) controller.
[0074] In some implementations, during the code generation process of each module, the script program strictly follows the syntax specifications of the hardware description language to ensure that the generated register read / write module can accurately implement parameter read / write control of configurable ports, the model management module can adapt to the physical connection requirements of all ports, the input / output control module can accurately respond to the transmission direction and enable control requirements of signals, and the clock reset module can ensure the timing basis for stable operation of the controller.
[0075] In some examples, Verilog can be chosen as the hardware description language. Verilog is a widely used hardware description language in digital circuit design, with powerful circuit description capabilities and simulation support. The generated Verilog-based code can be well adapted to the digital circuit design process, facilitating subsequent simulation, synthesis, and implementation.
[0076] In some embodiments of this disclosure, during the code integration process, the script performs syntax checks on the code of each module to ensure that the integrated code is free of syntax errors. At the same time, it optimizes the code structure, reduces redundant code, and improves the execution efficiency and resource utilization of the code.
[0077] In some embodiments of this disclosure, the consistency and standardization of generated code can be ensured by using preset code templates. The independent generation and integration of code for each module facilitates subsequent modification and maintenance of individual modules. At the same time, code based on hardware description language can be directly applied to the digital circuit design process, improving the coherence of the design.
[0078] In some embodiments of this disclosure, the preset code template predefines the syntax structure, interface definition, logical call relationship and comment specifications of each module's code. The script program automatically fills in the data and generates the code of the corresponding module by matching the data fields in the first data structure and the second data structure with the variable fields in the code template.
[0079] In some implementations, predefined code templates predefine the syntax structure, interface definitions, logical call relationships, and commenting conventions for each module's code. These conventions ensure the generated code's standardization, readability, and maintainability. (See also...) Figure 3 The script program automatically fills in the corresponding data by matching the data fields in the first and second data structures with the variable fields in the code template, thereby generating hardware description language-based code for the General Purpose Input / Output (GPIO) register read / write module, GPIO model management module, GPIO control module, and GPIO clock reset module. After the code for each module is generated, the script integrates these module codes, removes redundant information, ensures smooth logical connections between modules, and finally outputs the complete GPIO controller code.
[0080] In some embodiments of this disclosure, the specifications of each module's code can be clearly defined through preset code templates. The script program automatically fills in the code by matching data fields with variable fields, ensuring the syntactic correctness and logical integrity of the generated code and reducing errors that may be caused by human intervention. At the same time, the standardized code structure and interface definitions improve the readability and reusability of the code, facilitating collaboration among different designers and subsequent code expansion.
[0081] In some embodiments of this disclosure, the method further includes:
[0082] In response to detecting an update to the configuration file and / or the configuration table, obtain the feature data and / or function data in the updated configuration file and / or the updated configuration table;
[0083] The execution script program reads and stores the feature data and function data from the configuration file and the configuration table, respectively, including:
[0084] Execute the script program to read and store the updated feature data and / or updated function data respectively.
[0085] In some implementations, refer to Figure 4 In the actual design process, if an update to the configuration file and / or configuration table is detected, the terminal device will obtain the feature data and / or functional data from the updated configuration file and / or configuration table. Then, the Python script can be re-executed. The script will read the updated feature data and / or updated functional data and store them as corresponding first and second data structures, respectively. Following the code generation and integration process described above, it will automatically generate the updated code for the general input / output controller to adapt to changes in design requirements.
[0086] In some embodiments of this disclosure, timely response to configuration updates can be achieved, enabling designers to quickly generate updated code by simply updating configuration files and / or configuration tables when design requirements change, without modifying scripts and code templates. This greatly improves design flexibility and scalability, shortens project iteration cycles, and reduces maintenance costs.
[0087] In some embodiments of this disclosure, the configuration file is a text file in markup language format, and the configuration table is a spreadsheet file; the first data structure and the second data structure are at least one of key-value pair structure, array structure, or structure.
[0088] In some implementations, the configuration file can be a text file in markup language format. This format is highly readable, easy to edit and parse, and can clearly and accurately store relevant feature data. The configuration table can be a spreadsheet file. Spreadsheets are intuitive, easy to use, and facilitate batch editing and management, making them suitable for organizing a large amount of general input / output functional data. After executing the Python script, the script first reads and parses the constructed configuration file, storing the feature data of the system-on-a-chip's general inputs and outputs into a first data structure. The first data structure can be one or more combinations of key-value pairs, arrays, or structures. This data structure facilitates subsequent searching, calling, and processing of feature data. Next, the script reads and parses the configuration table, storing the functional data of each general input / output into a second data structure. The second data structure can also be one or more combinations of key-value pairs, arrays, or structures, adapting to the first data structure to ensure data storage consistency and smooth subsequent processing.
[0089] In some examples, configuration files can be text files in YAML (YAML Ain't Markup Language) format. YAML format is concise, clear, easy for humans to read and write, and can better meet the storage and management needs of feature data. Configuration tables can be Excel spreadsheets. Excel spreadsheets have convenient operation methods in data editing, filtering, sorting, etc., which makes it convenient for designers to manage and maintain large amounts of functional data.
[0090] In some examples, Python scripts can read YAML configuration files and Excel configuration tables, storing them in their respective list elements. Based on the read GPIO model data and configuration data, GPIO register read / write modules, GPIO model management modules, GPIO input / output control modules, and GPIO clock reset modules are generated, ultimately completing the automated code generation for the GPIO controller. If the design is modified or the process is upgraded, users only need to update the YAML configuration file and Excel table, greatly simplifying the design complexity and improving development efficiency.
[0091] In some embodiments of this disclosure, both the first data structure and the second data structure can be one or more combinations of key-value pairs, array structures, or structures, which are mutually compatible to ensure data storage consistency and smooth subsequent processing. Appropriate file types and data structures can improve the efficiency of data storage and processing, ensuring that script programs can quickly and accurately read and parse data, providing efficient support for code generation.
[0092] This disclosure provides a method for generating code for general-purpose input / output (GPIO) controllers. This method uses configuration files to record characteristic data of GPIOs and configuration tables to record functional data of each GPIO. A script then automatically generates code based on these two types of data, completely changing the traditional model that relies on designers manually writing hardware description language (HMR) code. Addressing the characteristics of numerous GPIOs and complex configuration requirements in system-on-a-chip (SoC) designs, this method effectively avoids oversights and errors that can easily occur during manual coding due to repetitive workloads and intricate details. It significantly improves the accuracy of GPIO controller code generation, greatly shortens the code development cycle, and enhances overall design efficiency. Furthermore, it eliminates the need for designers to have in-depth knowledge of the complex circuit structure and details of HMRs, lowering the professional threshold for SoC GPIO controller design and enabling more designers to participate in related design work, better meeting the needs of efficient SoC design and rapid iteration.
[0093] It is understood that the various embodiments of the methods described in this specification are presented in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. Related details can be found in the descriptions of other method embodiments.
[0094] It should be understood that although the steps in the flowcharts shown in the accompanying drawings are displayed sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the accompanying drawings may include multiple steps or stages, which are not necessarily completed at the same time, but may be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but may be performed alternately or in turn with other steps or at least a portion of the steps or stages of other steps.
[0095] Based on the description of the above-described embodiments of the code generation method for a chip general-purpose input / output (GPIO) controller, this disclosure also provides a code generation apparatus for a GPIO controller to implement the aforementioned code generation method. The apparatus may include a system (including a distributed system), software (application), module, component, controller, server, terminal, etc., using the method described in the embodiments of this specification, combined with necessary hardware implementation. Based on the same innovative concept, the apparatuses in one or more embodiments provided in this disclosure are as described in the following embodiments. Since the implementation schemes and methods for solving the problem are similar, the implementation of specific apparatuses in the embodiments of this specification can refer to the implementation of the aforementioned method, and repeated details will not be repeated. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatuses described in the following embodiments are preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0096] Figure 5 This is a schematic block diagram illustrating a code generation device for a chip general-purpose input / output controller according to an exemplary embodiment. The device can be the aforementioned terminal, a server, or a module, component, device, control unit, etc., integrated into the terminal. For details, please refer to... Figure 5 The device 100 may include: a first configuration module 120, a second configuration module 140, a processing module 160, and a code generation module 180. The first configuration module 120 is used to construct a configuration file, which records the characteristic data of the general input / output (GIO) of the system-on-a-chip (SoC). The second configuration module 140 is used to construct a configuration table, which records the functional data of the GIO of the SoC. The processing module 160 is used to execute a script program, which reads and stores the characteristic data and functional data from the configuration file and the configuration table, respectively. The code generation module 180 is used to automatically generate the code for each module of the GIO based on the characteristic data and the functional data, thereby completing the code generation for the GIO controller of the SoC.
[0097] In some embodiments of the device, the script program is a Python script, and the code generation module 180 is further configured to read and parse the configuration file, storing the feature data of the general-purpose input / output of the system-on-a-chip as a first data structure; and to read and parse the configuration table, storing the functional data of each general-purpose input / output as a second data structure; and to generate, according to the first data structure and the second data structure, corresponding general-purpose input / output register read / write module, general-purpose input / output model management module, general-purpose input / output control module, and general-purpose input / output clock reset module code based on a preset code template; and to integrate the generated module codes to output the complete general-purpose input / output controller code.
[0098] In some embodiments of the device, the processing module 160 is further configured to, in response to detecting an update to the configuration file and / or the configuration table, obtain feature data and / or functional data in the updated configuration file and / or the updated configuration table; and to execute a script program to read and store the updated feature data and / or the updated functional data respectively.
[0099] In some embodiments of the device, the preset code template predefines the syntax structure, interface definition, logical call relationship and comment specifications of each module code. The script program automatically fills in the data and generates the code of the corresponding module by matching the data fields in the first data structure and the second data structure with the variable fields in the code template.
[0100] In some embodiments of the device, the configuration file is a text file in markup language format, and the configuration table is a spreadsheet file; the first data structure and the second data structure are at least one of key-value pair structure, array structure, or structure.
[0101] In some embodiments of the device, the feature data includes at least one of general input / output port information, register-configurable port item information, and register configuration sequence information; the functional data includes at least one of general input / output name information, model information, signal direction information, output enable control information, register read / write control information, pull-up / pull-down resistor control information, drive strength control information, and Schmitt trigger control information.
[0102] The modules in the code generation device for the aforementioned chip general-purpose input / output controller can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independent of the processor in a computer device, or stored in software in the memory of a computer device, so that the processor can call and execute the operations corresponding to each module.
[0103] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a code generation method for a chip-based general-purpose input / output controller.
[0104] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0105] Based on the foregoing description of the relevant methods and apparatus embodiments, this disclosure also provides a computer device, including a memory and a processor. The memory stores a computer program, which, when executed by the processor, implements the code generation method for a chip general-purpose input / output controller described in any embodiment of this specification.
[0106] Based on the foregoing description of the relevant methods and apparatus embodiments, this disclosure also provides a computer-readable storage medium that, when the instructions in the computer-readable storage medium are executed by the processor of a computer device, enables the computer device to implement the code generation method for a chip general-purpose input / output controller as described in any embodiment of this disclosure.
[0107] Based on the foregoing description of the relevant methods and apparatus embodiments, this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the code generation method for a chip general-purpose input / output controller as described in any embodiment of this specification.
[0108] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. In particular, hardware + program embodiments are relatively simple in description because they are fundamentally similar to method embodiments; relevant parts can be referred to the descriptions in the method embodiments.
[0109] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0110] It should be noted that the apparatus, computer equipment, storage medium, and computer program products described above may also include other implementation methods according to the description of the method embodiments. Specific implementation methods can be found in the description of the relevant method embodiments. Furthermore, new embodiments formed by combinations of features from various methods, apparatuses, devices, and server embodiments still fall within the scope of this disclosure and will not be elaborated upon here.
[0111] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling and communication connections between the devices or units shown or described can be implemented through direct and / or indirect coupling / connection, through standard or custom interfaces or protocols, and can be implemented electrically, mechanically, or in other forms.
[0112] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0113] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A method for generating code for a chip-based universal input / output controller, characterized in that, The method includes: A configuration file is constructed to record the characteristic data of the general inputs and outputs of the system-on-a-chip. A configuration table is constructed, which is used to record the general input and output functional data of the system-on-a-chip; Execute the script program to read and store the feature data and function data of the configuration file and the configuration table respectively; Based on the feature data and the functional data, the script program automatically generates the code for each module of the general input / output, thus completing the code generation for the general input / output controller of the system-on-a-chip.
2. The method according to claim 1, characterized in that, The script program is a Python script. Based on the feature data and the functional data, the script program automatically generates the code for each module of the general input / output (GUID) system, completing the code generation for the GUID controller of the system-on-a-chip, including: The configuration file is read and parsed, and the characteristic data of the general input and output of the system-on-a-chip are stored as a first data structure; Read and parse the configuration table, and store the functional data of each general input and output into a second data structure; Based on the first data structure and the second data structure, corresponding hardware description language-based codes for the general input / output register read / write module, general input / output model management module, general input / output control module, and general input / output clock reset module are generated according to the preset code template. The generated module code is integrated to output the complete code for a general-purpose input / output controller.
3. The method according to claim 1, characterized in that, The method further includes: In response to detecting an update to the configuration file and / or the configuration table, obtain the feature data and / or function data in the updated configuration file and / or the updated configuration table; The execution script program reads and stores the feature data and function data from the configuration file and the configuration table, respectively, including: Execute the script program to read and store the updated feature data and / or updated function data respectively.
4. The method according to claim 2, characterized in that, The preset code template predefines the syntax structure, interface definition, logical call relationship and comment specifications of each module code. The script program automatically fills in the data and generates the code of the corresponding module by matching the data fields in the first data structure and the second data structure with the variable fields in the code template.
5. The method according to claim 2, characterized in that, The configuration file is a text file in markup language format, and the configuration table is a spreadsheet file; the first data structure and the second data structure are at least one of key-value pair structure, array structure, or structure.
6. The method according to claim 1, characterized in that, The feature data includes at least one of the following: general input / output port information, register-configurable port item information, and register configuration sequence information; the functional data includes at least one of the following: general input / output name information, model information, signal direction information, output enable control information, register read / write control information, pull-up / pull-down resistor control information, drive strength control information, and Schmitt trigger control information.
7. A code generation device for a chip universal input / output controller, characterized in that, The device includes: The first configuration module is used to build a configuration file, which is used to record the characteristic data of the general input and output of the system-on-a-chip. The second configuration module is used to construct a configuration table, which is used to record the general input and output functional data of the system-on-a-chip. The processing module is used to execute a script program, which reads the feature data and function data of the configuration file and the configuration table respectively and stores them respectively; The code generation module is used to automatically generate the code for each module of the general input / output based on the feature data and the functional data through the script program, thereby completing the code generation of the general input / output controller of the system-on-a-chip.
8. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.