Code generation method and device for hardware module, storage medium and program product
By automatically generating hardware module code using preset rules, the problem of low efficiency in hardware module code generation in existing technologies is solved, and a unified approach to efficient automated generation and design verification of hardware module code is achieved.
Patent Information
- Application Number
- CN202511178447.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-10-28
AI Technical Summary
In large-scale chip integration scenarios, existing technologies require manually defining module configuration information, resulting in low efficiency in hardware module code generation and an inability to achieve automation.
By using preset module configuration generation rules, preset command generation rules, and preset hardware code generation rules, hardware module code is automatically generated, including determining module configuration information, generating module command sets, and generating hardware code.
It enables automated generation of hardware module code, improves code generation efficiency, reduces manual configuration workload, and enhances the efficiency of design or verification.
Smart Images

Figure CN120848857A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to, but is not limited to, the field of computer technology, and in particular to a method, apparatus, storage medium, and program product for generating code for a hardware module. Background Technology
[0002] In scenarios such as large-scale integration at the top level of a chip, it is necessary to generate hardware description language (HDL) code files corresponding to the modules based on the module configuration information. Then, through various synthesis programs, these files can be translated into gate-level netlists, which are then processed into actual hardware implementations. Module configuration information is generally defined by hand, which makes the hardware module code generation work laborious and inefficient. Summary of the Invention
[0003] In view of this, the present disclosure provides at least one method, device, storage medium, and program product for generating code for a hardware module.
[0004] The technical solution of this disclosure embodiment is implemented as follows:
[0005] On one hand, this disclosure provides a method for generating code for a hardware module, the method comprising:
[0006] In response to the module instantiation generation command, the module configuration information is generated by using the preset module configuration generation rules to generate the module parameters corresponding to the code module to be generated, and the corresponding module configuration information is obtained.
[0007] Based on module configuration information, and using preset command generation rules, a set of module commands corresponding to the code module to be generated is generated.
[0008] Based on the module command set and module configuration information, and in accordance with the preset module hardware code generation rules, generate all instantiated hardware code corresponding to the module to be generated.
[0009] In the above embodiments, by using preset module configuration generation rules, preset command generation rules, and preset module hardware code generation rules, module configuration information can be determined by combining preset module configuration rules and module parameters under a single module instantiation generation command. Based on the preset command generation rules and module configuration information, a set of module commands can be generated, and module hardware code can be generated based on the preset module hardware code generation rules. This enables the automatic generation of all executable instantiated hardware code with a single command: based on a single module instantiation generation command, a set of module commands is generated from the module configuration information, and then all instantiated hardware code corresponding to the module is generated based on the module generation command, thus achieving automated generation of hardware module code and improving the generation efficiency of hardware module code.
[0010] In some embodiments, the preset module configuration generation rules include configuration code generation rules and configuration file generation rules. Using the preset module configuration generation rules, module configuration information is generated for the module parameters corresponding to the module to be generated code, and the corresponding module configuration information is obtained. This includes: for any module parameter, based on the corresponding configuration information, generating corresponding parameter configuration information using the configuration code generation rules; for each parameter configuration information, using the configuration file generation rules, cyclically generating corresponding module configuration information that conforms to the configuration file syntax.
[0011] In some embodiments, the preset module configuration generation rules include general module configuration generation rules, private module configuration generation rules, and module dependency configuration generation rules; module parameters include public module parameters, private module parameters, and dependent module parameters that the code module to be generated needs to depend on; in response to a module instantiation generation command, the preset module configuration generation rules are used to generate module configuration information for the module parameters corresponding to the code module to be generated, thereby obtaining the corresponding module configuration information, including: for each instantiation generation command in the module instantiation generation command, using the general module configuration generation rules and based on the public module parameters, generating corresponding general instantiation configuration information; for each instantiation generation command, using the private module configuration generation rules and based on the private module parameters, generating corresponding private instantiation configuration information; for each instantiation generation command, using the module dependency configuration generation rules and based on the dependent module parameters, generating corresponding dependency instantiation configuration information; and determining the general instantiation configuration information, private instantiation configuration information, and dependency instantiation configuration information corresponding to different instantiation generation commands in the module instantiation generation command as module configuration information.
[0012] In the above embodiments, the module instantiation generation command includes at least one instantiation generation command. Based on each instantiation generation command, corresponding instantiation configuration information can be generated, thereby obtaining module configuration information. By integrating the commands, the efficiency of generating module configuration information is improved.
[0013] In some embodiments, after obtaining the corresponding module configuration information, the method further includes: converting the module configuration information into module parameter definitions that conform to a preset syntax.
[0014] In the above embodiments, converting module configuration information into module parameter definitions can generate unified configuration information, thereby improving the efficiency of subsequent design, verification, or architecture usage.
[0015] In some embodiments, the preset command generation rules also include the code file compilation order; the method further includes: generating a corresponding module file list for the hardware language files of each command included in the module command set, according to the code file compilation order.
[0016] In the above embodiment, all generated files of the command are placed in a module file list in order. This module file list can be used for subsequent compilation, verification, synthesis, and backend. It is a register transfer level file and provides a basis for use in subsequent processes.
[0017] In some embodiments, the hardware language files of each command included in the module command set are used to generate a corresponding module file list according to the compilation order of the code files. This includes: identifying the absolute path of each command included in the module command set from the module configuration information; concatenating the absolute path of each command to obtain the directory where the corresponding file is located, and obtaining the file name of each command based on the module configuration information; for each command, concatenating the absolute path of the corresponding hardware language file based on the directory where the corresponding file is located and the file name; and generating a corresponding module file list for each command included in the module command set in the form of absolute file paths according to the compilation order of the code files.
[0018] In the above embodiment, the module file list lists the absolute file path corresponding to the hardware language file of each command. In this way, if the hardware language file is used later, the corresponding hardware language file can be obtained based on the corresponding absolute file path.
[0019] In some embodiments, based on the module command set and module configuration information, and according to preset module hardware code generation rules, the module hardware code corresponding to the code module to be generated is generated, including: determining the mixed language code corresponding to the code module to be generated based on the module configuration information; for each command included in the module command set, converting the initial related language code included in the mixed language code into language code, and determining the language code and the initial language code included in the language code as the corresponding intermediate language code; for each command, executing the corresponding intermediate language code, determining the corresponding target language code, and generating all corresponding hardware codes based on the corresponding target language code; and determining all hardware codes corresponding to different commands in the module command set as all instantiated hardware codes.
[0020] In the above embodiments, corresponding hardware code is generated for each command in the module command set. Thus, if the module command set contains all commands of all design codes for all modules, the corresponding hardware code can be generated at once, improving the efficiency of hardware module code generation.
[0021] In another aspect, embodiments of this disclosure provide a code generation apparatus for a hardware module, comprising: a configuration generation module, a command generation module, and a code generation module, wherein:
[0022] The configuration generation module is used to respond to the module instantiation generation command, and generate module configuration information for the module parameters corresponding to the code module to be generated using preset module configuration generation rules, so as to obtain the corresponding module configuration information.
[0023] The command generation module is used to generate a set of module commands corresponding to the code module to be generated, based on the module configuration information and using preset command generation rules.
[0024] The code generation module is used to generate all instantiated hardware code corresponding to the module to be generated, based on the module command set and module configuration information, and according to the preset module hardware code generation rules.
[0025] On the other hand, embodiments of this disclosure provide a computer device including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the program to implement some or all of the steps in the code generation method of the above-described hardware module.
[0026] In another aspect, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps in the code generation method for the aforementioned hardware module.
[0027] In another aspect, embodiments of this disclosure provide a computer program including computer-readable code, wherein when the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps in the code generation method for implementing the above-described hardware module.
[0028] In another aspect, embodiments of this disclosure provide a computer program product, the computer program product including a non-transitory computer-readable storage medium storing a computer program, wherein when the computer program is read and executed by a computer, it implements some or all of the steps in the code generation method for the above-described hardware module.
[0029] In this embodiment of the disclosure, by setting preset module configuration rules, preset command generation rules, and preset module hardware code generation rules, module configuration information can be determined by combining preset module configuration rules and module parameters under a single module instantiation generation command. Based on the preset command generation rules and module configuration information, a set of module commands can be generated, and module hardware code can be generated based on the preset module hardware code generation rules. This enables the automatic generation of all executable instantiated hardware code with a single command: based on a single module instantiation generation command, a set of module commands is generated from module configuration information, and then all instantiated hardware code is generated based on the module generation command, thus achieving automated generation of hardware module code and improving the generation efficiency of hardware module code.
[0030] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of this disclosure. Attached Figure Description
[0031] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure.
[0032] Figure 1 A schematic diagram illustrating the implementation process of an exemplary method for generating module code for related technologies;
[0033] Figure 2 A schematic diagram illustrating the implementation flow of a code generation method for a hardware module provided in this embodiment of the disclosure;
[0034] Figure 3 This disclosure provides an exemplary implementation flow diagram for generating module configuration information. Figure 1 ;
[0035] Figure 4 This disclosure provides an exemplary implementation flow diagram for generating module configuration information. Figure 2 ;
[0036] Figure 5 A schematic diagram illustrating an exemplary implementation process for generating a list of module files, provided for embodiments of this disclosure;
[0037] Figure 6 A schematic diagram illustrating an exemplary implementation process for generating module hardware code, provided for embodiments of this disclosure;
[0038] Figure 7A This is a schematic diagram illustrating an exemplary implementation process for generating module configuration information and parameter definitions, provided in an embodiment of this disclosure.
[0039] Figure 7B This is a schematic diagram illustrating an exemplary implementation process for generating a set of module commands and a list of files, provided in an embodiment of this disclosure.
[0040] Figure 7C A schematic diagram illustrating an exemplary implementation process for generating module hardware code, provided for embodiments of this disclosure;
[0041] Figure 8 A schematic diagram of the composition structure of a code generation device for a hardware module provided in this embodiment of the disclosure;
[0042] Figure 9 This is a schematic diagram of the hardware entity of a computer system provided in an embodiment of the present disclosure. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this disclosure clearer, the technical solutions of this disclosure are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this disclosure. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0044] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used herein is for descriptive purposes only and is not intended to limit this disclosure.
[0046] Before providing a further detailed description of the embodiments of this disclosure, the nouns and terms involved in the embodiments of this disclosure will be explained, and the nouns and terms involved in the embodiments of this disclosure shall be subject to the following interpretations.
[0047] Digital integrated circuits, especially computationally intensive digital integrated circuits, include field-programmable gate arrays (FPGAs) and other programmable logic circuits, as well as computer-aided design digital integrated circuits such as application-specific integrated circuits (ASICs). In the hardware design or verification of digital integrated circuits, the widely used programming languages are register transfer level (RTL) hardware description languages, such as, but not limited to, Verilog Hardware Description Language, Very-High-Speed Integrated Circuit Hardware Description Language (VHDL), Advanced Boolean Expression Language (ABEL), Common Universal Programming Language (CUPL), Altera Hardware Description Language (AHDL), Programmable Array Logic Assembler (PALASM), SystemVerilog, and any combination of the above languages. HDL code can be translated into a gate-level netlist using various synthesis programs. Then, traditional physical design tools can process the gate-level netlist into a real hardware implementation.
[0048] To better understand the code generation method for the hardware module provided in the embodiments of this disclosure, the code modification schemes used in related technologies will be described below.
[0049] In related technologies, there are issues with writing hardware design or verification code using HDL: In scenarios such as large-scale integration at the chip top level, there is a need to modify code content such as the top-level name of the module, interface name, internal signal name, and internal signal bit width multiple times. Module or interface names reflect the connection relationships between the module and its neighboring modules, facilitating rapid integration of modules at the top level. The following code demonstrates Verilog code with the module name "inst_exam_0", the signal prefix "inst_exam_0_", and a signal bit width of 4.
[0050]
[0051] To modify the module name, interface name, or signal width, 13 changes are required; to generate 10 similar codebases, 130 changes are needed. As the module codebase grows, the number of modifications increases. Furthermore, there are needs to configure signals with multiple widths, display them based on configuration switch codes, cyclically copy or systematically modify code according to configurations, or use Python functions to empower RTL code writing.
[0052] In related existing technologies, there is also a method for generating module HDL code, such as... Figure 1 As shown, by inputting the module configuration 11, the module unique identifier command 12, and the module's mixed Python and HDL code 13, the Python+HDL generation method 14 is used to generate an instantiated HDL code corresponding to the module, namely the module HDL code 15.
[0053] The hardware code generation scheme that involves modifying the code used in the aforementioned related technologies has the following problems: 1) It requires a lot of modifications or manual definition of configuration files, resulting in low code generation efficiency due to the large workload; 2) It cannot achieve automated code generation of hardware modules.
[0054] This disclosure provides a method for generating code for a hardware module, which can be executed by a processor of a computer device. The computer device can refer to a server, laptop computer, tablet computer, desktop computer, smart TV, set-top box, mobile device (e.g., mobile phone, portable video player, personal digital assistant, dedicated messaging device, portable gaming device), or other device with data processing capabilities. Figure 2 This is a schematic diagram illustrating the implementation flow of a code generation method for a hardware module provided in an embodiment of this disclosure, as shown below. Figure 2 As shown, the method includes the following steps S201 to S203:
[0055] Step S201: In response to the module instantiation generation command, the module configuration information is generated for the module parameters corresponding to the code module to be generated using the preset module configuration generation rules, and the corresponding module configuration information is obtained.
[0056] Here, the module to be generated can be a module component included in the Network on Chip (NoC), such as: Initiating Network Interface (INIU), Target Network Interface (TNIU), Router, Link, and LowPower modules. Of course, the module to be generated can also be a module that can independently implement functions, such as an adder, flip-flop, register, or other modules.
[0057] Here, module parameters are the parameters required to generate the module configuration information corresponding to the code module to be generated, including but not limited to: parameters of the characteristics of each module component itself, the common top-level module parameters of the modules that need to be used in the process of generating their own module configuration, and the module parameters of other modules that need to be used in the process of generating their own module configuration.
[0058] Here, the module instantiation generation command is a combination of all commands that execute the module hardware code to generate the module and all instantiations. For example, if each module in Module 1 and Module 2 corresponds to 10 instantiations, and if instantiation configurations for instantiations 2, 5, and 7 are implemented for Module 1, and instantiation configurations for instantiations 3, 5, and 7 are implemented for Module 2, then the module instantiation generation command will set the instantiation identifier information for instantiations 2, 5, and 7 in Module 1, and the instantiation identifier information for instantiations 3, 5, and 7 in Module 2. If the instantiation configuration information is generated for all instantiations in Module 1 and Module 2, then in this case, the module instantiation generation command will not include identifier information for Module 1, that is, it will generate all configuration information for all instantiations of Module 1. Exemplarily, the information included in the module instantiation generation command can be set based on actual needs and application scenarios, and this disclosure does not limit this.
[0059] Here, the preset module configuration generation rules are pre-set module configuration generation rules. For example, the preset module configuration generation rules define general rules for parameter generation, module-private rules other than the general rules, and rules for modules that depend on other module configurations for generation. Of course, other rules can also be set, which can be set based on actual needs and application scenarios. This disclosure does not limit this.
[0060] Here, after obtaining the module parameters, the module instantiation generation command, and the preset module configuration generation rules, the computer device can generate module configuration information based on the module instantiation generation command and the preset module configuration generation rules, thereby obtaining the corresponding module configuration information.
[0061] In some implementations, if the module instantiation generation command contains unique identifier information for the module, then by combining the preset module configuration generation rules and module parameters, the obtained configuration information is all the configuration information for one instantiation of that module. For example, if the module instantiation generation command contains identifier information for instantiation 1 of module 1, then the obtained module configuration information is all the configuration information for instantiation 1 of module 1.
[0062] In some implementations, if the module instantiation generation command does not carry unique identification information, then by combining the preset module configuration generation rules and module parameters, the obtained configuration information is all the configuration information of all instantiations in that module. For example, if the module instantiation generation command contains module 1, then the obtained module configuration information is all the configuration information of all instantiations of module 1.
[0063] In some implementations, multiple modules can be set in the module instantiation generation command. Whether each module carries unique identification information can also be set based on actual needs and application scenarios, and this disclosure does not limit this. For example, if the module instantiation generation command sets the identification information of instantiations 2, 3, and 5 of module 1, as well as module 2 and module 3, then, combined with the preset module configuration generation rules and module parameters, the result is all the configuration information of instantiations 2, 3, and 5 in module 1, and all the configuration information of all instantiations of module 2 and module 3.
[0064] Step S202: Based on the module configuration information, use the preset command generation rules to generate the module command set corresponding to the code module to be generated.
[0065] Here, the preset command generation rules pre-set the command generation rules, which define all the generation commands or the generation order between commands of the module design code, such as, but not limited to, Makefile, Shell, Python, Perl, etc., and any combination thereof.
[0066] For example, the preset command generation rules define general rules for parameter generation. For instance, the unique identifiers in the module commands can be generated in a regular manner using a loop, such as 0, 1, 2, ... At the same time, mixed code, such as Python and Makefile mixed code, can define the generation order between files and the constraints of generation to achieve incremental compilation and improve generation efficiency.
[0067] Here, whether the generated module command set is the set of all commands instantiated by module 1 or the set of all commands instantiated by all modules depends on the module instantiation generation command in step S201. Of course, the module instantiation generation command can also be re-entered, consistent with the above. If the module instantiation generation command carries the unique identifier information of the instantiation, then the set of all commands instantiated by module 1 is generated. If it does not carry the unique identifier information, the set of all commands instantiated by all modules is generated.
[0068] Here, if the module instantiation generation command is re-entered here, the module instantiation generation command in step S201 is the set of commands configured to generate the module. If the module instantiation generation command is not re-entered here, the module instantiation generation command in step S201 includes both the set of commands configured to generate the module and the set of commands to generate the module command set. For example, it can be set based on actual needs and application scenarios, and this disclosure does not limit it.
[0069] Here, the module command set includes a set of public file generation commands and a configuration of private file generation commands.
[0070] Step S203: Based on the module command set and module configuration information, generate all instantiated hardware code corresponding to the module to be generated according to the preset module hardware code generation rules.
[0071] Here, the preset module hardware code generation rules define general rules for parameter generation. For example, parameters can be configured using files in formats such as JSON, YAML, and Excel, or a combination of these formats. These files can include parameter names and values. If a module in the module command set does not carry unique instantiation identification information, then all instantiated hardware code includes all instantiated code files corresponding to the module to be generated.
[0072] Here, after obtaining the module configuration information and the module command set, the computer device generates all instantiated hardware code corresponding to the module to be generated, according to the preset module hardware code generation rules.
[0073] In this embodiment of the disclosure, by setting preset module configuration rules, preset command generation rules, and preset module hardware code generation rules, module configuration information can be determined by combining preset module configuration rules and module parameters under a single module instantiation generation command. Based on the preset command generation rules and module configuration information, a set of module commands can be generated, and module hardware code can be generated based on the preset module hardware code generation rules. This enables the automatic generation of all executable instantiated hardware code with a single command: based on a single module instantiation generation command, a set of module commands is generated from the module configuration information, and then all instantiated hardware code corresponding to the module is generated based on the module generation command, thus achieving automated generation of hardware module code and improving the generation efficiency of hardware module code.
[0074] In some embodiments, the preset module configuration generation rules include configuration code generation rules and configuration file generation rules; such as Figure 3As shown, step S201 above, "using preset module configuration generation rules to generate module configuration information for the module parameters corresponding to the code module to be generated, and obtaining the corresponding module configuration information," may include the following steps S301 and S302:
[0075] Step S301: For any module parameter, based on the corresponding configuration information, generate the corresponding parameter configuration information using the configuration code generation rules.
[0076] In the embodiments of this application, the configured code generation rules can be Python code generation rules, and the preset module configuration generation rules can include the configured code generation rules.
[0077] For example, for any module parameter, the corresponding parameter configuration information can be generated using configuration code generation rules based on the corresponding configuration information. For the parameter of module name, there are 10,000 configurations, from module 1 to 10,000. In this case, Python can use the number variable and for loop to design the name parameter and obtain the parameter configuration information of the module name.
[0078] Step S302: For each parameter configuration information, use the configuration file generation rules to generate the corresponding module configuration information that conforms to the configuration file syntax in a loop.
[0079] In the embodiments of this application, the configuration file generation rule can be a configuration file (CFG) generation rule, and the preset module configuration generation rule can include the configuration file generation rule.
[0080] For example, for each parameter configuration information, the implementation of generating corresponding module configuration information that conforms to the configuration file syntax by using configuration file generation rules can be as follows: for parameter configuration information, such as the module name parameter configuration information, generate corresponding code that conforms to CFG syntax by using CFG generation rules.
[0081] In this embodiment of the disclosure, the module configuration information is generated based on the module parameters using Python+CFG generation rules. The corresponding module configuration information can be obtained directly without the need for manual configuration of module configuration information, which can improve the efficiency of module configuration.
[0082] In some embodiments, the preset module configuration generation rules include general module configuration generation rules, private module configuration generation rules, and module dependency configuration generation rules; module parameters include public module parameters, private module parameters, and dependent module parameters that the code module to be generated needs to depend on; such as Figure 4As shown, step S201 above, "in response to the module instantiation generation command, using preset module configuration generation rules, generating module configuration information for the module parameters corresponding to the code module to be generated, and obtaining the corresponding module configuration information," may include the following steps S401 to S404:
[0083] Step S401: For each instantiation generation command in the module instantiation generation command, generate the corresponding instantiation general configuration information based on the common module parameters using the module general configuration generation rules.
[0084] Here, the module general configuration generation rules define general rules for parameter generation. For example, the module name parameters can be generated in a regular manner in a loop, such as "inst_exam_0", "inst_exam_1", "inst_exam_2", etc.; and corresponding instantiation general configuration information can be generated for each module.
[0085] Here, module parameters are the parameters required to generate the module configuration information corresponding to the code module to be generated, including but not limited to: parameters of the characteristics of each module component itself (private module parameters), the common top-level module parameters of the module that need to be used in the process of generating its own module configuration (common module parameters), and the module parameters of other modules that need to be used in the process of generating its own module configuration (dependent module parameters that the code module to be generated needs to depend on).
[0086] For example, common module parameters can be top-level module configurations shared by modules, and can be used as configurations shared by multiple modules.
[0087] Here, if the module instantiation generation command generates configuration information for instantiation 2 of module 1, then the general instantiation configuration information will be generated based on the common module parameters; if the module instantiation generation command generates configuration information for all instantiations of module 1, then the general instantiation configuration information for all instantiations of module 1 will be generated based on the common module information.
[0088] Step S402: For each instantiation generation command, use the module private configuration generation rules and generate the corresponding instantiation private configuration information based on the private module parameters.
[0089] Here, the module-specific configuration generation rules define special rules for parameter generation. For example, they set unique names for modules instead of simply setting the module name according to the general name mentioned above. Therefore, if there is a duplicate definition between the module-specific configuration generation rules and the general configuration generation rules, the configuration information defined by the module-specific configuration generation rules takes precedence over the configuration information defined by the general configuration generation rules. For instance, if the module name parameter generated above is "inst_exam_2", but the module name in the module-specific configuration generation rules is "inst_spec", then the final name of the module will be "inst_spec_".
[0090] For example, the private module parameters can be: the bit width of INIU, the address mapping of TNIU, the arbitration method of Router, the pipeline switch of LINK, the cache depth of Low Power, the connectivity parameters of INIU and TNIU, etc.
[0091] Step S403: For each instantiation generation command, use the module dependency configuration generation rules to generate the corresponding instantiation dependency configuration information based on the dependent module parameters.
[0092] Here, the module dependency configuration generation rules define the situations in which a module needs to use the module parameters of other modules. For example, the module data bit width parameter always subscribes to the bit width parameter in other module configurations (such as the top-level module configuration). Therefore, the bit width of this module can be controlled based on the changes in the bit width of the top-level module configuration.
[0093] For example, the dependent module parameters that the code module to be generated depends on can be module configurations that depend on other module parameters, which can affect the generation of other parameters generated subsequently. If other subsequent parameters are not defined by the overridden configuration, they are generated using general rules and the values of their dependent preceding overridden parameters or already generated parameters.
[0094] For example, connectivity parameters for the INIU and TNIU modules, and a NoC topology directed graph are required to generate configuration information for the Router module.
[0095] Step S404: Determine the general instantiation configuration information, private instantiation configuration information, and dependency instantiation configuration information corresponding to different instantiation generation commands in the module instantiation generation commands as module configuration information.
[0096] Here, the general instantiation configuration information, private instantiation configuration information, and instantiation dependency configuration information corresponding to different instantiation generation commands in the module instantiation generation command are determined as module configuration information. In this way, all configuration information of instantiation can be obtained for each instantiation generation command.
[0097] In this embodiment of the disclosure, the module instantiation generation command includes at least one instantiation generation command. Based on each instantiation generation command, corresponding instantiation configuration information can be generated, thereby obtaining module configuration information. By integrating the commands, the efficiency of generating module configuration information is improved.
[0098] In some embodiments, the computer device may also perform the following steps: converting module configuration information into module parameter definitions that conform to a preset syntax.
[0099] Here, the module instantiation generation command can integrate a conversion command for module configuration information. That is, after obtaining the module configuration information, it automatically converts the module configuration information into module parameter definitions that conform to a preset syntax. The preset syntax can be Verilog syntax.
[0100] Here, the process of transforming module configuration information can be implemented using Python. For example, each line in the module configuration information can be transformed into a definition using Verilog syntax.
[0101] Here, the module parameter definition file (define.vh) can be used for design, verification, or architecture as a unified configuration interface.
[0102] In this embodiment of the disclosure, the command to convert module configuration information into module parameter definition is integrated into the module instantiation generation command. This allows for the simultaneous acquisition of both module configuration information and module parameter definition. It is a one-time command with an automated execution process. Furthermore, the generated module parameter definition can provide a unified interface for subsequent design, verification, or architecture, thereby improving efficiency.
[0103] In some embodiments, the preset command generation rules also include the code file compilation order, and the computer device can also perform the following steps: generate a corresponding module file list for the hardware language files of each command included in the module command set, according to the code file compilation order.
[0104] Here, the code file compilation order defines the order in which all the design code files in the module are compiled. For example, the generation process can be implemented using Python, which involves placing all the generated files of the command in a list in sequence, and then generating a file list file (module file list). The file list file can be one or multiple.
[0105] Here, the module file list can be used by compilation, verification, synthesis, and backend. It is an important document for RTL delivery, providing a basis for subsequent processes. Furthermore, the command to generate the file list can also be integrated into the module instantiation generation command, generating the module file list at the same time as generating the module command set.
[0106] In some embodiments, such as Figure 5 As shown, the above steps, which generate a corresponding module file list by taking the hardware language file of each command included in the module command set according to the compilation order of the code files, may include the following steps S501 to S504:
[0107] Step S501: Identify the absolute path of each command included in the module command set from the module configuration information.
[0108] Here, the module configuration information contains the absolute path of each command in the module command set. For example, a computer device can obtain the absolute path of each command from the module configuration information through an absolute path retrieval function.
[0109] Step S502: Construct the directory where the corresponding file is located based on the absolute path of each command, and obtain the file name of each command based on the module configuration information.
[0110] Here, the directory where the corresponding file is located can be concatenated based on the absolute path of each command. It should be noted that the absolute path of each command is a scattered string. After obtaining the scattered string, the directory where the corresponding file is located can be concatenated. In addition, the file name of each command can also be obtained from the file name retrieval function in the module configuration information.
[0111] Step S503: For each command, construct the absolute path of the corresponding hardware language file based on the directory and file name of the corresponding file.
[0112] Here, for each command, the computer device can construct the absolute path of the hardware language file based on the directory and file name of the corresponding file.
[0113] Step S504: Generate a list of corresponding module files by taking the hardware language files of each command included in the module command set, in the form of absolute file paths, according to the compilation order of the code files.
[0114] Here, the computer device generates a corresponding module file list by taking the hardware language file of each command in the module command set as the absolute path of the file and in the order of code file compilation. That is, each line in the module file list is the absolute path of the hardware language file of each command, and the order of the list is based on the order of code file compilation.
[0115] In this embodiment of the disclosure, the absolute file path corresponding to the hardware language file of each command is listed in the module file list. In this way, if the hardware language file is used later, the corresponding hardware language file can be obtained based on the corresponding absolute file path.
[0116] In some embodiments, such as Figure 6 As shown, step S203 above may include the following steps S601 to S604:
[0117] Step S601: Based on the module configuration information, determine the mixed language code corresponding to the code module to be generated.
[0118] Here, the module configuration information is the module configuration information obtained in step S201 above, and the mixed language code is based on the module configuration information. The mixed language code may include initial Python language code and at least one initial RTL-related language code. Here, at least one initial RTL-related language code may be HDL language code.
[0119] Step S602: For each command included in the module command set, convert the initial language code included in the mixed language code into a language code, and determine the language code and the initial language code included in the language code as the corresponding intermediate language code.
[0120] Here, for each command, the initial HDL language code included in the mixed language code is converted into Python language code, and the converted Python language code and the initial Python language code are determined as intermediate Python language code.
[0121] Here, the initial HDL language code in the mixed language code is converted into a string in Python language. The content of the string can be HDL language code, so that hardware code can be generated based on the intermediate Python language code later.
[0122] Here, mixed language code can be unified into Python code. The conversion process utilizes the easy-to-accumulate and concatenate string variables in Python, making it easier to generate hardware design verification files based on HDL language later.
[0123] Step S603: For each command, execute the corresponding intermediate language code, determine the corresponding target language code, and generate all corresponding hardware codes based on the corresponding target language code.
[0124] Here, for each command, the target language code for the module is generated by executing the corresponding intermediate Python language code and accumulating string variables. In this case, the compiler can add string variable initialization and HDL language hardware design verification code at the beginning and end of the intermediate Python language code. Finally, the content in the string variables is the hardware code for the module.
[0125] Here, it is also possible to write a function to execute intermediate Python code and directly write the generated string into the hardware code of the HDL language.
[0126] Step S604: Determine all hardware codes corresponding to different commands in the module command set as all instantiated hardware codes.
[0127] Here, all hardware code corresponding to different commands in the module command set is defined as all instantiated hardware code.
[0128] In this embodiment of the disclosure, corresponding hardware code is generated for each command in the module command set. Thus, if the module command set contains all commands of all design codes for all modules, the corresponding hardware code can be generated at once, improving the efficiency of hardware module code generation.
[0129] It should be noted that in related technologies, code generation is generally performed on a single instantiation of a single module, resulting in low code generation efficiency. However, in this embodiment, the generation of all hardware code for all instantiations of multiple modules is completed at once through command integration, significantly improving the code generation efficiency for hardware instantiations. Therefore, steps S601 to S604 are not obvious to those skilled in the art.
[0130] This disclosure provides an exemplary method for generating code for a hardware module, which may include steps S1 to S10:
[0131] S1. Obtain the module parameters corresponding to the code module to be generated. The module parameters include public module parameters, private module parameters, and dependent module parameters that the code module to be generated needs to depend on.
[0132] S2. In response to the module instantiation generation command, for each instantiation generation command in the module instantiation generation command, generate the corresponding instantiation general configuration information based on the common module parameters using the module general configuration generation rules.
[0133] S3. For each instantiation generation command, use the module's private configuration generation rules and generate the corresponding instantiation private configuration information based on the private module parameters.
[0134] S4. For each instantiation generation command, use the module dependency configuration generation rules to generate the corresponding instantiation dependency configuration information based on the dependent module parameters.
[0135] S5. The instantiation general configuration information, instantiation private configuration information, and instantiation dependency configuration information corresponding to different instantiation generation commands in the module instantiation generation command are determined as module configuration information.
[0136] Here, steps S1 to S5 correspond to the aforementioned step S201, and can be implemented with reference to the specific implementation of step 201. Steps S2 to S5 also correspond to the aforementioned steps S401 to S404, as well as steps S301 and S302, and can be implemented with reference to the specific implementation of steps S401 to S404, as well as steps S301 and S302.
[0137] S6. Based on the module configuration information, use the preset command generation rules to generate the module command set corresponding to the code module to be generated.
[0138] Here, step S6 corresponds to the aforementioned step S202, and the specific implementation of the aforementioned step S202 can be referred to during implementation.
[0139] S7. Based on the module configuration information, determine the mixed language code corresponding to the code module to be generated.
[0140] S8. For each command included in the module command set, convert the initial language code included in the mixed language code into a language code, and determine the language code and the initial language code included in the language code as the corresponding intermediate language code.
[0141] S9. For each command, execute the corresponding intermediate language code, determine the corresponding target language code, and generate all corresponding hardware codes based on the corresponding target language code.
[0142] S10. Determine all hardware codes corresponding to different commands in the module command set as all instantiated hardware codes.
[0143] Here, steps S7 to S10 correspond to the aforementioned steps S203 and S601 to S604. In practice, the specific implementation of the aforementioned steps S203 and S601 to S604 can be referred to.
[0144] The following describes the application of the hardware module code generation method provided in this disclosure in a real-world scenario, using the automatic generation of all instantiated design code for the hardware module as an example.
[0145] This disclosure provides a method for generating code for a hardware module. By combining a Python+CFG generation method (corresponding to the preset module configuration generation rules in the aforementioned embodiments), a Python+HDL generation method (corresponding to the preset command generation rules in the aforementioned embodiments), and a Python+RUN generation method (corresponding to the preset hardware code generation rules in the aforementioned embodiments), the method automates the generation of hardware module code. (See Figure 7.) Figures 7A to 7C As shown in the figure, the method includes the following steps S701 to S703:
[0146] Step S701: Using the Python+CFG generator 70, based on other module configurations 71, mixed Python and CFG code for the module 72, module coverage configuration 73, and generation commands 74, generate module parameter definitions 75 (e.g., define.vh file) and module configurations 76.
[0147] Here, other module configurations include 71 (corresponding to the common module parameters in the aforementioned embodiments), 73 (corresponding to the private module parameters in the aforementioned embodiments, and the dependent module parameters that the code module to be generated needs to depend on), 74 (corresponding to the module instantiation generation command in the aforementioned embodiments), 75 (corresponding to the module parameter definitions in the aforementioned embodiments), and 76 (corresponding to the module configuration information in the aforementioned embodiments); and 72 (corresponding to the module general configuration generation rules in the preset module configuration generation rules in the aforementioned embodiments, which also includes the module private configuration generation rules in the module overriding configuration, and the module dependency configuration generation rules).
[0148] Among them, configuration 71 of other modules is common configuration information. These are common configurations that may be used during the generation of the module's own configuration, such as the common top-level module configuration.
[0149] The CFG (Configuration File) in the mixed Python and CFG code 72 is for module configuration, such as but not limited to json, markdown, Yaml, etc., and any combination of the above languages; the mixed code defines the general rules for parameter generation, see the content discussed in steps S401 and S403;
[0150] Module coverage configuration 73 is a special definition outside of the general rules defined in module Python and CFG mixed code 72. This module coverage configuration has higher priority than the general rules defined in module Python and CFG mixed code 72 and affects the generation of other parameters that depend on this coverage parameter. If other subsequent parameters are not defined by the coverage configuration, they are generated using the general rules and the values of the preceding coverage parameters or the generated parameters that they depend on.
[0151] The generation command 74 can have a unique identifier or not. If it has a unique identifier, it generates all configurations of the instantiated module 1. If it doesn't have a unique identifier, it generates all configurations of all instantiated modules. Usually, it doesn't have a unique identifier.
[0152] The Python+CFG generator 70 receives inputs including other module configurations 71, mixed Python and CFG code for modules 72, module override configurations 73, and generation commands 74, and outputs the module parameter definition define.vh file 75 and module configurations 76.
[0153] Module parameter definition 75 can be used for design, verification, or architecture as a unified configuration interface;
[0154] Module configuration 76 can be a single instantiated configuration of a module, but it is usually the configuration of all instantiated modules, including public and private configurations. Module configuration can be obtained through module override configuration 73, by subscribing to other module configurations 71, or by defining general rules for mixed Python and CFG code 72.
[0155] In this way, you only need to define the mixed Python and CFG code of the module once, and then you only need to define a small number of module override configurations each time (including override configurations of this module and other modules). You can get all the configurations of all instantiations of the module with a single command, without having to manually define hundreds, thousands or even tens of thousands of configurations.
[0156] Step S702: Using Python and the RUN generator 77, based on the module configuration 76, the module Python and RUN mixed code 78, and the module generation command 79, generate a file list 710 and a set of module commands 711.
[0157] Here, module configuration 76 (corresponding to module configuration information in the aforementioned embodiments), module Python and RUN mixed code 78 (corresponding to preset command generation rules in the aforementioned embodiments), module generation command 79 (corresponding to module instantiation generation command in the aforementioned embodiments), module file list 710 (corresponding to module file list in the aforementioned embodiments), and module command set 711.
[0158] Among them, module configuration 76 is the module configuration information discussed in step S701 above;
[0159] In the mixed Python and RUN code (78), RUN refers to a set of module commands. It's a file that defines all the build commands or the build order between commands in the module's design code, such as, but not limited to, Makefile, Shell, Python, Perl, and combinations of these languages. The mixed code defines general rules for parameter generation. For example, it can use loops to generate module commands with unique identifiers like 0, 1, 2, ... Furthermore, mixed code, such as Python and Makefile mixed code, can define the build order and constraints between files to achieve incremental compilation and improve build efficiency.
[0160] Module coverage configuration 73 is a special definition outside of the general rules defined in module Python and CFG mixed code 72. This module coverage configuration has higher priority than the general rules defined in module Python and CFG mixed code 72 and affects the generation of other parameters that depend on this coverage parameter. If other subsequent parameters are not defined by the coverage configuration, they are generated using the general rules and the values of the preceding coverage parameters or the generated parameters that they depend on.
[0161] Module generation command 79 can have a unique identifier or not. If it has a unique identifier, it generates a set of commands and a list of files for all instantiations of module 1. If it does not have a unique identifier, it generates a set of commands and a list of files for all instantiations of the module. It is usually generated without a unique identifier. It should be noted that the difference between module generation command 79 and generation command 74 mentioned above is that one generates configuration, and the other generates a set of commands. In the above embodiment, the two are integrated, but this integration is not mandatory. The specific configuration can be based on actual needs and application scenarios and is not limited.
[0162] The Python+RUN generator 77 receives module configuration 76, mixed Python and RUN code for the module 78, and module generation commands 79 as inputs, and outputs a list of module files 710 and a set of module commands 711;
[0163] The output module file list 710 defines all the design code files for the module and the compilation order. This file can be used by the compiler, verifier, synthesizer, and backend, and is an important file in RTL delivery. The conversion process can be implemented using Python; that is, all the generated files of the command can be placed in a list in order, and then a file list file can be generated. There can be one file or multiple file list files.
[0164] The module command set 711 can be a single set of instantiated commands for a module, but it is typically the set of all instantiated commands for the module, including the public file generation command set and the private file generation command configuration. The output module command set 711 can be used as input to the Python+HDL generator 713.
[0165] In this way, you only need to define the mixed Python and RUN code of the module once. In the future, you can obtain all the commands of all the design code files of the module by simply combining the module configuration generated by the Python+CFG generation method, without having to manually define hundreds, thousands or even tens of thousands of commands.
[0166] Step S703: Using the Python+HDL generator 713, based on the module configuration 76, the module command set 711, and the module Python and HDL mixed code 712, generate the module HDL code 714.
[0167] Here, module configuration 76 (corresponding to the module configuration information in the aforementioned embodiments), module command set 711, module Python and HDL mixed code 712 (corresponding to the preset module hardware code generation rules in the aforementioned embodiments), and module HDL code 714 (corresponding to all instantiated hardware codes in the aforementioned embodiments).
[0168] Among them, module configuration 76 is the module configuration information discussed in step S701 above;
[0169] The module command set 711 is the module command set discussed in step S702 above;
[0170] In module Python and HDL mixed code 712, HDL is the module hardware code.
[0171] In steps S701 to S703 above, the mixed Python and CFG code, the mixed Python and RUN code, the mixed Python and HDL code, and the module generation command are all one-time operations and generally do not change. Moreover, since mixed code is a universal rule, less code needs to be written, definition efficiency is high, and the generated code quality is higher than handwritten code. Subsequently, only a small number of module override configurations need to be defined, and a single command can obtain all the design code files that the module compiles, including module parameter definitions, module HDL code, and a list of module files. Therefore, this invention improves the efficiency of configuration file definition and achieves automatic generation of all compileable module files with a single command, improving the generation efficiency and ease of use of module design code. Steps S701 to S703 in the embodiments of this disclosure can be used individually or in any combination.
[0172] Based on the foregoing embodiments, this disclosure provides a code generation device for a hardware module. The device includes various units and modules included in each unit, which can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0173] Figure 8 This is a schematic diagram of the composition structure of a code generation device for a hardware module provided in an embodiment of this disclosure, such as... Figure 8 As shown, the hardware module code generation device 800 includes: a configuration generation module 810, a command generation module 820, and a code generation module 830, wherein:
[0174] The configuration generation module 810 is used to respond to the module instantiation generation command, and generate module configuration information for the module parameters corresponding to the code module to be generated by using the preset module configuration generation rules, so as to obtain the corresponding module configuration information.
[0175] The command generation module 820 is used to generate a set of module commands corresponding to the code module to be generated based on the module configuration information and using preset command generation rules.
[0176] The code generation module 830 is used to generate all instantiated hardware code corresponding to the code module to be generated, according to the module command set and module configuration information and the preset module hardware code generation rules.
[0177] In some embodiments, the preset module configuration generation rules include configuration code generation rules and configuration file generation rules; the configuration generation module 810 is further configured to generate corresponding parameter configuration information for any module parameter based on the corresponding configuration information using the configuration code generation rules; and to generate corresponding module configuration information conforming to the configuration file syntax in a loop for each parameter configuration information using the configuration file generation rules.
[0178] In some embodiments, the preset module configuration generation rules include general module configuration generation rules, private module configuration generation rules, and module dependency configuration generation rules; module parameters include public module parameters, private module parameters, and dependent module parameters that the code module to be generated needs to depend on; the configuration generation module 810 is further configured to, for each instantiation generation command in the module instantiation generation commands, generate corresponding general instantiation configuration information based on the public module parameters using the general module configuration generation rules; generate corresponding private instantiation configuration information based on the private module parameters using the private module configuration generation rules; and generate corresponding dependency instantiation configuration information based on the dependent module parameters using the module dependency configuration generation rules; and determine the general instantiation configuration information, private instantiation configuration information, and dependency instantiation configuration information corresponding to different instantiation generation commands in the module instantiation generation commands as module configuration information.
[0179] In some embodiments, the configuration generation module 810 is further configured to convert module configuration information into module parameter definitions that conform to a preset syntax.
[0180] In some embodiments, the preset command generation rules also include the code file compilation order; the command generation module 820 is further configured to generate a corresponding module file list for each command's hardware language file included in the module command set, according to the code file compilation order.
[0181] In some embodiments, the command generation module 820 is further configured to identify the absolute path of each command included in the module command set from the module configuration information; construct the corresponding file directory based on the absolute path of each command, and obtain the file name of each command based on the module configuration information; for each command, construct the corresponding absolute path of the hardware language file based on the corresponding file directory and file name; and generate a corresponding module file list by taking the hardware language files of each command included in the module command set in the form of absolute file paths and following the compilation order of the code files.
[0182] In some embodiments, the code generation module 830 is further configured to: determine the mixed language code corresponding to the code module to be generated based on the module configuration information; for each command included in the module command set, convert the initial language code included in the mixed language code into language code, and determine the language code and the initial language code included in the language code as the corresponding intermediate language code; for each command, execute the corresponding intermediate language code to determine the corresponding target language code, and generate all corresponding hardware codes based on the corresponding target language code; and determine all hardware codes corresponding to different commands in the module command set as all instantiated hardware codes.
[0183] The descriptions of the apparatus embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. In some embodiments, the functions or modules included in the apparatus provided in this disclosure can be used to perform the methods described in the method embodiments above. For technical details not disclosed in the apparatus embodiments of this disclosure, please refer to the descriptions of the method embodiments of this disclosure for understanding.
[0184] Based on the foregoing embodiments, such as Figure 9 As shown, this disclosure provides an exemplary computer system 900, which includes a server 910 containing an input / output unit 920, a memory 930, and a processor 940. The server 910 is capable of executing one or more units. In this invention, the term "computer-readable medium" refers to any medium involved in providing instructions to the processor 940, such as, but not limited to, optical discs, magnetic disks, read-only memory, random access memory, solid-state devices and drives, or any other tangible medium suitable for storing electrical signals, or computer-readable signal media, which may include transient media such as carrier waves. The input / output unit 920 processes input from a user interface interface 950 and an operation interface interface 960, which may utilize input devices such as, but not limited to, a keyboard, mouse, touch device, or voice commands.
[0185] Server 910 may connect to an external storage device, which may contain removable memory, such as, but not limited to, a portable hard drive, optical media (CD or DVD), disk media, or any other medium from which a computer can read executable instructions. Server 910 may connect to an output device 980, such as a display that outputs data and other information to a user, and requests additional information from the user. Connections between server 910 and user interface 950, user interface 960, external storage 970, and output device 980 may be via wireless protocols, such as, but not limited to, the 802.11 standard, Bluetooth, or mobile phone protocols, or via physical transmission protocols, such as cables or fiber optics. Output device 980 may also further serve as an input device for user interaction.
[0186] Processor 940 may execute one or more modules. Python+CFG generation module 951 (corresponding to the configuration generation module in the aforementioned embodiments) is used to generate module configuration and module parameter definition files. The entire process is based on mixed Python and CFG code, module override configuration, other module configurations, and module generation commands. Python+RUN generation module 952 (corresponding to the command generation module in the aforementioned embodiments) receives the module configuration generated by Python+CFG generation module 951 and, based on the mixed Python and RUN code, generates a set of module commands and a list of module files. Python+HDL generation module 953 (corresponding to the command generation module in the aforementioned embodiments) receives the module configuration generated by Python+CFG generation module 951 and the set of module commands generated by Python+RUN generation module 952, and, based on the mixed Python and HDL code, generates module HDL code. Through coordinated control of the entire process, the efficiency of configuration file definition is improved, and a single command automatically generates all instantiated design code files for a compileable module, improving the generation efficiency and usability of module design code.
[0187] It should be noted that, in the embodiments of this disclosure, if the code generation method of the aforementioned hardware module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this disclosure, or the part that contributes to the related technology, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods of the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this disclosure are not limited to any specific hardware, software, or firmware, or any combination of hardware, software, and firmware.
[0188] This disclosure provides a computer device including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the above-described method.
[0189] This disclosure provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements some or all of the steps in the above-described method. The computer-readable storage medium may be transient or non-transient.
[0190] This disclosure provides a computer program including computer-readable code, wherein when the computer-readable code is executed in a computer device, a processor in the computer device performs some or all of the steps in the above-described method.
[0191] This disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method. This computer program product can be implemented specifically through hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium; in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0192] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between them, while their similarities or commonalities can be referenced interchangeably. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product of this disclosure, please refer to the descriptions of the method embodiments of this disclosure for understanding.
[0193] It should be understood that the phrase "an embodiment" or "one embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this disclosure. Therefore, "in one embodiment" or "one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this disclosure, the sequence numbers of the above steps / processes do not imply a sequential order of execution; the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure. The sequence numbers of the above embodiments of this disclosure are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0194] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0195] In the several embodiments provided in this disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0196] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0197] In addition, each functional unit in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0198] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0199] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, magnetic disks, or optical disks.
[0200] The above description is merely an embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for generating code for a hardware module, characterized in that, The code generation method for the hardware module includes: In response to the module instantiation generation command, the module configuration information is generated by using the preset module configuration generation rules to generate the module parameters corresponding to the code module to be generated, and the corresponding module configuration information is obtained. Based on the module configuration information, a set of module commands corresponding to the code module to be generated is generated using preset command generation rules; Based on the module command set and the module configuration information, and in accordance with the preset module hardware code generation rules, all instantiated hardware code corresponding to the module to be generated is generated.
2. The code generation method for a hardware module according to claim 1, characterized in that, The preset module configuration generation rules include configuration code generation rules and configuration file generation rules; The method utilizes preset module configuration generation rules to generate module configuration information for the module parameters corresponding to the code module to be generated, obtaining the corresponding module configuration information, including: For any module parameter, based on the corresponding configuration information, the configuration code generation rules are used to generate the corresponding parameter configuration information; For each parameter configuration information, the corresponding module configuration information conforming to the configuration file syntax is generated in a loop using the configuration file generation rules.
3. The code generation method for a hardware module according to claim 1, characterized in that, The preset module configuration generation rules include general module configuration generation rules, private module configuration generation rules, and module dependency configuration generation rules; the module parameters include public module parameters, private module parameters, and dependent module parameters that the code module to be generated needs to depend on; in response to the module instantiation generation command, the preset module configuration generation rules are used to generate module configuration information for the module parameters corresponding to the code module to be generated, resulting in the corresponding module configuration information, including: For each instantiation generation command in the module instantiation generation command, the corresponding instantiation general configuration information is generated based on the common module parameters using the module general configuration generation rules. For each instantiation generation command, the corresponding instantiation private configuration information is generated based on the private module parameters using the module's private configuration generation rules. For each instantiation generation command, the corresponding instantiation dependency configuration information is generated based on the dependent module parameters using the module dependency configuration generation rules. The instantiation general configuration information, the instantiation private configuration information, and the instantiation dependency configuration information corresponding to different instantiation generation commands in the module instantiation generation command are determined as the module configuration information.
4. The code generation method for a hardware module according to claim 1, characterized in that, The code generation method for the hardware module also includes: The module configuration information is converted into module parameter definitions that conform to a preset syntax.
5. The code generation method for a hardware module according to claim 1, characterized in that, The preset command generation rules also include the code file compilation order; The code generation method for the hardware module also includes: The hardware language files for each command included in the module command set are used to generate a corresponding list of module files according to the compilation order of the code files.
6. The code generation method for a hardware module according to claim 5, characterized in that, The step of generating a corresponding module file list by taking the hardware language file of each command included in the module command set according to the compilation order of the code files includes: Identify the absolute path of each command included in the module command set from the module configuration information; The directory containing the corresponding file is constructed by concatenating the absolute path of each command, and the file name of each command is obtained based on the module configuration information; For each command, the absolute path of the corresponding hardware language file is concatenated based on the directory where the corresponding file is located and the file name; The hardware language files for each command included in the module command set are used to generate a corresponding module file list in the form of absolute file paths, according to the compilation order of the code files.
7. The code generation method for a hardware module according to any one of claims 1 to 6, characterized in that, The step of generating all instantiated hardware code corresponding to the module to be generated, according to the module command set and the module configuration information and in accordance with preset module hardware code generation rules, includes: Based on the module configuration information, determine the mixed language code corresponding to the code module to be generated; For each command included in the module command set, the initial language code included in the mixed language code is converted into a language code, and the language code and the initial language code included in the language code are determined as the corresponding intermediate language code; For each command, the corresponding intermediate language code is executed to determine the corresponding target language code, and based on the corresponding target language code, all corresponding hardware codes are generated. The hardware code corresponding to different commands in the module command set is determined as all instantiated hardware code.
8. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the code generation method of the hardware module according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps in the code generation method for the hardware module of any one of claims 1 to 7.
10. A computer program product, characterized in that, The computer program product includes a non-transitory computer-readable storage medium storing a computer program, which, when read and executed by a computer, implements the steps in the code generation method of the hardware module according to any one of claims 1 to 7.