Register code automatic generation method and device, equipment and medium
By dividing register functions in chip design and building sub-templates and configuration files, the automatic generation of ASIC register code is achieved, solving the problem of code generation of multiple register types, and improving the universality and maintainability of the script.
Patent Information
- Application Number
- CN202411300446.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-12-06
AI Technical Summary
In chip design, ASIC has many types of registers and large functions, which leads to frequent modification of existing scripts, reducing maintainability.
By obtaining the functions of the register, dividing out the set of sub-functions, and building corresponding sub-templates and template configuration files, generating register templates using preset scripts, and automatically generating register codes according to the register type, supporting new types to achieve automation by updating the template configuration files. generate.
It lowers the threshold for script usage, improves the universality of automatically generated scripts by registers, adds supported template types and register types, and reduces script modification requirements.
Smart Images

Figure CN119088399A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of chip design technology, and in particular to a method, device, equipment and medium for automatically generating register codes. Background Art
[0002] In chip design, the formats of register codes of different types are relatively uniform. Generally speaking, a script is designed to automatically generate register codes, such as Figure 1 , Figure 2 The figure shows the process of generating code from an existing script. The basic information of the register is obtained by reading the configuration file, and then the fixed template inside the script is applied to generate the register code according to the register type. However, for ASIC (Application-Specific Integrated Circuit), there are many types of registers and the functional differences are large, so there may be dozens or even hundreds of registers with different functions. In this case, the script may need to be modified hundreds of times, which greatly reduces the maintainability of the script. Therefore, how to provide a solution to the above technical problems is a problem that technicians in this field currently need to solve. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for automatically generating register codes, which can realize automatic code generation for different types of registers. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses a method for automatically generating register codes, comprising:
[0005] Acquire different register functions of different registers, and divide the register functions based on a preset division rule to obtain a register sub-function set;
[0006] Constructing a corresponding sub-template for each register sub-function in the register sub-function set, and constructing a template configuration file for configuring the register sub-function based on the sub-template;
[0007] The template configuration file is read using a preset register code generation script, and a corresponding register template is generated according to the sub-template in the template configuration file, and then the register template is applied according to the register type of the register to generate a register code.
[0008] Optionally, the acquiring different register functions of different registers and dividing the register functions based on a preset division rule to obtain a register sub-function set includes:
[0009] Obtain different register functions of different registers to obtain a register set;
[0010] The element functions in the register set are sequentially split, integrated and deduplicated to obtain a register sub-function set including a plurality of register sub-functions.
[0011] Optionally, the constructing a template configuration file for configuring the register sub-function based on the sub-template includes:
[0012] Obtain different register types corresponding to different registers;
[0013] According to the correspondence between the register function included in the register type and the register sub-function, the sub-template is switch-configured so as to construct a template configuration file for configuring the register sub-function based on the sub-template.
[0014] Optionally, after applying the register template according to the register type of the register to generate the register code, the method further includes:
[0015] If there is a newly added register type currently, determining a corresponding newly added register function according to the newly added register type;
[0016] A target register sub-function is determined based on the newly added register function, and the template configuration file is updated using a target sub-template corresponding to the target register sub-function.
[0017] Optionally, the using a preset register code generation script to read the template configuration file, and generating a corresponding register template according to the sub-template in the template configuration file, includes:
[0018] The preset register code generation script is used to read the parameter options and the corresponding configuration options in the template configuration file, and the corresponding register template is generated for the parameter options and the configuration options through the preset template control logic in the preset register code generation script.
[0019] Optionally, the method for automatically generating register codes further includes:
[0020] Determine the fields to be configured; the fields to be configured include type configuration fields and function configuration fields;
[0021] Determine different variable types, and write the variable types as values of the type configuration field into corresponding configuration information areas in the template configuration file to obtain the parameter options;
[0022] A type tag is set to characterize whether the variable type has the register sub-function, and the type tag is written into the corresponding configuration information area in the template configuration file as the value of the function configuration field to obtain the configuration option.
[0023] Optionally, the method for automatically generating register codes further includes:
[0024] When a template modification instruction is received, the template configuration file is modified according to the template modification instruction.
[0025] In a second aspect, the present application discloses a device for automatically generating register codes, comprising:
[0026] A function division module, used for obtaining different register functions of different registers, and dividing the register functions based on a preset division rule to obtain a register sub-function set;
[0027] a template construction module, used to construct a corresponding sub-template for each register sub-function in the register sub-function set, and to construct a template configuration file for configuring the register sub-function based on the sub-template;
[0028] The automatic code generation module is used to read the template configuration file using a preset register code generation script, generate a corresponding register template according to the sub-template in the template configuration file, and then apply the register template according to the register type of the register to generate a register code.
[0029] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the automatic register code generation method as described above.
[0030] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned method for automatically generating register codes.
[0031] The present application provides a method for automatically generating register codes, including: obtaining different register functions of different registers, and dividing the register functions based on preset division rules to obtain a set of register sub-functions; constructing a corresponding sub-template for each register sub-function in the set of register sub-functions, and constructing a template configuration file for configuring the register sub-function based on the sub-template; using a preset register code generation script to read the template configuration file, and generating a corresponding register template according to the sub-template in the template configuration file, and then applying the register template according to the register type of the register to generate a register code.
[0032] Beneficial technical effects of the present application: Since different types of registers differ greatly in function, different register functions correspond to different register types. The present invention subdivides the register function into multiple register sub-functions, constructs corresponding sub-templates for the register sub-functions, and then uses the sub-templates to generate template configuration files that can be configured. In this way, when generating register code, it is only necessary to use the preset register code generation script to read the template configuration file to automatically generate the corresponding register template, and then apply the template according to the register type to automatically generate the register code. For scenarios where new register types can be obtained by combining elements in the sub-function set, users can achieve automatic code generation for registers of this type by simply adding the template configuration file without modifying the script. The threshold for script use is lowered, and the versatility of the register automatic generation script is improved. In addition, the original fixed template is changed to a template that can be automatically generated, and the types of templates and registers supported are greatly increased.
[0033] In addition, the present application provides a register code automatic generation device, equipment and medium, which correspond to the above-mentioned register code automatic generation method and have the same effect as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0035] Figure 1 Schematic diagram of the process of generating code for an existing script;
[0036] Figure 2 A schematic diagram of the process of generating code for a specific existing script;
[0037] Figure 3A flow chart of a method for automatically generating register codes disclosed in this application;
[0038] Figure 4 A schematic diagram of a process of generating code from a script disclosed in this application;
[0039] Figure 5 A schematic diagram of a specific script code generation process disclosed in this application;
[0040] Figure 6 This is a schematic diagram of the structure of a register code automatic generation device disclosed in this application;
[0041] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] In chip design, the formats of register codes of different types are relatively unified. Generally speaking, a script is designed to automatically generate register codes. The basic information of the register is obtained by reading the configuration file, and then the register code is generated by applying the fixed template inside the script according to the register type.
[0044] However, for ASIC, there are many types of registers with large functional differences, so there may be dozens or even hundreds of registers with different functions. In this case, the script may need to be modified hundreds of times, which greatly reduces the maintainability of the script.
[0045] To this end, the present application provides a register code automatic generation solution, and the user can realize the automatic generation of codes for different types of registers without modifying the script.
[0046] The embodiment of the present invention discloses a method for automatically generating register codes, see Figure 3 As shown, the method includes:
[0047] Step S11: different register functions of different registers are obtained, and the register functions are divided based on a preset division rule to obtain a register sub-function set.
[0048] In the embodiment of the present application, a template configuration system is designed to subdivide the different register functions of different registers, and divide the register functions into multiple sub-functions based on preset division rules. By sorting out the existing registers in use, a set of register types that need to support automatic generation of register codes is tried.
[0049] Specifically, different register functions of different registers are obtained to obtain a register set; the element functions in the register set are sequentially split, integrated and deduplicated to obtain a register sub-function set including a plurality of register sub-functions.
[0050] It is understandable that different types of registers have different register functions, and different register functions have different register sub-functions. After sequentially splitting, integrating, and deduplicating the element functions included in the register set, a register sub-function set including multiple register sub-functions can be obtained.
[0051] Step S12: constructing a corresponding sub-template for each register sub-function in the register sub-function set, and constructing a template configuration file for configuring the register sub-function based on the sub-template.
[0052] It is understandable that, since different register types have large functional differences, different register functions correspond to different register types. In the embodiment of the present application, after obtaining the register sub-function set, a corresponding sub-template is constructed for each register sub-function divided in the set. Each register type can be configured with switches according to the sub-functions actually required to obtain a configuration file for the register to be generated. That is, different register types can be determined by combining different register sub-functions.
[0053] Specifically, different register types corresponding to different registers are obtained; according to the correspondence between the register function contained in the register type and the register sub-function, the sub-template is switched and configured so as to construct a template configuration file for configuring the register sub-function based on the sub-template.
[0054] In a specific implementation, a template configuration file is generated for the divided register sub-functions. The template configuration file includes parameter options and configuration options. The parameter options correspond to the different variable types that are divided, such as ro (Read-Only), rw (Read / Write), const (constant data), count (count), etc.; the configuration options correspond to whether a certain register sub-function is reflected for the current variable type. In this way, when the script reads the template configuration file, it can generate the corresponding template according to the parameter options and configuration options, changing the original fixed template to a template that can be automatically generated, which greatly increases the types of supported templates.
[0055] Step S13: using a preset register code generation script to read the template configuration file to generate a corresponding template, and then applying the template according to the register type of the register to generate a register code.
[0056] like Figure 4 The figure shows a schematic diagram of the process of automatic register code generation in the present invention. The preset register code generation script is used to read the template configuration file, generate the corresponding template, and then the generated template is applied to generate the register code by the register type, thereby improving the versatility of the automatic register generation script. It should be pointed out that when a new type of register support needs to be added, only the template configuration file needs to be modified, without modifying the script, thereby lowering the threshold for script use.
[0057] Specifically, when a new register type is added, the specific process of updating the template configuration file includes: if a new register type currently exists, determining the corresponding new register function according to the new register type; determining the target register sub-function based on the new register function, and updating the template configuration file using the target sub-template corresponding to the target register sub-function.
[0058] In a specific implementation, the newly added register function is a new register function that can be determined by combining the register sub-functions in the register sub-function set. For example, there is a combination of register functions AB and AC, and sub-functions A, B, and C are obtained when the functions are split; at this time, if the newly added register function is BC, then B and C are the determined target register sub-functions, and at this time, there is no need to modify the script, and only the template configuration file needs to be modified to update the template configuration file.
[0059] In another specific implementation, if the newly added register function cannot be determined by combining the register sub-functions in the register sub-function set, for example, the function of the newly added register is AD. Since there is no D in the register sub-function set, it is necessary to modify the script accordingly to add D. After the script is modified, the register sub-function D is added to the register sub-function set, and register types with different register sub-functions such as BD, CD, or even ABCD can also be automatically generated.
[0060] It can be seen that if a new type of register cannot be obtained by combining elements in the sub-function set, then the register of this type can be split, the sub-function set can be supplemented and the corresponding sub-template can be added. In the future, the template configuration file can also be used to support the automatic generation of more types of register codes.
[0061] In addition, if there is a need to modify the current type of register, similarly, only the register template configuration file needs to be modified without modifying the script. Specifically, when a template modification instruction is received, the template configuration file is modified according to the template modification instruction.
[0062] like Figure 5 The figure shows a process of automatically generating code according to a template configuration file provided by this embodiment. The template configuration file includes parameter options and corresponding configuration options, such as rw corresponding to parameter options, and yes / no configured under different sub-functions later corresponding to configuration options. The preset register code generation script is used to read the parameter options and corresponding configuration options in the template configuration file, and the preset template control logic in the preset register code generation script is used to generate a corresponding register template for the parameter options and the configuration options.
[0063] Specifically, the specific process of determining parameter options and configuration options includes the following steps:
[0064] Determine the fields to be configured; the fields to be configured include type configuration fields and function configuration fields;
[0065] Determine different variable types, and write the variable types as values of the type configuration field into corresponding configuration information areas in the template configuration file to obtain the parameter options;
[0066] A type tag is set to characterize whether the variable type has the register sub-function, and the type tag is written into the corresponding configuration information area in the template configuration file as the value of the function configuration field to obtain the configuration option.
[0067] It should be noted that the type label used to characterize whether the variable type has the register sub-function can be yes / no, or can be set to other type symbols, such as 1 / 0, etc., which are not specifically limited here. When there is a need to operate the template configuration file, only yes or no needs to be configured.
[0068] Finally, the template is applied according to the register type of the register, and the RTL register code is generated through the original register code generation logic.
[0069] The present application provides a method for automatically generating register codes, including: obtaining different register functions of different registers, and dividing the register functions based on preset division rules to obtain a set of register sub-functions; constructing a corresponding sub-template for each register sub-function in the set of register sub-functions, and constructing a template configuration file for configuring the register sub-function based on the sub-template; using a preset register code generation script to read the template configuration file, and generating a corresponding register template according to the sub-template in the template configuration file, and then applying the register template according to the register type of the register to generate a register code.
[0070] Beneficial technical effects of the present application: Since different types of registers differ greatly in function, different register functions correspond to different register types. The present invention subdivides the register function into multiple register sub-functions, constructs corresponding sub-templates for the register sub-functions, and then uses the sub-templates to generate template configuration files that can be configured. In this way, when generating register code, it is only necessary to use the preset register code generation script to read the template configuration file to automatically generate the corresponding register template, and then apply the template according to the register type to automatically generate the register code. For scenarios where new register types can be obtained by combining elements in the sub-function set, users can achieve automatic code generation for registers of this type by simply adding the template configuration file without modifying the script. The threshold for script use is lowered, and the versatility of the register automatic generation script is improved. In addition, the original fixed template is changed to a template that can be automatically generated, and the types of templates and registers supported are greatly increased.
[0071] Correspondingly, the present application embodiment also discloses a device for automatically generating register codes, see Figure 6 As shown, the device comprises:
[0072] A function division module 11 is used to obtain different register functions of different registers, and divide the register functions based on a preset division rule to obtain a register sub-function set;
[0073] A template construction module 12, configured to construct a corresponding sub-template for each register sub-function in the register sub-function set, and to construct a template configuration file for configuring the register sub-function based on the sub-template;
[0074] The automatic code generation module 13 is used to read the template configuration file using a preset register code generation script, generate a corresponding register template according to the sub-template in the template configuration file, and then apply the register template according to the register type of the register to generate a register code.
[0075] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0076] It can be seen that the above scheme of this embodiment includes: obtaining different register functions of different registers, and dividing the register functions based on preset division rules to obtain a register sub-function set; constructing a corresponding sub-template for each register sub-function in the register sub-function set, and constructing a template configuration file for configuring the register sub-function based on the sub-template; using a preset register code generation script to read the template configuration file, and generating a corresponding register template according to the sub-template in the template configuration file, and then applying the register template according to the register type of the register to generate a register code.
[0077] Beneficial technical effects of the present application: Since different types of registers differ greatly in function, different register functions correspond to different register types. The present invention subdivides the register function into multiple register sub-functions, constructs corresponding sub-templates for the register sub-functions, and then uses the sub-templates to generate template configuration files that can be configured. In this way, when generating register code, it is only necessary to use the preset register code generation script to read the template configuration file to automatically generate the corresponding register template, and then apply the template according to the register type to automatically generate the register code. For scenarios where new register types can be obtained by combining elements in the sub-function set, users can achieve automatic code generation for registers of this type by simply adding the template configuration file without modifying the script. The threshold for script use is lowered, and the versatility of the register automatic generation script is improved. In addition, the original fixed template is changed to a template that can be automatically generated, and the types of templates and registers supported are greatly increased.
[0078] Furthermore, the present application also discloses an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the diagram cannot be considered as any limitation on the scope of use of the present application.
[0079] Figure 7 The present invention is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the register code automatic generation method disclosed in any of the aforementioned embodiments.
[0080] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0081] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The data 223 may include various data. The storage method may be temporary storage or permanent storage.
[0082] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the register code automatic generation method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0083] Furthermore, the embodiment of the present application also discloses a computer-readable storage medium, wherein the computer-readable storage medium mentioned here includes a random access memory (Random Access Memory, RAM), a memory, a read-only memory (Read-Only Memory, ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk or an optical disk, or any other form of storage medium known in the technical field. Wherein, when the computer program is executed by the processor, the aforementioned register code automatic generation method is implemented. For the specific steps of the method, reference can be made to the corresponding contents disclosed in the aforementioned embodiment, and no further description will be given here.
[0084] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0085] The steps of the register code automatic generation method or algorithm described in conjunction with the embodiments disclosed herein can be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0086] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0087] The above is a detailed introduction to a register code automatic generation method, device, equipment and medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for automatically generating register codes, characterized in that: include: Acquire different register functions of different registers, and divide the register functions based on a preset division rule to obtain a register sub-function set; Constructing a corresponding sub-template for each register sub-function in the register sub-function set, and constructing a template configuration file for configuring the register sub-function based on the sub-template; The template configuration file is read using a preset register code generation script, and a corresponding register template is generated according to the sub-template in the template configuration file, and then the register template is applied according to the register type of the register to generate a register code.
2. The method for automatically generating register codes according to claim 1, characterized in that: The acquiring different register functions of different registers and dividing the register functions based on a preset division rule to obtain a register sub-function set includes: Obtain different register functions of different registers to obtain a register set; The element functions in the register set are sequentially split, integrated and deduplicated to obtain a register sub-function set including a plurality of register sub-functions.
3. The method for automatically generating register codes according to claim 1, characterized in that: The constructing a template configuration file for configuring the register sub-function based on the sub-template includes: Obtain different register types corresponding to different registers; According to the correspondence between the register function included in the register type and the register sub-function, the sub-template is switch-configured so as to construct a template configuration file for configuring the register sub-function based on the sub-template.
4. The method for automatically generating register codes according to claim 1, characterized in that: After applying the register template according to the register type of the register to generate the register code, the method further includes: If there is a newly added register type currently, determining a corresponding newly added register function according to the newly added register type; A target register sub-function is determined based on the newly added register function, and the template configuration file is updated using a target sub-template corresponding to the target register sub-function.
5. The method for automatically generating register codes according to claim 1, characterized in that: The using of the preset register code generation script to read the template configuration file and generating a corresponding register template according to the sub-template in the template configuration file includes: The preset register code generation script is used to read the parameter options and the corresponding configuration options in the template configuration file, and the corresponding register template is generated for the parameter options and the configuration options through the preset template control logic in the preset register code generation script.
6. The method for automatically generating register codes according to claim 5, characterized in that: Also includes: Determine the fields to be configured; the fields to be configured include type configuration fields and function configuration fields; Determine different variable types, and write the variable types as values of the type configuration field into corresponding configuration information areas in the template configuration file to obtain the parameter options; A type tag is set to characterize whether the variable type has the register sub-function, and the type tag is written into the corresponding configuration information area in the template configuration file as the value of the function configuration field to obtain the configuration option.
7. The method for automatically generating register codes according to any one of claims 1 to 6, characterized in that: Also includes: When a template modification instruction is received, the template configuration file is modified according to the template modification instruction.
8. A device for automatically generating register codes, characterized in that: include: A function division module, used for obtaining different register functions of different registers, and dividing the register functions based on a preset division rule to obtain a register sub-function set; a template construction module, used to construct a corresponding sub-template for each register sub-function in the register sub-function set, and to construct a template configuration file for configuring the register sub-function based on the sub-template; The automatic code generation module is used to read the template configuration file using a preset register code generation script, generate a corresponding register template according to the sub-template in the template configuration file, and then apply the register template according to the register type of the register to generate a register code.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the method for automatically generating register codes according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein when the computer program is executed by a processor, the method for automatically generating register codes according to any one of claims 1 to 7 is implemented.
