Code generation method and device, computer device, storage medium and product
By constructing functions and parameters that match database filtering and development requirements, skill code that meets actual needs is generated, solving the problem of insufficient quality in skill code generation from general large models and achieving efficient and accurate code generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-31
AI Technical Summary
Existing general-purpose models lack a deep understanding of the characteristics of the Skill language when generating Skill code, resulting in code quality that fails to meet the preset application standards and cannot satisfy the high-quality code requirements in real-world applications.
By constructing a function database, an information database, and a parameter database, an initial set of functions matching the development requirements is selected, a set of target functions whose calling logic meets the development requirements is selected, and the target parameter set is extracted, ultimately generating code that meets the development requirements.
It significantly shortens the development cycle, improves code quality and reliability, and ensures that the generated code is logically rigorous, functionally complete, and meets actual needs.
Smart Images

Figure CN121209887B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software development technology, and in particular to a code generation method, apparatus, computer equipment, storage medium, and product. Background Technology
[0002] In the field of integrated circuit design, Skill code, as a programming language closely integrated with EDA (Electronic Design Automation) tools such as Cadence, plays a crucial role in key stages such as chip design, placement, and routing. With the increasing complexity of chip designs, the demand for Skill code is also growing. Efficiently and accurately generating Skill code has become a key factor in improving chip design efficiency and quality.
[0003] In related technologies, general large-scale models are the primary technique in other code generation fields, such as Python, Java, and C++ code. These models attempt to automatically generate code by learning from large amounts of code data using deep learning algorithms. However, due to the unique characteristics of the Skill language, general large-scale models suffer from numerous problems in application. During the code generation process, the model's lack of a deep understanding of Skill language features leads to code quality failing to meet preset application standards. Therefore, improving the accuracy of code generation has become an urgent problem to be solved in this field. Summary of the Invention
[0004] Therefore, it is necessary to provide a code generation method, apparatus, computer equipment, storage medium, and product that can highly match the code with the user's actual needs, thereby improving the quality and reliability of the code, in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a code generation method, which includes:
[0006] Based on the development requirements of the code to be developed, an initial set of functions matching the development requirements is selected from the function database; the function database includes various correspondences between development requirements and functions;
[0007] Based on the information database, a set of target functions whose calling logic conforms to the development requirements is selected from the initial function set; the information database includes the correspondence between multiple functions and their calling logic.
[0008] Information about the parameters of the target function set is extracted from the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets.
[0009] Based on the set of target functions and the set of target parameters, generate the code to be developed.
[0010] Secondly, this application also provides a code generation apparatus, comprising:
[0011] The function filtering module is used to filter an initial set of functions from the function database that match the development requirements of the code to be developed. The function database includes various mapping relationships between development requirements and functions.
[0012] The function filtering module is also used to filter a set of target functions whose calling logic conforms to the development requirements from the initial function set based on the information database; the information database includes the correspondence between multiple functions and calling logic.
[0013] The parameter extraction module is used to extract information about the parameters of the target function set based on the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets.
[0014] The code generation module is used to generate code to be developed based on the target function set and the target parameter set.
[0015] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0016] Based on the development requirements of the code to be developed, an initial set of functions matching the development requirements is selected from the function database; the function database includes various correspondences between development requirements and functions;
[0017] Based on the information database, a set of target functions whose calling logic conforms to the development requirements is selected from the initial function set; the information database includes the correspondence between multiple functions and their calling logic.
[0018] Information about the parameters of the target function set is extracted from the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets.
[0019] Based on the set of target functions and the set of target parameters, generate the code to be developed.
[0020] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0021] Based on the development requirements of the code to be developed, an initial set of functions matching the development requirements is selected from the function database; the function database includes various correspondences between development requirements and functions;
[0022] Based on the information database, a set of target functions whose calling logic conforms to the development requirements is selected from the initial function set; the information database includes the correspondence between functions and calling logic;
[0023] Information about the parameters of the target function set is extracted from the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets.
[0024] Based on the set of target functions and the set of target parameters, generate the code to be developed.
[0025] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0026] Based on the development requirements of the code to be developed, an initial set of functions matching the development requirements is selected from the function database; the function database includes various correspondences between development requirements and functions;
[0027] Based on the information database, a set of target functions whose calling logic conforms to the development requirements is selected from the initial function set; the information database includes the correspondence between functions and calling logic;
[0028] Information about the parameters of the target function set is extracted from the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets.
[0029] Based on the set of target functions and the set of target parameters, generate the code to be developed.
[0030] The aforementioned code generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product select an initial set of functions from a function database that matches the development requirements. This allows for quick and accurate function selection from existing function resources, saving time. Next, based on an information database, a set of target functions whose calling logic meets the requirements is selected from the initial set, further pinpointing the necessary functions and reducing unnecessary trials and debugging. Then, based on a parameter database, the target parameter set corresponding to the parameters of the target function set is determined, avoiding searching through massive amounts of code resources and significantly shortening the development cycle. Finally, the target function set and target parameter set are integrated according to the development requirements to generate structured code that fits the development needs and application scenarios, thereby improving code quality and reliability. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1 This is a diagram illustrating the application environment of the code generation method in one embodiment;
[0033] Figure 2 This is a flowchart illustrating a code generation method in one embodiment;
[0034] Figure 3 This is a flowchart illustrating multi-model collaboration in one embodiment;
[0035] Figure 4 This is a flowchart illustrating the process of selecting an initial set of functions in one embodiment;
[0036] Figure 5 This is a flowchart illustrating the process of filtering the set of target functions in one embodiment;
[0037] Figure 6 This is a flowchart illustrating the process of constructing a parameter database in one embodiment;
[0038] Figure 7 This is a flowchart illustrating the process of obtaining a code solution in one embodiment;
[0039] Figure 8 This is a flowchart illustrating the process of obtaining a code solution in another embodiment;
[0040] Figure 9 This is a flowchart illustrating the process of generating code to be developed in one embodiment;
[0041] Figure 10 This is a flowchart illustrating the process of generating code to be developed in another embodiment;
[0042] Figure 11 This is a flowchart illustrating the process of evaluating code to be developed in one embodiment;
[0043] Figure 12 This is a flowchart illustrating the process of evaluating the code to be developed in another embodiment;
[0044] Figure 13 This is a structural block diagram of a code generation device in one embodiment;
[0045] Figure 14 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0047] 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 application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. In the description of embodiments of this application, technical terms such as "first," "second," etc., are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary or secondary relationship of the indicated technical features. In the description of embodiments of this application, "a plurality of" means two or more, unless otherwise explicitly defined.
[0048] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0049] In related technologies, applying general-purpose models to Skill code generation faces numerous challenges, making it difficult to generate high-quality code that matches real-world application scenarios. Because the Skill language is tightly integrated with EDA tools, general-purpose models lack a deep understanding of Skill language characteristics, making it difficult to accurately grasp specific requirements. This often results in generated code that doesn't meet actual needs, such as logical errors and missing functionality, failing to meet industrial-grade application standards. Furthermore, the high coupling between the Skill language and EDA tools leads to complex relationships and mutual exclusions within the function libraries and parameter systems of EDA tools. For example, the use of some functions depends on specific parameter combinations, and different parameters may also restrict each other. However, current technologies have not yet resolved these issues, further compromising the accuracy of code generation and failing to meet the demands for high-quality Skill code in practical applications.
[0050] Based on this, embodiments of this application provide a code generation method, apparatus, computer device, storage medium, and product, which can generate code that highly matches the user's actual needs, and makes the code logically rigorous and functionally complete.
[0051] The code generation method provided in this application can be executed by a single electronic device with computing power, or by a system composed of multiple electronic devices. For example, the code generation method provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located on a cloud or other network server. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, and tablets. Server 104 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services.
[0052] In one embodiment, such as Figure 2 As shown, a code generation method is provided, which includes the following steps:
[0053] Step 202: Based on the development requirements of the code to be developed, select an initial set of functions from the function database that match the development requirements; the function database includes various correspondences between development requirements and functions.
[0054] In such Figure 1 In the application environment shown, terminal 102 is equipped with EDA software tools, which can help engineers perform a series of complex tasks such as circuit design, simulation, and verification. However, in actual use of EDA software, there are often some specific development needs, such as automated placement and routing, circuit performance optimization, and checking whether specified patterns appear in the layout.
[0055] For example, a user inputs a requirement description in a terminal with EDA tools deployed, such as checking whether a specified graphic appears in the layout. By analyzing the requirement description, the development requirements of the code to be developed are determined. Then, the development requirements are used to search for functions in a pre-built function database to filter out functions that match the development requirements, thereby forming an initial set of functions.
[0056] In some embodiments, the pre-built function database is formed by constructing multiple functions. When building this function database, it is necessary to collect and organize functions related to EDA tools, such as the function APIs (Application Programming Interfaces) of the EDA software itself, to be used for calling the functions of the EDA software. Then, based on the applicable development requirements, the functions are analyzed, and corresponding identifiers or descriptions are added to each function. A correspondence between development requirements and function identifiers or descriptions is then established, and the functions and their correspondences are stored in the database to form the function database.
[0057] Therefore, when searching for a function in the function database, the development requirements corresponding to the requirement description are analyzed to obtain the identifier or description information of the required function. Then, the corresponding relationships in the function database are traversed to determine the function whose identifier or description information matches the development requirements, and all functions are organized to obtain the initial function set.
[0058] In other embodiments, the pre-built function database includes multiple sub-databases and a mapping between development requirements and these sub-databases. During construction, the collected functions are categorized according to the type of development requirement or function attribute to obtain multiple sub-databases. For example, circuit layout-related functions and schematic-related functions are stored in different databases. A mapping between the sub-databases and development requirements is also established. Then, for each sub-database, the functions are analyzed, and corresponding identifiers or descriptions are added to each function. A mapping between the identifiers or descriptions and the functions is then established, and the functions and their mappings are stored in the sub-database.
[0059] Therefore, when searching for functions in this function database, the development requirements corresponding to the requirement descriptions are analyzed to determine the type or attribute of the required function, as well as the identifier or description information of the required function. Sub-databases matching the type or attribute of the required function are determined through these correspondences. Then, the correspondence between the identifier or description information in these sub-databases and the functions is used to determine the required function, thus forming an initial function set.
[0060] Step 204: Based on the information database, select the target function set whose calling logic meets the development requirements from the initial function set; the information database includes the correspondence between multiple functions and calling logic.
[0061] The initial function set obtained through screening only reflects functions that match the development requirements. To ensure logical coherence in the code to be developed, it is necessary to analyze the call logic of the functions in the initial function set to select functions whose call logic conforms to the development requirements. Based on this, a pre-set information database is used to analyze the call logic of the functions in the initial function set to select functions whose logic meets the development requirements. In some embodiments, after collecting and organizing functions related to the EDA tool, each function is analyzed in detail, such as its call logic information, including usage instructions, parameter requirements, and parameter composition. Then, the call logic information is organized into function call logic, and a correspondence between the call logic and the functions is established.
[0062] For example, since the information database stores the correspondence between multiple functions and their calling logic, this correspondence can be used to clarify how each function is called or used in different scenarios. To improve the accuracy of subsequent code generation, it is necessary to further filter the functions in the initial function set. Specifically, based on the information database, each function in the initial function set is analyzed to determine whether the calling or usage method of each function matches the development requirements. Then, functions whose calling logic meets the requirements are selected to form the target function combination.
[0063] In some possible implementations, if the development requirement is clearly design rule checking, usage patterns such as "first extract layout data, then perform rule parsing and violation detection" can be determined from the information database. Then, relevant functions are selected from the initial function set to form the target function set. The selected relevant functions can be executed sequentially according to predetermined logic to complete the various tasks of design rule checking.
[0064] Step 206: Extract information from the parameters of the target function set based on the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets.
[0065] After filtering the target function set via the terminal, to ensure that the functions can be called successfully and executed correctly according to the expected development requirements, it is necessary to extract the parameters related to each function in the target function set from a pre-set parameter database. In some possible embodiments, when it is necessary to collect and organize functions related to EDA tools, the parameters in each function need to be organized to form a parameter set including but not limited to the data format of the parameter itself and a description of its correlation with other parameters, and to establish the correspondence between functions and parameter sets.
[0066] For example, a pre-built parameter database stores the correspondence between multiple functions and parameter sets. After obtaining the target function set, parameters are extracted from the parameter database based on the correspondence between multiple functions and parameter sets, thereby obtaining the parameter sets corresponding to each function in the target function set to form the target parameter set.
[0067] In some possible embodiments, after explicitly checking whether the development requirement for a specific graphic appears in the layout and filtering to obtain a set of target functions, the parameter set corresponding to each function in the target function set is extracted using a parameter database. For example, if the target function set includes an image search function, the parameters corresponding to the image search function, such as graphic feature parameters and layout coordinate range parameters, can be extracted from the parameter database.
[0068] In other possible embodiments, after clarifying the development requirements for design rule checks and selecting the target function set, the parameter set corresponding to each function in the target function set is extracted using a parameter database. For example, if the target function set includes rule parsing functions, the parameters corresponding to the rule parsing functions, such as rule file format parameters and layout data type parameters, can be extracted from the parameter database.
[0069] Step 208: Generate the code to be developed based on the target function set and the target parameter set.
[0070] For example, each parameter set in the target parameter set is provided to the corresponding function, ensuring that the parameter types, quantity, and value ranges match the function definition. Then, the functions in the target function set are analyzed to clarify their functionality, inputs, outputs, and possible calling relationships. Next, the functions are combined in a logical order, such as the calling order determined by development requirements, to form a complete code solution. During this combination process, data transfer between functions needs to be carefully managed to ensure accuracy and smoothness. Finally, the code solution is transformed into the code to be developed, corresponding to the development requirements.
[0071] In the code generation method described above, an initial set of functions matching the development requirements is selected from the function database, allowing for quick and accurate function selection from existing function resources, thus saving time. Next, a set of target functions whose calling logic meets the requirements is selected from the initial set based on the information database, further refining the location of the necessary functions and reducing unnecessary trials and debugging. Then, the target parameter set corresponding to the parameters of the target function set is determined based on the parameter database, avoiding searching through massive amounts of code resources and significantly shortening the development cycle. Finally, the target function set and target parameter set are integrated according to the development requirements to generate structured code that fits the development needs and application scenario, thereby improving code quality and reliability.
[0072] In one embodiment, in the above embodiments, steps 202 to 208 can be executed in a code generation model. For example, a code generation model is pre-built, the code requirement description input by the user is input into the code generation model, and steps 202 to 208 are executed in the code generation model to output the generated code.
[0073] In another embodiment, steps 202 to 208 above can be completed through the collaboration of multiple different models; for example, they can be completed through the collaboration of multiple different large models; or, for example, the process of determining the development requirements of the code to be developed is completed through a scenario matching model, the process of screening the initial function combination is completed through a preliminary screening model, the process of screening the target function set is completed through a post-screening model, the process of extracting the target parameter set is completed through a parameter selection model, and the process of generating the code to be developed is completed through a solution generation model and a code generation model.
[0074] The following examples illustrate in detail the process of generating code in the embodiments of this application through the collaboration of multiple different models.
[0075] In one embodiment, such as Figure 3 As shown, before step 202, which involves selecting an initial set of functions from the function database that match the development requirements of the code to be developed, the method further includes:
[0076] The scenario matching model is invoked; the scenario matching model is pre-configured with a scenario matching template library; the user's requirement description is input into the scenario matching model, and the scenario matching model performs intent recognition on the user's requirement description to obtain the development requirements.
[0077] Before the terminal performs the steps of "filtering and matching an initial set of functions from a function database, further determining the target function and parameter set, and finally integrating and generating code that fits the requirements" using multiple models, it needs to accurately obtain the development requirements of the code to be developed. A scenario matching model can be used to perform intent recognition on the input requirement description, thereby accurately obtaining the development requirements.
[0078] For example, after a user inputs a requirement description, a scenario matching model is invoked to extract key information from the requirement description to obtain a keyword set. Analysis of the keyword set determines the user's true intent, which is then transformed into development requirements. In some possible embodiments, when a user inputs a requirement description regarding EDA design, such as a requirement for automated chip placement and routing, the requirement description is input into the scenario matching model. The model utilizes a scenario matching template library to extract and analyze key information from the requirement description, identify the user's true intent, and transform that intent into development requirements.
[0079] In this embodiment, the scene matching model can quickly identify the intent of the user's requirement description, automatically output the development requirements, and provide a reference for intent identification by combining the scene matching template library, so that the development requirements are more in line with the user's actual needs.
[0080] In the process of generating code using multiple models on the terminal, in order to improve the generation efficiency, open source code or code from completed projects can be collected, and usable code writing templates can be obtained through analysis and organization. In addition, the correspondence between development requirements and template categories can be clarified during the analysis process.
[0081] In one embodiment, see Figure 3 Before invoking the scene matching model, the method also includes:
[0082] Obtain multiple code writing templates and their corresponding template categories; divide all code writing templates according to their categories to obtain multiple sets of writing templates; the scenario matching template library includes template filtering mapping relationships and multiple sets of writing templates, and the template filtering mapping relationships include the correspondence between development requirements and template categories.
[0083] For example, by organizing commonly used engineering requirements, code corresponding to these requirements is obtained. This code is then refined to create code writing templates for each requirement. These templates cover various application scenarios. Next, the template category for each template is defined. Template categories are based on factors such as code function, purpose, and application scenario, such as data query, file processing, and interface rendering. Then, all code writing templates are categorized according to their respective categories, grouping templates belonging to the same category into multiple template sets. Finally, a correspondence between development requirements and template categories is established, and this correspondence is integrated with the multiple template sets into a scenario matching template library. This scenario matching template library is then configured in the scenario matching model. In some possible embodiments, template categories can be divided according to different functions of EDA design, such as circuit simulation and layout / routing. In this case, the scenario matching template library includes multiple writing templates suitable for Skill code.
[0084] In this embodiment, by organizing the writing templates and classifying the template categories, a writing template set is formed to achieve orderly management of code templates and provide certain support for code development, so that the code can be reused, improve code quality and development standardization, and reduce development costs.
[0085] In one embodiment, step 202 above, combined with Figure 3 As shown, based on the development requirements of the code to be developed, an initial set of functions matching the development requirements is selected from the function database, including:
[0086] Invoke the pre-screening model; the pre-screening model is pre-configured with a function database; input the development requirements into the pre-screening model, and the pre-screening model will select an initial set of functions from the function database that match the development requirements.
[0087] For example, a pre-filtering model pre-configured with a function database is invoked, and the identified development requirements are input into the pre-filtering model. These identified development requirements include data such as application scenarios and functions. The pre-filtering model searches the function database according to preset search rules to filter out functions related to and matching the development requirements, thus forming an initial function set. In some possible embodiments, the user-input requirement description includes functions and application scenarios. In this case, after extracting and analyzing the key information in the requirement description to obtain the development requirements, the development requirements, functions, and application scenarios are all input into the pre-filtering model. The pre-filtering model then searches the function database according to preset search rules to filter out functions related to and matching the development requirements, thus forming an initial function set.
[0088] In this embodiment, relevant functions are quickly and accurately located from a large function database based on development requirements, which speeds up the development process and ensures the matching degree between functions and development requirements, helping to reduce errors and rework caused by improper function selection.
[0089] When the pre-screening model is actually invoked in the terminal to filter the initial set of functions, in order to further improve the accuracy of function filtering, it is necessary to expand the function filtering from different dimensions and integrate the functions filtered from each dimension with other dimensions to filter functions that meet all dimensions, thereby improving the accuracy of function filtering and improving code development efficiency.
[0090] In one embodiment, such as Figure 4 As shown in step 202 above, the function database includes a distribution database and a function database. The distribution database includes the correspondence between scenario types and functions, and the function database includes the correspondence between functions and features. An initial set of functions matching the development requirements is selected from the function database, including:
[0091] Step 402: Determine the target search identifier based on development requirements; the target search identifier includes the target scenario type and the target function.
[0092] For example, a traffic splitting database is a resource library that stores various function sets. Different function sets are suitable for different target scenarios. That is, the function sets in the traffic splitting database are classified and stored according to different dimensions such as function and application scenario.
[0093] By analyzing the target scene type, the scene characteristics corresponding to the target scene type are determined. Then, based on the scene characteristics, a search is performed in the traffic distribution database. This can be combined with filtering methods such as keyword matching and rule judgment to find the set of functions that best matches the target scene type, i.e., the first initial function set.
[0094] In some possible implementations, if the user's development requirement is to develop a Skill script to automatically connect the bus under limited conditions, the target scenario type and target function can be determined by analyzing the development requirements.
[0095] Step 404: Select the first set of initial functions from the splitting database according to the target scene type.
[0096] For example, a traffic splitting database is a resource library that stores various function sets. Different function sets are suitable for different target scenarios. That is, the function sets in the traffic splitting database are classified and stored according to different dimensions such as function and application scenario.
[0097] By analyzing the target scene type, the scene characteristics corresponding to the target scene type are determined. Then, based on the scene characteristics, a search is performed in the traffic distribution database. This can be combined with filtering methods such as keyword matching and rule judgment to find the set of functions that best matches the target scene type, i.e., the first initial function set.
[0098] In some possible embodiments, the mapping relationship between different scenarios and functions pre-stored in the traffic splitting database is used to query functions related to bus connections, such as routing topology analysis functions, routing rule checking functions, and routing path optimization functions. The queried functions are then selected to form a first initial function set.
[0099] In some other possible embodiments, step 406 involves selecting a second initial set of functions from the function database based on the target function.
[0100] For example, a function database is a repository that stores numerous functions, each corresponding to a specific function.
[0101] By analyzing the target function, the functional characteristics of the target function are determined. Then, based on the functional characteristics, the function database is searched, and the function is matched with the target function according to the functional description and other elements. Through precise comparison, those functions that can meet the target function are selected to form a second initial function set.
[0102] In some possible embodiments, the mapping relationships between different functions and their corresponding roles are pre-stored in the function database to find functions related to automatic routing optimization, such as the shortest route function. The found functions are then filtered to form a second initial function set.
[0103] Step 408: Construct an initial function set based on the first initial function set and the second initial function set.
[0104] For example, since a first initial function set and a second initial function set have already been selected from the traffic distribution database and the function database, respectively, the first initial function set is selected based on the target scenario type and fits the specific scenario requirements; the second initial function set is selected from the function database based on the target function and meets the function implementation requirements. Therefore, in order to find a function set that can both adapt to the target scenario and implement the target function, it is necessary to find the intersection of the first initial function set and the second initial function set, and use the functions in the intersection as the initial function set.
[0105] In some possible embodiments, filtering is performed from a distribution database based on the target function type to obtain a set of type functions in the distribution database whose function types match the target function type. Filtering is also performed from a function database based on the target function functionality to obtain a set of function functions whose functionality matches the target function functionality. Then, the type function set and the function function set are combined, and functions contained in both sets are used as the initial filtered functions, resulting in an initial function set containing all the initially filtered functions. In some embodiments, the filtering operation from the distribution database needs to be performed multiple times, and the filtering operation from the function database needs to be performed multiple times, as shown below:
[0106]
[0107] in, For the initial set of functions, Let Q be the filtering function, and let Q be the user requirement description. To split the database, For functional databases, The weights of the stream filtering function, Weights for the function filtering criteria. User requirements descriptions include, but are not limited to, specific development needs and user-specified scenarios.
[0108] In this embodiment, selecting a first initial set of functions from the traffic distribution database based on the target scenario type can determine the functions applicable to a specific scenario; while selecting a second initial set of functions from the function database according to the target function ensures that the functions have the ability to implement the specific function. Then, by comprehensively considering both the scenario and function dimensions, a set of functions that both conforms to the target scenario and satisfies the target function can be obtained, improving the accuracy of function selection and thus helping to improve development efficiency and code quality.
[0109] In one embodiment, step 204 above, combined with Figure 3 Based on the information database, a set of target functions whose calling logic meets the development requirements is selected from the initial function set, including:
[0110] The post-filtering model is invoked; the post-filtering model is pre-configured with an information database; the initial function set is input into the post-filtering model, and the post-filtering model filters out the target function set whose calling logic meets the development requirements from the initial function set.
[0111] For example, a post-filtering model with a pre-configured information database is invoked, and the initial function set is input into the post-filtering model. The information database contains information such as function call logic or usage methods. The post-filtering model analyzes each function in the initial function set to determine whether the function's call logic or usage method meets the current development requirements, such as whether the function's parameter passing method and execution order meet the requirements. Through analysis, functions whose call logic meets the development requirements are selected to form a target function set. In some possible embodiments, when the development requirement is to perform batch modifications to metal layers and active area layers within the layout, the post-filtering model filters out functions from the initial function set that can filter layers and modify layers according to specified requirements for use in Skill script development in the EDA field.
[0112] In this embodiment, the information database provides rich reference information for the post-screening model, enabling the model to deeply analyze the fit between function call logic and development requirements, accurately select the target function set, reduce code error rate, and improve system stability and reliability.
[0113] The initial set of functions selected meets the development requirements, but it's uncertain whether this set will be used correctly in actual use, or whether it matches the execution process of the development requirements. Therefore, further investigation is needed to determine if the use of functions aligns with the development requirements, thereby avoiding the use of mismatched functions in subsequent development, which could lead to development errors and wasted resources.
[0114] In one embodiment, such as Figure 5 As shown, a set of target functions whose calling logic meets the development requirements is selected from the initial function set, including:
[0115] Step 502: For each function in the initial function set, the post-filtering model extracts the corresponding calling logic from the information database.
[0116] For example, the information database contains various call logic information for each function, such as the function's input parameter requirements, output format, specific execution steps, and possible dependencies. The post-selection model traverses the initial function set, determining the call logic corresponding to each function in the initial function set through the correspondence between multiple functions and their call logic. For instance, for a function used for data processing, the model obtains information such as its input data format, processing algorithm, and output data structure.
[0117] In some possible embodiments, the information database stores the calling logic information of EDA domain skill functions, such as the input parameter types, output result formats, execution order, and conditions when the function is used for circuit simulation. The subsequent filtering model traverses the initial function set, determining the calling logic corresponding to each function in the initial function set through the correspondence between multiple functions and their calling logic. For example, for layout drawing functions, the model extracts the input requirements, including but not limited to layout information, and the specific flow of the drawing operation, that must be passed when calling the layout drawing function.
[0118] Step 504: Perform a matching analysis between the calling logic and the development requirements to obtain the matching analysis results.
[0119] For example, during matching analysis, it is necessary to examine the specific content of each sub-requirement of the development requirements and then compare the calling logic with the specific content of each sub-requirement one by one to analyze whether the calling logic can meet the requirements. For instance, if the requirement is to implement a user login function, the calling logic should include steps such as user input validation and database query.
[0120] In some possible implementations, development requirements may include specific goals such as circuit design, simulation, and layout drawing in EDA Skill script development. During matching analysis, development requirements are broken down into multiple sub-tasks, and the calling logic is compared with each sub-task one by one to analyze whether the calling logic can meet the requirements.
[0121] Step 506: If the matching analysis result shows that the calling logic meets the development requirements, the function is determined as the target function; wherein, the target function set includes multiple target functions whose calling logic meets the development requirements.
[0122] For example, after performing a matching analysis on the function call logic, if the result shows that the call logic matches the pre-defined development requirements, then this function can be identified as the target function. After completing the traversal analysis of each function in the initial function set, all target functions whose call logic matches the pre-defined development requirements constitute the target function set.
[0123] In some possible implementations, the correspondence between functions and their calling logic in the information database is used to determine the calling logic of each function in the initial function set. Then, the calling logic of each function is matched and analyzed with development requirements and application scenarios to determine the functions whose calling logic matches the development requirements and application scenarios, i.e., the target function set. The specific filtering is as follows:
[0124]
[0125] in, For the set of objective functions, For information database.
[0126] In this embodiment, extracting function call logic from an information database and matching the extracted logic with development requirements greatly improves the accuracy of function selection. Furthermore, by analyzing the call logic, functions that truly meet the requirements can be accurately identified, avoiding development errors and resource waste caused by using mismatched functions.
[0127] In one embodiment, step 206 above, combined with Figure 3 As shown, information is extracted from the parameters of the objective function set based on the parameter database to obtain the objective parameter set, including:
[0128] The parameter selection model is invoked; the parameter selection model is pre-configured with a parameter database; the target function set is input into the parameter selection model, and the parameter selection model extracts the parameter set corresponding to each function in the target function set from the parameter database; wherein, the target parameter set includes the parameter set corresponding to each function.
[0129] For example, a parameter selection model with a pre-configured parameter database is invoked, and the target function set is input into the parameter selection model. The parameter database includes parameter sets used to construct each function. The parameter selection model is then used to filter the parameters of each function in the target function set to obtain the parameter set corresponding to each function, thus forming a target parameter set that includes the parameter sets corresponding to each function. The specifics are as follows:
[0130]
[0131] in, For the target parameter set, For parameter database.
[0132] When faced with specific development requirements, it is unnecessary to extract all parameters from the parameter set corresponding to a function. Therefore, during the extraction process, the development requirements are analyzed to clarify the functions that need to be implemented, and then the parameters that can achieve the functions are selected from the parameter set corresponding to the function.
[0133] In some possible embodiments, after determining the set of target functions for generating EDA skill code, a parameter selection model is used to filter the parameters of each function in the target function set to obtain the parameter set corresponding to each function. For example, for a target function for circuit timing analysis, the model will extract relevant parameters such as clock cycle and delay time from a database.
[0134] In this embodiment, the parameter selection model can quickly and accurately find the matching parameter set from the parameter database based on the target function set. Furthermore, since the parameter database is pre-configured with parameter sets that highly match the functions, program failures caused by parameter errors can be reduced.
[0135] In real-world code execution environments, functions often have complex interrelationships. To ensure smoother function usage, it's necessary to analyze these relationships. By utilizing the parameters that constitute functions to uncover their potential connections, we can effectively schedule and optimize related functions during subsequent code generation, thereby improving overall code accuracy and reducing errors caused by improper function coordination.
[0136] In one embodiment, such as Figure 6 As shown, the method also includes the following before calling the parameter selection model:
[0137] Step 602: Obtain the parameter set corresponding to each function in the function database.
[0138] For example, by sorting out each function, the set of parameters used to constitute each function can be determined, that is, the set of parameters corresponding to each function.
[0139] Step 604: For each parameter set, perform a correlation analysis between the first parameter set and the second parameter set to obtain the correlation information of the first parameter set; the first parameter set is the parameter set corresponding to any function in the function database, and the second parameter set is any parameter set other than the first parameter set; wherein, the parameter database includes the parameter sets corresponding to each function in the function database and the correlation information corresponding to each parameter set.
[0140] For example, the function database contains multiple functions, each corresponding to a set of parameters. When we select the parameter set of one function as the first parameter set, and then randomly select one from the remaining parameter sets as the second parameter set, we perform correlation analysis. We then iterate through all the parameter sets in the remaining parameter sets, and use all the analyzed correlation information as part of the first parameter set. In some possible embodiments, for circuit design, resistance, voltage, and current parameters are related by Ohm's law. Through analysis, we can obtain correlation information between the first and second parameter sets, such as whether the parameters influence each other and how they influence each other.
[0141] In this embodiment, by performing correlation analysis on the parameter set and utilizing the analyzed correlation information, the coordination between related functions can be improved, thereby improving the accuracy of the code.
[0142] In one embodiment, step 208 above, combined with Figure 3 As shown, based on the set of objective functions and the set of objective parameters, the code to be developed is generated, including:
[0143] The solution generation model and code generation model are invoked; the target function set and target parameter set are input into the solution generation model, and the solution generation model integrates the target function set and target parameter set to generate a code solution; the code solution is input into the code generation model, and the code generation model transforms the code solution to obtain the code to be developed.
[0144] For example, the target function set and target parameter set are input into a pre-trained solution generation model. This model deeply integrates the functions in the target function set and the parameter set in the target parameter set according to conventional code logic and the calling logic of each function in the target function set. This includes analyzing the calling order of functions and parameter passing rules to obtain a code solution that meets development requirements. The code solution clearly defines how each function works together to achieve the expected functionality. Then, the generated code solution is input into a pre-trained code generation model. The code generation model, based on this code solution and following the syntax rules of the programming language, transforms the code solution into specific code to be developed.
[0145] In some possible embodiments, without using templates, a solution generation model and a code generation model are invoked. The target function set and target parameter set are input into the solution generation model, which then integrates these sets according to development requirements to generate a code solution. The code solution is then input into the code generation model, which transforms the solution into the code to be developed. The solution generation model analyzes development requirements such as business logic and performance requirements to obtain information such as function call relationships and parameter passing logic. Based on this information, it rationally integrates the target functions and parameters to construct a feasible code implementation scheme, i.e., a code solution.
[0146] In other possible embodiments, when using templates, a solution generation model and a code generation model are invoked. The template, a set of target functions, and a set of target parameters are input into the solution generation model. The solution generation model then fills the template with the set of target functions and the set of target parameters to obtain a code solution. The code solution is then input into the code generation model, which transforms the code solution to obtain the code to be developed. Alternatively, the template, the set of target functions, and the set of target parameters are all input into the solution generation model. Based on the structure and rules of the template, the solution generation model integrates each function in the set of target functions with its corresponding target parameters, and then fills them into the corresponding positions in the template. The template includes a code framework with a general structure.
[0147] In some other possible embodiments, the solution generation model analyzes the call order of functions and parameter passing rules based on EDA domain knowledge and Skill script rules to generate a code solution. This code solution is then input into the code generation model, which converts it into code to be developed according to Skill syntax.
[0148] In this embodiment, a solution generation model is used to integrate the set of objective functions and the set of objective parameters to generate a code solution, thereby shortening the development cycle. Furthermore, the code generation model transforms the code solution into code to be developed, improving the accuracy and standardization of the code.
[0149] To further improve the correctness of the logical interactions between functions described in the code solution, the data transmission and logical interactions between functions can be further analyzed to clarify the connections between functions, that is, to discover potential data flows and logical dependencies.
[0150] In one embodiment, such as Figure 7 As shown, the solution generation model populates the template with the set of objective functions and the set of objective parameters to obtain a code solution, including:
[0151] Step 702: For each first function, analyze the correlation between the parameter set corresponding to the first function and the second function to obtain the correlation analysis results; the first function is any function in the target function set, and the second function includes all functions in the target function set except the first function.
[0152] For example, for each first function, i.e., any function in the target function set, the correlation between the parameter set corresponding to the first function and the second function is analyzed. This involves determining whether the parameters of the first function participate in the structural composition of the second function. Here, the second function refers to any function in the target function set other than the first function. If there are first function parameters that do not participate in the structural composition of the second function, then the first function is an independent function. Therefore, the first and second functions cannot be generated together to avoid problems such as function confusion and parameter mismatch. In some possible embodiments, the correlation between the parameter set corresponding to the first function and the second function is analyzed. For example, in a circuit simulation script, the first function is used to set resistance parameters, and the second function is used to calculate current. The logical connection between the resistance parameters and the current calculation function is analyzed to clarify the dependencies between functions and parameter passing rules, thereby obtaining the correlation analysis results.
[0153] Step 704: If the correlation analysis result shows that the parameter set corresponding to the first function is correlated with the second function, analyze the template to obtain the template analysis result.
[0154] For example, if the structure consists of a first function parameter and a second function, the initial template needs to be analyzed, with a focus on the parts related to the first and second functions. It's necessary to check if the initial template contains logic for parameter association. If such logic exists, it's determined whether the initial template can correctly handle the current association; otherwise, adjustments to the initial template to accommodate the parameter association are needed. Furthermore, the order and method of function calls in the template must be checked to ensure they match the parameter association. A mismatch could lead to function call errors or abnormal data transfer. In some possible embodiments, in the Skill script template for circuit layout, the first function sets component positions, and the second function connects components. Therefore, the logic related to positions and connections in the template is analyzed to determine whether the template can be directly reused under the current association function and which parts need modification, thus obtaining the template analysis results.
[0155] Step 706: Based on the template analysis results and the set of target functions, populate the template to obtain a code solution.
[0156] For example, the template analysis results clarify the compatibility of function parameters in the initial template, facilitating adjustments and additions. Then, the functions implementing each function in the target function set are filled into the corresponding positions in the initial template according to the rules and logic determined by the template analysis results. Furthermore, for functions with parameter associations, the parameters are accurately filled in based on the association relationships. This process gradually improves the initially blank or partially missing initial template, ultimately forming the code to be developed.
[0157] In this embodiment, by performing correlation analysis on the parameter sets corresponding to each first function and the second function, the relationship between functions in the target function set is clarified. This helps developers to deeply understand the interaction between functions, discover potential data flow and logical dependencies, and improve the logic and stability of the code.
[0158] In one embodiment, such as Figure 8 As shown, the method also includes:
[0159] Step 802: If the correlation analysis result shows that the parameter set corresponding to the first function is not related to the second function, the template is processed according to the first function to obtain an intermediate template; the intermediate template includes a template that reserves specific information at the target location.
[0160] For example, when the correlation analysis results indicate that the parameter set corresponding to the first function is not related to the second function, meaning the parameter set of the first function does not participate in the structural composition of the second function, the initial template can be specifically processed based on the first function. Since the parameters of the first function are unrelated to the second function, the independence of the parameters endows the first function with relatively independent logic and structure. Specifically, the first function, when running and implementing its functions, is not affected by the parameters of the second function and has its own unique operating rules and methods. Therefore, the initial template can be operated on according to the relatively independent logic, structure, and requirements of the first function to obtain an intermediate template. This intermediate template reserves specific information at the target location, which can serve as an indication for subsequent operations.
[0161] Step 804: Analyze the initial template to obtain the template analysis results.
[0162] For example, when analyzing the initial template, it's crucial to focus on the related parts between functions other than the first function. It's necessary to check if the initial template contains logic for handling parameter associations. If such logic exists, determine if the initial template can correctly handle the current associations; otherwise, consider how to adjust the initial template to accommodate parameter associations. Furthermore, it's essential to check if the order and manner of function calls in the template match the parameter associations. A mismatch could lead to function call errors or abnormal data transfer.
[0163] Step 806: Based on the analysis results of the second function and the template, fill in the intermediate template to obtain the code solution.
[0164] For example, the template analysis results clarify the compatibility of function parameters in the initial template, facilitating adjustments and additions. Then, functions implementing various functionalities from the target function set (excluding the first function) are filled into the corresponding positions in the initial template according to the rules and logic determined by the template analysis results. Furthermore, for functions with parameter associations, the parameters are accurately filled in based on the association relationships. Finally, the first code is filled into the target positions in the intermediate template based on specific information, gradually improving the initially blank or partially missing template, thus forming a code solution.
[0165] In some possible embodiments, when the correlation analysis indicates that the parameter set corresponding to the first function is unrelated to the second function, the template is processed based on the first function, and specific information is reserved at the target position of the template during processing to obtain an intermediate template. This specific information refers to the location where the code generated by the second function will be filled. Then, the template is analyzed to examine its structure, logic, and adaptability to the EDA task, yielding template analysis results. Subsequently, combining the second function and the template analysis results, the relevant content of the second function is filled into the reserved position in the intermediate template to complete the code logic construction, thereby obtaining a complete code solution.
[0166] In this embodiment, when the correlation analysis shows that the parameter set corresponding to the first function is not related to the second function, an intermediate template with reserved specific information is obtained based on the initial template processed by the first function, and the first code is determined. This increases the flexibility and scalability of the code, facilitating subsequent adjustments based on different situations. Then, the functions implementing each function in the target function set are filled into the corresponding positions of the initial template according to the rules and logic determined by the template analysis results and the specific information. This fully considers the independence between functions and the coordination of the overall code, making the code solution more in line with actual needs, reducing redundant code, and improving development efficiency.
[0167] In one embodiment, such as Figure 9 As shown, before calling the solution to generate the model and code model, the method also includes:
[0168] Step 902: Perform correlation analysis on each function in the objective function set based on the objective parameter set to obtain the correlation analysis results.
[0169] For example, based on the target parameter set, each function in the target function set is analyzed to examine its dependency on the target parameters. If the output of a function is completely unaffected by certain target parameters, then the function is determined to be relatively independent of these parameters. Further analysis is performed to determine if there are parameter sharing or dependencies between the functions. If there are no parameter relationships between functions, then the functions are determined to be independent at the parameter level. Through analysis at multiple levels, correlation analysis results are obtained. In some possible embodiments, if a function's parameters have poor distinguishability or usage compared to other parameters, then that function can be determined to be an independent function compared to other functions.
[0170] Step 904: If the association analysis result shows that there is no independent function in the target function set, execute the call solution generation model and code model to obtain the code to be developed.
[0171] For example, if the correlation analysis results show that there are no independent functions in the target function set, it means that the functions in the target function set are related and interdependent, and the solution generation model and code generation model can be called to obtain the code to be developed.
[0172] In some possible implementations, before invoking the solution generation model and code generation model, it is necessary to perform function correlation analysis using the target function set and target parameter set. The target parameter set contains the parameters required for each function to run, and the target function set consists of relevant functions that implement specific EDA functionalities. That is, correlation analysis is performed on each function in the target function set based on the target parameter set to determine whether the function can run independently and does not depend on other functions. If the correlation analysis results show that there are no independent functions in the target function set, it indicates that there are inter-dependencies between the functions, and thus the solution generation model and code generation model can be executed. The solution generation model integrates functions and parameters to obtain a code generation solution, and the code generation model is used to transform the code generation solution into the Skill script code to be developed.
[0173] In this embodiment, by conducting correlation analysis on each function in the target function set based on the target parameter set, the dependencies between functions can be clearly understood, thereby avoiding problems such as code logic breakage and incompatibility that may occur due to function independence, and thus helping to improve code quality.
[0174] In one embodiment, such as Figure 10 As shown, combined with Figure 3 As shown, the method also includes:
[0175] Step 1002: If the correlation analysis results show that there are independent functions in the objective function set, call the secondary function model.
[0176] For example, when the correlation analysis results show that there are independent functions in the target function set, it indicates that the independent function is independent, and the secondary function model can be called at this time.
[0177] Step 1004: Input the independent function into the sub-function model, and use the sub-function model to convert the independent function into the first code.
[0178] For example, once the independent functions are identified through analysis, they are input into the secondary function model. The secondary function model processes the independent functions according to their characteristics and established rules, specifically: parsing the logic and parameters of the independent functions to clarify their functional purpose; and then, according to the syntax and specifications of a specific programming language (such as the rules and syntax requirements in the EDA field), presenting the functionality of the independent functions in code form (such as the Skill scripting language), i.e., generating the first code.
[0179] Step 1006: Generate second code based on the first function set and the first parameter set; the first function set includes all functions in the target function set except for independent functions, and the first parameter set includes the parameter set corresponding to each function in the first function set.
[0180] For example, the dependencies and logical order among functions within the first function set are identified, and the input and output requirements of each function are clarified based on the first parameter set. Then, according to specific programming language specifications, such as the rules and syntax requirements of the EDA field, the logical relationships between the functions and their corresponding parameters in the first function set are expressed in code (such as Skill scripting language), ultimately forming the second code.
[0181] Step 1008: Combine the first code and the second code to obtain the code to be developed.
[0182] For example, when combining the first code and the second code, the calling order and data interaction method of the first code and the second code are determined according to the overall system logic and architecture. Then, based on the calling order and data interaction method, the first code and the second code are organically integrated to form the code to be developed that can realize the complete business requirements.
[0183] A relatively complete code development workflow framework has been built through multi-model collaboration. However, in actual code development, there are still some cases where independent functions generate code that require special handling. Independent functions often have specific functionalities and logic, and differ somewhat from other functions in the overall workflow. To handle the process of generating code from independent functions, a mechanism such as... Figure 3 The sub-functional model is shown. This model is used to analyze and identify independent functions and generate corresponding code, further refining the entire code development process.
[0184] In one exemplary embodiment, see Figure 3 In code development tools, multiple models work together to generate code to be developed.
[0185] When a user inputs a requirement description, the terminal inputs this description into a scenario matching model. The scenario matching model uses intent recognition to derive the development requirements. Simultaneously, the requirements are categorized into predefined template categories based on preset matching rules within the scenario matching model. If a template is found, it is used when generating subsequent code; otherwise, after determining the functions and parameters, the determined functions and parameters are analyzed to obtain a solution for code generation.
[0186] After clarifying the development requirements, these requirements are input into a pre-screening model. The pre-screening model determines one set of functions by mapping the development requirements to functions in the distribution function library, and another set by mapping the development requirements to functions in the functional function library. Then, it checks for duplicates in both sets of functions to obtain the initial set of functions contained in both sets. The screening process is as follows:
[0187] The specific filtering options are shown below:
[0188]
[0189] in, For the initial set of functions, Let Q be the filtering function, and let Q be the user requirement description. To split the database, For functional databases, The weights of the stream filtering function, Weights for the function filtering criteria. User requirements descriptions include, but are not limited to, specific development needs and user-specified scenarios.
[0190] Next, to ensure logical coherence in the code to be developed, the call logic of the functions in the initial function set needs to be analyzed to filter functions whose call logic matches the development requirements. The initially filtered function set is then input into a post-filtering model. This model uses the correspondence between functions and call logic in the information database to determine the call logic of each function in the initial function set. Finally, the call logic of each function is matched and analyzed with the development requirements and application scenarios to determine the functions whose call logic matches these requirements and scenarios. The specific filtering process is as follows:
[0191]
[0192] in, For the set of objective functions, For information database.
[0193] Once the required functions are determined, the next step is to filter the parameters that meet the development requirements. At this point, the target function set is input into the parameter selection model. An information database is used to filter the parameters of each function in the target function set to obtain the parameter set for each function, thus forming the target parameter set that includes the parameter sets for each function. The details are as follows:
[0194]
[0195] in, For the target parameter set, For parameter database.
[0196] When faced with specific development requirements, it is unnecessary to extract all parameters from the parameter set corresponding to a function. Therefore, during the extraction process, the development requirements are analyzed to clarify the functions that need to be implemented, and then the parameters that can achieve the functions are selected from the parameter set corresponding to the function.
[0197] After determining the parameters, the correlation information contained in the parameters is used to determine whether there are independent functions in the target function set. If independent functions exist, they are input into the secondary function model. The secondary function model processes the independent functions according to their characteristics and predetermined rules to generate the corresponding code.
[0198] The non-independent functions and their corresponding parameters are input into the solution generation model. This model analyzes the non-independent functions and their parameters to obtain a solution that generates code. If a usable template has been previously determined, then, if independent functions are present, spaces can be reserved in the template for the code corresponding to those functions. Simultaneously, the non-independent functions and their corresponding parameters can be filled into the template, resulting in a solution that includes the filled template.
[0199] The solution for generating code, or the solution for generating code and the code corresponding to the independent function, are then input into the code generation model to generate the code to be developed.
[0200] In one embodiment, such as Figure 11 As shown, the method also includes:
[0201] Step 1102: Evaluate and analyze the code to be developed to obtain code evaluation results.
[0202] For example, the code to be developed is evaluated and analyzed to determine whether it meets preset conditions, and thus whether it should be selected as the target code for development. This evaluation and analysis includes syntax evaluation and functional evaluation. In terms of syntax, a professional code inspection tool is used to scan the code, which can accurately identify syntax errors such as spelling mistakes, missing punctuation, and disorganized statement structures. In terms of functionality, the code is placed in a simulated runtime environment, specific test data is input, and the output results are observed to see if they match expectations.
[0203] Step 1104: If the code evaluation result shows that the code to be developed meets the preset conditions, then the code to be developed is identified as the target code to be developed; meeting the preset conditions includes that the code to be developed has correct syntax and that its functions meet the development requirements.
[0204] For example, after testing, if it is determined that the syntax of the code to be developed is correct and that the functionality of the code to be developed meets the development requirements, that is, if the code to be developed meets the preset conditions, then the code to be developed can be used as the target code to be developed.
[0205] In some possible implementations, syntax checking employs mature static analysis methods, utilizing the sklint software to perform syntax compliance checks on the generated code. The specific methods for functional checking are as follows:
[0206] The generated Skill code is run in a simulation environment to modify the specified test file. Then, based on the data format and function characteristics of the test file, the corresponding verification process is invoked (e.g., to check if a specified graphic appears in the layout, DRC (Design Rule Check) is called to perform a design rule check on the test file and obtain the corresponding test results). The test suite defines specific verification methods for each test case and generates standardized test files. By analyzing quantifiable metrics such as the content of the runnable test files or log files, the accuracy of the generated code in fulfilling the user's intent is evaluated.
[0207] Step 1106: If the code evaluation result indicates that the code to be developed does not meet the preset conditions, determine the update requirements based on the code evaluation result, and update the code to be developed according to the update requirements to obtain the target code to be developed.
[0208] For example, if it is determined that the syntax of the code to be developed is incorrect, and / or that the functionality of the code to be developed does not meet the development requirements, then the code to be developed will be updated as needed. If the evaluation finds problems such as spelling errors or disordered statement structure, then the update requirements will include correcting these syntax errors, ensuring that the code conforms to the programming language specifications, adjusting functions in the target function set, and replacing the initial template. If the code cannot achieve the expected functionality, it is necessary to determine whether there are problems with the logic or whether there are errors in the parameters of the functions, and then modify the initial template, functions, or parameters. During the update process, multiple tests and verifications can be performed until syntactically correct code that meets the development requirements is obtained, i.e., the code to be developed.
[0209] In some possible embodiments, for each update process, the previous code to be developed is updated according to the current update requirement to obtain the current code to be developed; if the current update requirement is the first update requirement, then the previous code to be developed is the generated code to be developed; the current code to be developed is analyzed and evaluated to obtain the current evaluation result; if the current evaluation result indicates that the current code to be developed does not meet the preset conditions, the next update requirement is generated based on the current evaluation result, and the next update requirement is used as the new current update requirement and the current code to be developed is used as the new previous code to be developed, and the process returns to execute the update of the new previous code to be developed according to the new current update requirement to obtain the new current evaluation result, until the most recent new current evaluation result indicates that the new code to be developed meets the preset conditions, then the most recent new code to be developed is determined as the target code to be developed; meeting the preset conditions includes that the most recent new code to be developed has correct syntax and that its functionality meets the development requirements.
[0210] For each update process, the previous code to be developed is updated based on the current update requirements to obtain the current code to be developed. If this is the first update, the previous code to be developed is the initially generated code to be developed. Then, the current code to be developed is analyzed and evaluated to obtain the evaluation results. If the current code to be developed does not meet the preset conditions, i.e., it has syntax errors or its functionality does not meet the development requirements, the next update requirement is generated based on the evaluation results, the relevant code is updated, and it is re-evaluated. This process is repeated, iterating and updating and evaluating the code until the new code to be developed is syntactically correct and functionally meets the requirements. At this point, the new code to be developed is identified as the target code to be developed.
[0211] In this embodiment, the use of an initial template, a set of target functions, and a set of target parameters to determine the code to be developed provides a clear starting point for development, making the development process more directional and effectively reducing blind spots. Then, the evaluation of the code to be developed allows for the early identification and resolution of potential problems, avoiding serious errors in subsequent development and reducing development costs. It also allows developers to flexibly adjust the code according to actual conditions, gradually optimizing code performance and functionality, thereby improving the reliability and usability of the code.
[0212] In one embodiment, such as Figure 12 As shown, the code to be developed is evaluated and analyzed to obtain code evaluation results, including:
[0213] Step 1202: Perform a correctness analysis on the syntax of the code to be developed and obtain the correctness analysis results.
[0214] For example, when performing syntax correctness analysis on the code to be developed, a professional code inspection tool is required. The code to be developed is input into the code inspection tool, which then scans the code line by line according to established syntax rules (such as Skill syntax rules). During the scan, the tool can accurately identify various syntax errors (such as in the Skill scripting language). For instance, it can quickly detect spelling errors, such as misspelled variable names; it can also detect missing punctuation issues, such as forgetting to add a semicolon at the end of a statement; and it can determine whether the statement structure is disordered, such as whether the nesting of code blocks is compliant. After the scan is complete, the code inspection tool records these error messages in detail, forming a correctness analysis result.
[0215] Step 1204: If the correctness analysis result shows that the syntax of the code to be developed is correct, perform a completeness analysis on the functionality of the code to be developed to obtain the completeness analysis result; wherein, the code evaluation result includes the correctness analysis result and the completeness analysis result.
[0216] For example, once the correctness analysis shows that the syntax of the code to be developed is entirely correct, a completeness analysis of its functionality is required. Specifically: a simulated runtime environment is set up, which should replicate the actual running scenario of the code as closely as possible; then, specific test data is prepared, covering all possible scenarios the code might encounter; the code to be developed is placed in this environment and the test data is input, and its output is observed. The output is compared with the expected results. If they are completely consistent, it indicates that the code to be developed is functionally complete within the current test scope; if there are differences, it indicates that the code to be developed may have missing functionality or logical errors. Through this test analysis, the completeness analysis result is finally obtained. Then, the completeness analysis result and the correctness analysis result are used together as the code evaluation result.
[0217] In this embodiment, rigorous syntax analysis can promptly identify and correct issues in the code, such as spelling errors, improper punctuation, and disorganized statement structures, ensuring that the code conforms to programming language standards at a fundamental level. Combined with functional integrity analysis, this guarantees that the code can accurately complete various tasks in practical applications, improving its usability and reliability.
[0218] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0219] Based on the same inventive concept, this application also provides a code generation apparatus for implementing the code generation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more code generation apparatus embodiments provided below can be found in the limitations of the code generation method described above, and will not be repeated here.
[0220] In one exemplary embodiment, such as Figure 13 As shown, a code generation device is provided, including: a function filtering module 1302, a parameter extraction module 1304, and a code generation module 1306, wherein:
[0221] The function filtering module 1302 is used to filter an initial set of functions that match the development requirements of the code to be developed from the function database; the function database includes various correspondences between development requirements and functions;
[0222] The function filtering module 1302 is also used to filter a set of target functions whose calling logic conforms to the development requirements from the initial function set based on the information database; the information database includes multiple correspondences between functions and calling logic;
[0223] The parameter extraction module 1304 is used to extract information from the parameters of the target function set according to the parameter database to obtain the target parameter set; the parameter database includes the correspondence between multiple functions and parameter sets;
[0224] The code generation module 1306 is used to generate code to be developed based on the target function set and the target parameter set.
[0225] Each module in the aforementioned code generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0226] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 14 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores template databases, distribution databases, function databases, information databases, and parameter databases. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a code generation method.
[0227] Those skilled in the art will understand that Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0228] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0229] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0230] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0231] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0232] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0233] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0234] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A code generation method characterized by, The method comprises: determining a development requirement of the to-be-developed code through a scene matching model, and screening an initial function set matched with the development requirement from a function database through a pre-screening model; the function database comprises a corresponding relationship between a plurality of development requirements and functions; screening a target function set whose calling logic conforms to the development requirement from the initial function set through a post-screening model according to an information database; the information database comprises a corresponding relationship between a plurality of functions and calling logics; performing information extraction on parameters of the target function set according to a parameter database through a parameter selection model to obtain a target parameter set; the parameter database comprises a corresponding relationship between a plurality of functions and parameter sets; and performing correlation analysis on functions in the target function set based on correlation information contained in the parameters of the target parameter set to obtain a correlation analysis result; generating the to-be-developed code through a sub-function model, a solution generation model and a code generation model based on the correlation analysis result, the target function set and the target parameter set; wherein, in the case that the correlation analysis result is that there is an independent function in the target function set, the independent function is input into the sub-function model to generate code corresponding to the independent function, and the non-independent function and the parameters corresponding to the non-independent function are input into the solution generation model to obtain a solution for generating code, and a position is reserved for the code corresponding to the independent function in the solution.
2. The method of claim 1, wherein, The determination of the development requirement of the to-be-developed code through the scene matching model comprises: calling the scene matching model; the scene matching model is pre-configured with a scene matching template library; inputting a user requirement description into the scene matching model, performing intention recognition on the user requirement description through the scene matching model, and obtaining the development requirement.
3. The method according to any of claims 1-2, characterized in that, The screening of the initial function set matched with the development requirement from the function database through the pre-screening model comprises: calling the pre-screening model; the pre-screening model is pre-configured with the function database; inputting the development requirement into the pre-screening model, and screening the initial function set matched with the development requirement from the function database through the pre-screening model.
4. The method of claim 3, wherein, The function database comprises a shunt database and a function database; the shunt database comprises a corresponding relationship between scene types and functions, and the function database comprises a corresponding relationship between functions and functions; The screening of the initial function set matched with the development requirement from the function database comprises: determining a target search identifier based on the development requirement; the target search identifier comprises a target scene type and a target function; screening a first initial function set from the shunt database according to the target scene type; screening a second initial function set from the function database according to the target function; constructing the initial function set based on the first initial function set and the second initial function set.
5. The method according to any of claims 1-2, characterized by, The information database is used to filter a target function set with calling logic meeting the development demand from the initial function set through a post-filtering model, including: The post-filtering model is called, and the post-filtering model is pre-configured with the information database; The initial function set is input into the post-filtering model, and the target function set with calling logic meeting the development demand is filtered from the initial function set through the post-filtering model.
6. The method of claim 5, wherein, The target function set with calling logic meeting the development demand is filtered from the initial function set, including: For each function in the initial function set, the calling logic corresponding to the function is extracted from the information database through the post-filtering model; The calling logic is matched and analyzed with the development demand to obtain a matching analysis result; In a case where the matching analysis result is that the calling logic meets the development demand, the function is determined as a target function; The target function set includes a plurality of target functions with calling logic meeting the development demand.
7. The method according to any one of claims 1-2, characterized in that, The parameter selection model is called, and the parameter selection model is pre-configured with the parameter database; The target function set is input into the parameter selection model, and the parameter set corresponding to each function in the target function set is extracted from the parameter database through the parameter selection model; The target parameter set includes the parameter set corresponding to each function. The target function set and the target parameter set are input into the solution generation model, and a code solution is generated by integrating the target function set and the target parameter set through the solution generation model; 8. The method according to any one of claims 1-2, characterized in that, The solution generation model and the code generation model are called; The target function set and the target parameter set are input into the solution generation model, and a code solution is generated by integrating the target function set and the target parameter set through the solution generation model; The code solution is input into the code generation model, and the code solution is converted to obtain the to-be-developed code through the code generation model. The method further includes:
9. The method of claim 8, wherein, In a case where a template is used, the solution generation model and the code generation model are called; The template, the target function set and the target parameter set are input into the solution generation model, and the target function set and the target parameter set are filled into the template through the solution generation model to obtain a code solution; The code solution is input into the code generation model, and the code solution is converted to obtain the to-be-developed code through the code generation model. The target function set and the target parameter set are filled into the template through the solution generation model to obtain a code solution, including:
10. The method of claim 9, wherein, For each first function, the association between the parameter set corresponding to the first function and a second function is analyzed to obtain an association analysis result; the first function is any function in the target function set, and the second function includes functions other than the first function in the target function set; In a case where the association analysis result is that the parameter set corresponding to the first function is associated with the second function, the template is analyzed to obtain a template analysis result; According to the template analysis result and the target function set, the template is filled to obtain the code solution; In a case where the association analysis result is that the parameter set corresponding to the first function is not associated with the second function, the template is processed according to the first function to obtain an intermediate template; the intermediate template includes a template that reserves specific information at a target position; wherein the specific information is a position filled by code generated by the second function; The template is analyzed to obtain a template analysis result; According to the second function and the template analysis result, the intermediate template is filled to obtain the code solution.
11. The method of claim 8, wherein, Before the calling of the solution generation model and the code generation model, the method further comprises: In a case where the association analysis result is that there is no independent function in the target function set, the solution generation model and the code generation model are executed to obtain the to-be-developed code; In a case where the association analysis result is that there is the independent function in the target function set, a secondary function model is called; The independent function is input into the secondary function model, and the independent function is converted into a first code by the secondary function model; Based on a first function set and a first parameter set, a second code is generated; the first function set includes all functions in the target function set except the independent function, and the first parameter set includes parameter sets corresponding to functions in the first function set; The first code and the second code are combined to obtain the to-be-developed code.
12. The method of any one of claims 1-2, wherein, The method further comprises: An evaluation analysis is performed on the to-be-developed code to obtain a code evaluation result; In a case where the code evaluation result is that the to-be-developed code meets a preset condition, the to-be-developed code is determined as a target to-be-developed code; the preset condition is met, including that the syntax of the to-be-developed code is correct and the function meets the development requirement; In a case where the code evaluation result is that the to-be-developed code does not meet the preset condition, an update requirement is determined based on the code evaluation result, and the target to-be-developed code is obtained by updating the to-be-developed code according to the update requirement.
13. A code generation apparatus characterized by comprising: The device comprises: A function screening module is configured to determine a development requirement of a to-be-developed code by a scene matching model, and screen an initial function set matched with the development requirement from a function database by a pre-screening model; the function database includes a correspondence between a plurality of development requirements and functions. The function screening module is further configured to screen, according to an information database, a target function set that meets the development requirement from the initial function set through a post-screening model; the information database includes a corresponding relationship between a plurality of functions and a calling logic; The parameter extraction module is configured to perform information extraction on parameters of the target function set according to a parameter database through a parameter selection model to obtain a target parameter set; the parameter database includes a corresponding relationship between a plurality of functions and a parameter set; and the parameter extraction module is further configured to perform correlation analysis on each function in the target function set based on correlation information contained in the parameters of the target parameter set to obtain a correlation analysis result; The code generation module is configured to generate the to-be-developed code based on the correlation analysis result, the target function set, and the target parameter set through a sub-function model, a solution generation model, and a code generation model; and the code generation module is further configured to, in a case where the correlation analysis result is that there is an independent function in the target function set, input the independent function into the sub-function model to generate code corresponding to the independent function, and input a non-independent function and parameters corresponding to the non-independent function into the solution generation model to obtain a solution for generating the code, and reserve a position for the code corresponding to the independent function in the solution.
14. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor implements the steps of the method of any one of claims 1 to 12 when executing the computer program.
15. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 12.
16. A computer program product comprising a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 12. The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 12.
Citation Information
Patent Citations
Code reconstruction method and system, computing device, storage medium and program product
CN120315754A
Method and system for automatically generating front-end Service code
CN120491931A