Application program generation method and device
By receiving and detecting user-input use case description information, generating applications that meet preset rules, solving the problem of insufficient simulation of high-speed or time-sensitive functions in the prior art, and improving the verification quality of chip system-level verification.
Patent Information
- Application Number
- CN202510259074.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-06-27
AI Technical Summary
The DUT applications generated in the prior art are not applicable to simulations of high-speed or time-sensitive functions because they are separated from real usage scenarios, thus reducing the verification quality of chip system-level verification.
By receiving the use case description information input by the user, detecting and translating according to preset detection rules, and generating the corresponding application program. The method includes preprocessing of use case description information, syntax detection, semantic detection, and ultimately generating an application that satisfies the preset rules.
Improves the verification quality of the generated DUT applications for chip system-level verification, making it more suitable for simulation of high-speed or time-sensitive functions.
Smart Images

Figure CN120215953A_ABST
Abstract
Description
Technical Field
[0001] This field relates to the field of computers, and in particular, to a method and device for generating an application program. Background Art
[0002] Currently, in order to verify the design accuracy of a system-on-chip (SoC), chip verification personnel usually use electronic design automation (EDA) tools to simulate and verify the chip.
[0003] Among them, a design under test (DUT) application program is required for system-level simulation verification of the chip. In the related art, usually, the DUT application program is a command parser that has nothing to do with the verification scenario.
[0004] However, since the DUT application program generated in this way is separated from the real usage scenario, the DUT application program is not suitable for simulating high-speed or time-sensitive functions, resulting in low verification quality of the DUT application program for chip verification.
[0005] In summary, in the related art, the generated DUT application program has low verification quality for chip system-level verification. Summary of the Invention
[0006] Embodiments of the present disclosure provide a method, device, equipment, computer storage medium, and computer program product for generating an application program, which can improve the verification quality of the generated DUT application program for chip system-level verification.
[0007] In a first aspect, an embodiment of the present disclosure provides a method for generating an application program, the method including:
[0008] Receiving use case description information input by a user, where the use case description information is generated by the user based on a preset definition rule, and the use case description information includes at least one of a use case description line and a use case description block. The use case description line and the use case description block respectively include annotation domain information and operation domain information. The annotation domain information represents a textual description of a test operation, and the operation domain information includes test operation information;
[0009] Detecting the use case description information according to a preset detection rule to obtain to-be-translated use case description information that meets the preset detection rule;
[0010] Performing a translation operation on the to-be-translated use case description information to obtain an application program corresponding to the to-be-translated use case description information.
[0011] In an implementable embodiment, the use case description information further includes keywords, and the keywords are used to combine multiple use case description lines to obtain a use case description block.
[0012] In an implementable embodiment, the operation domain information further includes variable information, and the variable information is generated based on a non-explicitly declared type method.
[0013] In an implementable embodiment, the use case description line and the use case description block further include target function codes, and the target function codes represent codes for describing complex operations.
[0014] In an implementable embodiment, the use case description information is detected according to a preset detection rule, and the use case description information to be translated that meets the preset detection rule is obtained, including:
[0015] Perform a preprocessing operation on the use case description information to obtain the preprocessed use case description information;
[0016] Perform a syntax detection on the preprocessed use case description information according to a first preset rule to obtain a first detection result;
[0017] In the case where the first detection result indicates that the preprocessed use case description information meets the first preset rule, obtain the use case description information after syntax detection;
[0018] Perform a semantic detection on the use case description information after syntax detection according to a second preset rule to obtain a second detection result;
[0019] In the case where the second detection result indicates that the use case description information after syntax detection meets the second preset rule, obtain the use case description information to be translated.
[0020] In an implementable embodiment, performing a syntax detection on the preprocessed use case description information according to a first preset rule to obtain a first detection result includes:
[0021] According to the first preset rule, detect the format information and the structure information corresponding to the preprocessed use case description information to obtain a detection result;
[0022] In the case where the detection result indicates that the format information and the structure information corresponding to the preprocessed use case description information meet the first preset rule, generate a corresponding syntax tree based on the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information;
[0023] In the case where the syntax tree is successfully generated, obtain the first detection result.
[0024] In an implementable embodiment, generating a corresponding syntax tree based on the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information includes:
[0025] Detect the consistency between the objects and elements in the sub-operation expression corresponding to the operation domain information of the pre-processed use case description information and the target data information stored in the database, and obtain a third detection result. The database is used for translation feature detection;
[0026] When the third detection result indicates that the objects and elements in the sub-operation expression corresponding to the operation domain information of the pre-processed use case description information are consistent with the target data information stored in the database, generate a syntax tree.
[0027] In one implementable embodiment, perform semantic detection on the use case description information after syntax detection according to a second preset rule, and obtain a second detection result, including:
[0028] According to the target object corresponding to the use case description information after syntax detection, add a type identifier corresponding to the target object to the syntax tree to obtain a syntax tree including the target object type identifier. The target objects include expressions, numerical constants, and numerical constants;
[0029] Perform semantic detection on the syntax tree including the target object type identifier according to the second preset rule to obtain a second detection result.
[0030] In one implementable embodiment, when the operation domain information of the use case description information to be translated includes a hardware resource reference symbol, perform a translation operation on the use case description information to be translated to obtain an application program corresponding to the use case description information to be translated, including:
[0031] Based on the hardware resource reference symbol, obtain the corresponding hardware resource information from the hardware model, and the hardware model includes multiple registers;
[0032] Generate corresponding variable definition information based on the second detection result;
[0033] Generate a structure initialization function and an array initialization function according to the use case description information to be translated;
[0034] Obtain built-in code;
[0035] Obtain corresponding annotation information according to the use case description information to be translated;
[0036] Based on the variable definition information, built-in code, annotation information, hardware resource information, structure initialization function, and array initialization function, obtain core code;
[0037] According to the core code, common code, and configuration file, obtain an application program.
[0038] Second, the embodiments of the present disclosure provide a device for generating an application program. The device includes:
[0039] A receiving module, configured to receive use case description information input by a user. The use case description information is generated by the user based on preset definition rules, and includes at least one of a use case description line and a use case description block. The use case description line and the use case description block respectively include annotation domain information and operation domain information. The annotation domain information represents a textual description of a test operation, and the operation domain information includes test operation information.
[0040] A detection module, configured to detect the use case description information according to preset detection rules, and obtain the use case description information to be translated that meets the preset detection rules.
[0041] A translation module, configured to perform a translation operation on the use case description information to be translated, and obtain an application program corresponding to the use case description information to be translated.
[0042] In a third aspect, an embodiment of the present disclosure provides a device for generating an application program. The device includes a processor and a memory storing computer program instructions. The processor reads and executes the computer program instructions to implement the method for generating an application program according to any one of the first aspect.
[0043] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium storing computer program instructions, and the computer program instructions, when executed by a processor, implement the method for generating an application program according to any one of the first aspect.
[0044] In a fifth aspect, an embodiment of the present disclosure provides a computer program product including a computer program, and the computer program, when executed by a processor, implements the method for generating an application program according to any one of the first aspect.
[0045] An embodiment of the present disclosure provides a method, device, device, computer storage medium, and computer program product for generating an application program. The method obtains use case description information, detects the use case description information according to preset detection rules, and obtains the use case description information to be translated that meets the preset detection rules. A translation operation is performed on the use case description information to be translated, and an application program corresponding to the use case description information to be translated is obtained. By translating the use case description information generated by the user based on preset definition rules to obtain an application program, the verification quality of the application program for chip system-level verification can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required to be used in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
[0047] Figure 1 FIG. is a schematic flowchart of a method for generating an application program provided by an embodiment of the present disclosure;
[0048] Figure 2 is a schematic flowchart of a process for obtaining use case description information provided by an embodiment of the present disclosure;
[0049] Figure 3 is a schematic diagram of a syntax tree corresponding to use case description information provided by an embodiment of the present disclosure;
[0050] Figure 4 is a schematic diagram of a database provided by an embodiment of the present disclosure;
[0051] Figure 5 is a schematic diagram of a syntax tree including a target object type identifier provided by an embodiment of the present disclosure;
[0052] Figure 6 is a schematic diagram of a hardware model structure provided by an embodiment of the present disclosure;
[0053] Figure 7 is a schematic structural diagram of a generating device for an application program provided by an embodiment of the present disclosure;
[0054] Figure 8 is a schematic structural diagram of a generating device for an application program provided by an embodiment of the present disclosure. Detailed implementation manners
[0055] The features and exemplary embodiments of various aspects of the present invention will be described in detail below. For the purpose of making the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present invention, rather than to limit the present invention. For those skilled in the art, the present invention can be implemented without some of these specific details. The following description of the embodiments is only to provide a better understanding of the present invention by showing examples of the present invention.
[0056] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, the elements defined by the statement "including..." do not exclude the existence of additional identical elements in the process, method, article or device including the elements.
[0057] Before elaborating on the technical solutions provided by the embodiments of the present disclosure, for the convenience of understanding the embodiments of the present disclosure, the present disclosure specifically describes the problems existing in the related technologies:
[0058] Currently, chip simulation verification based on EDA tools is the main means to ensure the correctness of chip design. A complete verification process generally includes three levels: module level, subsystem level, and chip system level. Among them, chip system level verification (system verification) usually simulates the actual usage scenario and verifies the control and data paths from the CPU to each subsystem and the coordination among subsystems from the perspective of the CPU. The program executed by the CPU is one of the main inputs of this verification process.
[0059] Among them, a Design Under Test (DUT) application program is required for system level verification of the chip. In the related technologies, a command interpreter that has nothing to do with the verification scenario is usually used as the DUT application program. The specific verification scenario is implemented by the TestBench application program. The TestBench application program passes commands and data to the DUT application program through backdoor access. After the latter executes the commands, it feeds back the results to the TestBench application program.
[0060] However, since this type of application program is separated from the real usage scenario, the DUT application program is not suitable for simulating high-speed or time-sensitive functions, resulting in low verification quality of the DUT application program for chip system level verification.
[0061] In addition, in the related technologies, a customized program can also be implemented by the verification personnel according to the verification scenario. However, for the customized program, the verification personnel need to implement the corresponding C language program for each verification, which causes the verification personnel to invest a lot of energy in the design and implementation of the verification program, resulting in a long time spent on verifying the chip using the DUT application program.
[0062] In summary, in the related technologies, the generated DUT application program has low verification quality for chip system level verification and takes a long time to generate.
[0063] The embodiments of the present disclosure provide a method, device, equipment, computer storage medium, and computer program product for generating an application program, which can solve the technical problems existing in the related technologies.
[0064] Embodiments of the present disclosure provide a method, apparatus, device, computer storage medium, and computer program product for generating an application program. The method obtains use case description information. The use case description information is detected according to a preset detection rule to obtain the use case description information to be translated that meets the preset detection rule. A translation operation is performed on the use case description information to be translated to obtain an application program corresponding to the use case description information to be translated. By translating the use case description information generated by the user based on a preset definition rule, the verification quality of the application program for chip system-level verification can be improved.
[0065] The method for generating an application program provided by the embodiments of the present disclosure will be introduced below.
[0066] Figure 1 The flowchart of the method for generating an application program provided by an embodiment of the present disclosure is shown. As Figure 1 , the method includes steps S110-S130.
[0067] S110: Receive the use case description information input by the user.
[0068] Among them, the use case description information is generated by the user based on a preset definition rule. The use case description information includes at least one of a use case description line and a use case description block. The use case description line and the use case description block respectively include annotation domain information and operation domain information. The annotation domain information represents a textual description of the test operation, and the operation domain information includes test operation information.
[0069] In this embodiment, the use case description information input by the user is received.
[0070] Among them, the use case description block includes multiple use case description lines.
[0071] In one embodiment, the use case description information input by the user can be received through an application program generation tool.
[0072] In one example, the user represents a verification personnel.
[0073] In one example, the use case description information can be the execution steps of a simulation use case described in a structured language.
[0074] S120: Detect the use case description information according to a preset detection rule to obtain the use case description information to be translated that meets the preset detection rule.
[0075] In this embodiment, after receiving the use case description information input by the user, the use case description information is detected according to a preset detection rule to obtain the use case description information to be translated that meets the preset detection rule.
[0076] In the step process of the embodiments of the present disclosure, by detecting the use case description information input by the user, the error reporting probability of the subsequently generated application program can be reduced, thereby improving the quality of the generated application program.
[0077] S130: Perform a translation operation on the use case description information to be translated to obtain an application program corresponding to the use case description information to be translated.
[0078] In this embodiment, after detecting the use case description information and obtaining the use case description information to be translated that meets the preset detection rules, perform a translation operation on the use case description information to be translated to obtain an application program corresponding to the use case description information to be translated.
[0079] In one embodiment, the translation operation on the use case description information to be translated can be performed by a translator in the application program generation tool.
[0080] In one example, the application program corresponding to the use case description information to be translated can be the source program of the DUT application program. After being compiled, the source program of the DUT application program can obtain the DUT application program, so as to perform system-level test verification on the chip according to the DUT application program.
[0081] The embodiments of the present disclosure can improve the verification quality of the application program for chip system-level verification by translating the use case description information generated by the user based on the preset definition rules into an application program.
[0082] In one embodiment, the general format of the use case description line is as follows:
[0083] <{annotations}>{operations}
[0084] Among them, <{annotations}> represents annotation domain information, and {operations} represents operation domain information. The curly brackets "{}" represent an aggregator and serve as the boundary for each part of the information.
[0085] Among them, the definition rules of the use case description line content include the following:
[0086] (1) It is composed of ASCII characters. In the embodiments of the present disclosure, other characters are regarded as illegal characters.
[0087] (2) For valid annotation domain information and operation domain information, they must be within the aggregator. Non-blank characters outside the aggregator will not be processed as annotation domain information or operation domain information.
[0088] (3) The annotation domain information and the operation domain information can be empty. If the annotation domain information and the operation domain information are empty, this use case description line is regarded as an empty line.
[0089] (4) If the annotation field information and the operation field information include multiple aggregation symbols, they are treated as one layer of aggregation symbols.
[0090] (5) The annotation field information can be empty, that is, there is only operation field information, but there cannot be only annotation field information.
[0091] (6) There can be or not be whitespace characters, such as spaces, tabs, etc., between the aggregation symbols of the annotation field information and the operation field information.
[0092] (7) The annotation field information is regarded as a whole during parsing and translation. Its original content (excluding the whitespace characters on both sides) is copied as the first line of the code segment corresponding to the description of this line, and is included in the code by the comment symbols / ** / as the comment of this code segment.
[0093] (8) The operation field information consists of several sub-operations, and the sub-operations are in the C-like language format. During parsing and translation, each sub-operation will generate one or more lines of code corresponding to it, and the order of the code is the same as the order of the sub-operations.
[0094] It should be noted that the annotation field information is not only a use case description, but also added to the generated test code as a code comment. On the one hand, it can reflect the consistency between the use case description and the code, and on the other hand, it also helps to increase the readability of the code; the specified form of the operation draws on the writing format and syntax elements of C code. And the application generation tool is compatible with the basic operators and expressions of C. This avoids the redefinition of operators and expressions, and at the same time can reduce the translation difficulty of the application generation tool. It should be pointed out that using the operators and expressions in C format does not mean that the verification personnel only write C code in another way when using this tool, because in system simulation, the main coding content of the verification personnel is to operate the underlying hardware, such as peripheral registers or memory, in order to implement the set verification scenario in the most efficient way. The application generation tool optimizes the specification of hardware operations to the greatest extent to reduce the complexity of hardware operations.
[0095] It can be understood that by defining the use case description line through the above rules, it belongs to an abstract definition. Compared with the writing method of use case description information in related technologies, the embodiments of the present disclosure can improve the efficiency of users in generating use case description information, thereby improving the efficiency of the application program corresponding to the generated use case description information.
[0096] Therefore, the embodiments of the present disclosure obtain an application program by translating the use case description information generated by the user based on preset definition rules. Since the use case description information is generated by the user in combination with the verification scenario, the verification quality of the application program for chip system-level verification can be improved. Since the use case description information is generated based on preset definition rules, the efficiency of the use case description information can be improved, thereby improving the efficiency of the application program corresponding to the generated use case description information.
[0097] In one embodiment, the use case description information further includes keywords, which can support a more flexible operation description method and are used to combine multiple use case description lines to obtain a use case description block.
[0098] In one example, the use case description information may include the keyword "packfunction...endpack", which is used to encapsulate multiple lines of operations into a function and add it to the database in the application generation tool. Subsequently, the same type of operations can be directly described by function call.
[0099] In one example, the use case description information may include the keyword "packstructure...endpack", which is used to encapsulate multiple variables into a structure and add it to the database in the application generation tool. Subsequently, variables can be organized and passed through the structure, and its usage and purpose are similar to those of structures in C language.
[0100] In one example, the use case description information may include the keyword "loop...endloop", which is used to implement loop operations and is suitable for descriptions of operations such as continuous reading and writing of peripherals. The translator in the application generation tool can translate the content described by this keyword into a for loop in C language.
[0101] In one example, the use case description information may include the keyword "if...elseif...else...endif", which is used to implement conditional branch operations. The translator in the application generation tool can translate the content described by this keyword into an if branch in C language.
[0102] In one example, the use case description information may include the keyword "wait", which is used to implement continuous query and waiting operations and is suitable for descriptions of querying hardware status or delaying. The translator in the application generation tool can translate the content described by this keyword into a while loop in C language.
[0103] In one example, the use case description information may include the keyword "with", which is used together with keywords such as "packfunction", "packstructure", "loop", and "wait" to represent additional attributes.
[0104] It should be noted that the foregoing keywords are identifiers with special meanings introduced by the tool for the convenience of use case description and do not include a series of keywords defined in C language. The differences between the two are as follows: First, the former is outside the aggregator; the latter is inside the aggregator. Second, the former is parsed and translated according to the foregoing rules, and the latter is parsed and translated according to C language rules.
[0105] In one embodiment, the operation domain information further includes variable information, which is generated based on a non-explicitly declared type manner, that is, type variables all follow the "define and use" feature, that is, new variables are defined and used in the manner of "variable name = initial value", without specifying the variable type.
[0106] In one example, the variable information includes integer variables. When assigning an initial value to an integer variable, the value should be an integer constant or variable. Constants support decimal and hexadecimal (with the 0x prefix) formats. Integer constants default to the int32_t type and can be explicitly specified with a suffix or by forced conversion. Among them, the suffixes u, l, ul, ll, and ull (case-insensitive) represent the uint32_t, int32_t, uint32_t, int64_t, and uint64_t types respectively. If both a suffix and forced conversion are specified, the forced conversion type shall prevail.
[0107] In one example, the variable information includes floating-point variables. When assigning an initial value to a floating-point variable, the value should be a floating-point constant or variable. The constant can be expressed in general form or exponential form. Floating-point constants default to the double type and can be explicitly specified with a suffix or by forced conversion. Among them, the suffixes f, l (case-insensitive) represent the float and long double types respectively.
[0108] In one example, the variable information includes array type variables. When assigning an initial value to an array type variable, the array length and at least one element initial value (the element initial values are specified in sequence from front to back) should be specified. Among them, the array length should be an integer constant, and the element values can be numerical constants or variables of the target type. The target type can be integer, floating-point, structure type, enumeration type, or pointer type. The array element type can be specified by the aforementioned suffix or forced conversion. When the element types are inconsistent, if they are of the same type, such as all being integer types, then the principle of "unsigned to signed, short bit width to long bit width" is followed; if they are of different types, a type error is prompted by the tool tip. In addition, elements without specified initial values do not participate in type judgment, and their types are determined by the elements with given initial values, and the default value is 0. The array variables can also be initialized by assigning values between arrays, and the elements are assigned values in sequence from front to back.
[0109] It should be noted that assigning values between arrays is only applicable to the scenario of initializing array variables and not to the assignment scenario during general use. The application generation tool calls a predefined array initialization function to complete the initial value assignment after the array is defined and before it is used; for the initialization method using an initial value list, if the number of initial values is less than the array size, the application generation tool fills in the initial value list, and if the number of initial values is greater than the array size, the application generation tool truncates the initial value list.
[0110] In one example, the variable information includes variables of structure type. When initializing a variable of structure type, at least the inherent member _mtype of the structure should be assigned a value, which identifies the structure type name, and the other unassigned members adopt default values. When assigning values, the assignment can be done in order or by member name, but the two methods cannot be used mixedly. Different from the aforementioned types, the types of structure members have been specified for them during encapsulation, so there is no need to explicitly specify the type when initializing values. It is also possible to initialize a structure variable by assigning values between structures, and this method is also applicable to the assignment scenarios during general use.
[0111] In one example, the variable information includes variables of pointer type. When initializing a variable of pointer type, the value should be a numerical constant address, a variable address (the address represented by the variable, note the difference from "the address of the variable"), a pointer variable, or the address of a variable. Among them, the numerical constant address and the variable address need to be cast to the address type, and the address of a variable should be obtained by using the address-of operator (&).
[0112] In one example, the variable information includes variables of void type. The void type is mainly used to specify the parameter and return value types of encapsulated functions when describing use cases, that is, if the return value or parameter is void, it is represented by void.
[0113] In one embodiment, the use case description line and the use case description block also include target function code, and the target function code represents the code for describing complex operations.
[0114] It can be understood that the functionally independent C (or inline assembly) code, that is, the target function code, is embedded into the use case description information to directly describe special or complex operations. Combining it with the general description method can describe more diverse simulation scenarios. The application program generation tool treats the embedded target function code as a black box, and does not check or make any adjustments to its operation description content when translating use cases. The user is responsible for ensuring the correctness of the embedded code format and function.
[0115] In one example, the insert keyword is used for embedding target function code, and it has two basic formats, which are used for embedding functions and embedding code snippets respectively.
[0116] In one example, when the application program generation tool processes an embedded function, it outputs the function implemented by the user to the C code, and replaces the description during embedding with the embedded function at the place where the function is embedded. At the same time, the application program generation tool also enters the function into the database for subsequent calls.
[0117] In one example, the principle of embedding code snippets is similar to that of embedding functions, except that the embedded code snippets are not isolated from the code corresponding to other operation descriptions by means of function encapsulation. Inevitably, this will involve the interoperation of two parts of code. The application generation tool stipulates that variables are not defined within the embedded code snippets and only externally defined variables can be used; the use of external variables is not used as a basis for the application generation tool to determine the variable type (the application generation tool treats it as a black box), and the user should predict the type when using external variables to avoid syntax or functional errors caused by type mismatches.
[0118] In one embodiment, the use case description information is detected according to a preset detection rule to obtain the use case description information to be translated that meets the preset detection rule. As Figure 2 shown, it may include steps S121 - S125.
[0119] S121: Perform a preprocessing operation on the use case description information to obtain the preprocessed use case description information.
[0120] In this embodiment, after receiving the use case description information, a preprocessing operation is performed on the use case description information to obtain the preprocessed use case description information.
[0121] In one embodiment, it can be detected whether the use case description information includes keywords. If keywords are included, the use case description information is regarded as a use case description block. And it is detected whether the keywords (and related content) of the use case description block are in the correct format and whether the block structure is complete. If the use case description block is complete, a preprocessing operation is performed on the use case description block, that is, the use case description block is expanded into multiple use case description lines.
[0122] Among them, the expansion method is to remove the head and tail (structure) content of the block, retain the block body, and enclose the block body with curly braces. When expanding the use case description block, it is also necessary to record information such as the position, type, and head and tail content of the original description block for replacing or inserting corresponding code at the correct position during subsequent block processing.
[0123] In one example, all the preprocessed use case description information is use case description lines.
[0124] In one example, detecting the keywords (and related content) format and block structure of the use case description block includes: detecting the use case description block structure, the block header structure of the use case description block, and the block header content of the use case description block.
[0125] In one example, the detection of the block header content of the use case description block includes: content integrity, identifier legality, data type legality, expression legality, and delimiter legality, etc.
[0126] S122: Perform a syntax check on the preprocessed use case description information according to the first preset rule to obtain a first check result.
[0127] In this embodiment, after obtaining the preprocessed use case description information, a syntax check can be performed on the preprocessed use case description information according to the first preset rule to obtain a first check result.
[0128] In the step process of the embodiments of the present disclosure, by performing a syntax check on the preprocessed use case description information, it is ensured that the syntax rules of the preprocessed use case description information meet the preset conditions.
[0129] S123: When the first check result indicates that the preprocessed use case description information meets the first preset rule, obtain the use case description information after syntax check.
[0130] In this embodiment, when it is detected that the preprocessed use case description information meets the first prediction rule, obtain the use case description information after syntax check.
[0131] S124: Perform a semantic check on the use case description information after syntax check according to the second preset rule to obtain a second check result.
[0132] In this embodiment, after obtaining the use case description information after syntax check, a semantic check can be performed on the use case description information after syntax check according to the second preset rule to obtain a second check result.
[0133] It can be understood that the use case description information after syntax check only conforms to the syntax rules and does not necessarily conform to the semantic rules. For example, the operation of assigning a value to a numerical constant is meaningless. Therefore, in the step process of the embodiments of the present disclosure, by performing a semantic check on the use case description information after syntax check, the use case description information after syntax check can be made to conform to the semantic rules.
[0134] S125: When the second check result indicates that the use case description information after syntax check meets the second preset rule, obtain the use case description information to be translated.
[0135] In this embodiment, when it is detected that the use case description information after syntax check meets the second preset rule, obtain the use case description information to be translated.
[0136] By performing syntax checks and semantic checks on the use case description information, the embodiments of the present disclosure can ensure that the use case description information meets the rules of syntax checks and semantic checks, thereby improving the quality of the application program subsequently translated based on the use case description information.
[0137] In one embodiment, the preprocessed use case description information is subjected to syntax detection according to a first preset rule to obtain a first detection result, which may include steps S1221 - S1223.
[0138] S1221: Detect the format information and structure information corresponding to the preprocessed use case description information according to the first preset rule to obtain a detection result.
[0139] In this embodiment, after obtaining the preprocessed use case description information, the format information and structure information corresponding to the preprocessed use case description information are detected to obtain a detection result.
[0140] In one example, the use case description information, that is, the use case description line, can be subjected to description line detection. The description line detection is used to detect the format information and structure information of the use case description line.
[0141] Specifically, in one example, the description line detection can detect the line structure, character format, and sub - operation separator in the use case description line.
[0142] S1222: When the detection result indicates that the format information and structure information corresponding to the preprocessed use case description information meet the first preset rule, generate a corresponding syntax tree based on the sub - operation expression corresponding to the operation domain information of the preprocessed use case description information.
[0143] In one embodiment, when it is detected that the format information and structure information corresponding to the preprocessed use case description information meet the first preset rule, a corresponding syntax tree is generated according to the sub - operation expression corresponding to the operation domain information of the preprocessed use case description information.
[0144] In one example, if the sub - operation expression corresponding to the operation domain information of the preprocessed use case description information is {datanum = UART0 / / STS / / RXNUM + 1}, a corresponding syntax tree can be generated as Figure 3 shown. Figure 3 In it, the entire sub - operation expression is regarded as an assignment expression; on the left side of the assignment expression is a symbol expression (variable), and on the right side is an addition expression; the addition expression is composed of a hardware resource reference expression and a numeric expression; symbols and numbers are the smallest expressions and they are not composed of other expressions, so they are usually used as the leaf nodes of the entire syntax tree.
[0145] S1223: When the syntax tree is successfully generated, obtain the first detection result.
[0146] In this embodiment, if the syntax tree is successfully generated, the first detection result is obtained.
[0147] Embodiments of the present disclosure generate a syntax tree based on the preprocessed use case description information, and can determine whether the syntax of the preprocessed use case description information conforms to the syntax rules according to the structure of the syntax tree.
[0148] In one embodiment, based on the sub-operation expressions corresponding to the operation domain information of the preprocessed use case description information, a corresponding syntax tree is generated, which may include step S12221 and step S12222.
[0149] S12221: Detect the consistency between the objects and elements in the sub-operation expressions corresponding to the operation domain information of the preprocessed use case description information and the target data information stored in the database to obtain a third detection result.
[0150] Wherein, the database is used for translation feature detection, and the target data information corresponds to the translation feature.
[0151] In one example, the database is located in the application generation tool.
[0152] In this embodiment, by detecting the consistency between the objects and elements in the sub-operation expressions corresponding to the operation domain information of the preprocessed use case description information and the target data information stored in the database, a third detection result is obtained.
[0153] It can be understood that detecting the consistency between the objects and elements of the sub-operation expressions corresponding to the operation domain information of the use case description information in the embodiments of the present disclosure and the target data information stored in the database can be regarded as a database dependency check. That is, through this detection method, it can be ensured that the objects and elements used in the use case description written by the user, such as functions, constant macros, data types, and operators, are uniquely defined in the database, that is, corresponding to the target data information in the database, so that the subsequent translator can parse and translate these objects and elements according to the database.
[0154] S12222: Generate a syntax tree when the third detection result indicates that the objects and elements in the sub-operation expressions corresponding to the operation domain information of the preprocessed use case description information are consistent with the target data information stored in the database.
[0155] In this embodiment, if the third detection result indicates that the objects and elements in the sub-operation expressions corresponding to the operation domain information of the preprocessed use case description information are consistent with the target data information stored in the database, a corresponding syntax tree is generated.
[0156] Embodiments of the present disclosure detect the consistency between the objects and elements in the sub-operation expressions corresponding to the operation domain information of the use case description information, and thus generate a syntax tree according to the detection result, which can avoid the use case description information including objects and elements not defined in the database, thereby improving the accuracy of generating the syntax tree.
[0157] In one embodiment, the user can configure the translation features of the application generation tool, that is, the sets related to the translation features such as the data type set, operator set, constant macro set, and numeric constant suffix set are maintained in the database, and the dynamic configuration of the application generation tool features can be achieved by increasing or decreasing the content of the corresponding sets.
[0158] In addition to translation feature detection, the database can also provide the user with ready-made use case description resources, making the use case description information dynamic and reusable, that is, the content of the database changes dynamically with the use of the tool, and its content can be used in different steps of the same use case description information or different use case description information. It can be understood that the introduction of the database realizes the "one definition, multiple uses" of the operation description, which helps to simplify the complexity of the use case description.
[0159] In one embodiment, the main content of the database includes a function set, a data type set, an operator set, a character constant set, and a numeric constant suffix set.
[0160] In one example, the function set includes function definitions and function declarations. Function definitions refer to functions that are built into the application generation tool or user-defined and added to the database through operations such as packfunction and insert. Function declarations refer to functions defined in the common base code of the C runtime library or the application generation tool. The difference between the two is that function definitions contain the complete implementation of the function, while function declarations only contain the function prototype. The user can directly reference the functions in the function set in the use case description information, and the application generation tool automatically adds the corresponding function definitions or includes the corresponding header files in the generated code. It should be added that the functions for automatically initializing the structure and array (in the case of direct assignment between arrays) added by the application generation tool according to the operation description should also be added to the function set.
[0161] In one example, the data type set includes type definitions and type declarations. Type definitions refer to the structure types that are built into the application generation tool or user-defined and added to the database through the packstructure operation. Type declarations refer to other types described in the "variable definition" mentioned above. The difference between the two is that type definitions contain the complete definition of the type, while type declarations only contain the type identifier. The user can directly reference the data types in the data type set in the use case description information. If the custom structure type is referenced, the application generation tool automatically adds the corresponding type definition or includes the corresponding header file in the generated code. The user can also modify the data type set to change the types supported by the application generation tool, but it should not exceed the type scope in the "variable definition".
[0162] In one example, the operator set contains various operators supported by the application generation tool, including C operators and hardware resource reference symbols. In addition to the operator identifiers, the operator set should also contain the number of parameters and the parameter positions corresponding to each operator, and different operation meanings of the same operator should be described separately. For example, "()" can represent both function call and type conversion, and thus correspond to two descriptions in the operator set respectively. The application generation tool checks the operators in the use case description information according to the descriptions in the operator set. The user can modify the operator set to change the operators supported by the application generation tool, but should not exceed the scope of C operators and hardware resource reference symbols.
[0163] In one example, the character constant set contains common character constants built into the application generation tool, such as defining SYSCLK to represent the system clock frequency value, etc. The user can directly reference them when writing the use case description information, and the application generation tool will automatically add the corresponding macro definitions in the code. To distinguish from other identifiers, the application generation tool stipulates that the letters in the character constants are all in uppercase. That is, if the user uses all-uppercase identifiers in the use case description, the application generation tool defaults to treating them as character constants and looking up the corresponding definitions in the character constant set. The user can modify the character constant set to change the character constants supported by the application generation tool, and the typical usage is to modify the constant value represented by the character.
[0164] In one example, the numeric constant suffix set contains suffixes used to explicitly specify the type of numeric constants, such as u, ul, f, etc. In addition to the suffix identifiers, the suffix set should also contain the data bit width it represents (the data type may not be stored because its represented type is fixed in the C language and should not be defined as different types in the application generation tool), such as u represents 32-bit unsigned integer. The application generation tool checks the numeric constant suffixes in the use case description through the suffix set and identifies the bit width of the numeric constants.
[0165] In one embodiment, for the convenience of the application generation tool to retrieve and the user to consult, the function set, data type set, operator set, character constant set, and numeric constant suffix set in the database are stored in different sub-libraries respectively, and each sub-library adopts the organizational structure of a hierarchical linked list. The content in the database includes two levels, namely the directory entry and the content entry.
[0166] In one example, the schematic diagram of the composition of the database is as Figure 4 shown, where the database includes a function library, a data type library, an operator library, a character constant library, and a numeric constant suffix library.
[0167] In one example, the format of the directory entry of the function library is as follows:
[0168] funcname{return; param1; param2;...}{line}{offset}{include}
[0169] Among them, line and offset respectively represent the line number of the first line of the specific implementation of the function and the offset in the file, which are used to locate the function implementation in the library. include represents the header file containing the function declaration. line and offset are for custom functions, and their values are UNDEF for library functions. include is for library functions, and its value is UNDEF for custom functions; the return value and parameter list of library functions should also be UNDEF values. The application generation tool determines the line number range of the target function in the library according to the line number (non-UNDEF) in the target directory entry and the adjacent directory entry behind it.
[0170] In an example, the content item format of the function library is as follows:
[0171] funcname{return; param1; param2;...}
[0172] {
[0173] / *C format function body* /
[0174] }
[0175] Among them, it contains the function header consistent with the directory entry of the function library and the corresponding function body. The function body is in C language format. The application generation tool can directly copy it to the generated C code (while replacing the function header) when translating the use case. It should be noted that library functions do not have content items.
[0176] In an example, the content item format of the data type library is as follows:
[0177] typename{mem1; mem2;...}{line}{offset}{include}
[0178] Among them, typename is the type name, such as int32_t, float, uart_init_t, etc.; {mem1; mem2;...} is the member list, which is only meaningful for custom structure variables. For C basic data types, its form is {UNDEF}. The meanings of line and offset are the same as those of the line and offset in the function library directory entry; include indicates the header file containing the type definition. Usually, a header file should be specified for C basic data types. For custom structure types, if considering defining them in a header file, the header file should also be specified here. If directly defined in the source file, set include to UNDEF. The line and offset values corresponding to C basic data types are UNDEF.
[0179] In an example, the content item format of the data type library is as follows:
[0180] typename{mem1; mem2;...}
[0181] {
[0182] / *C format type body* /
[0183] }
[0184] Among them, the content item of the data type library contains the type header consistent with the directory entry of the data type library and the corresponding type body. The type body is in C language format, and the application generation tool can directly copy it to the generated C code when translating the use case description information (while replacing the type header). Usually, only custom structure types have content items, and C language basic data types do not have this item content.
[0185] In an example, the directory entry format of the operator library is as follows:
[0186] operator{operands}{pos1; pos2; pos3}{line}{offset}
[0187] Among them, operator is the operator identifier, such as +, +=, (), ->, sizeof, etc.; operands indicates the number of operands corresponding to the operator. Unary, binary, and ternary operators correspond to one, two, and three operands respectively; posN indicates the position of the operand relative to the operator, which is divided into three positions: left, middle, and right. If there is an operand in the corresponding position, the value is 1, otherwise the value is 0; the meanings of line and offset are the same as those of the aforementioned directory entry.
[0188] In an example, the content item format of the operator library is as follows:
[0189] {left type}{mid type}{right type}
[0190] Among them, left type, mid type, and right type respectively represent the sets of legal data types of the left, middle, and right operands of the operator. If there is no corresponding operand, the value is UNDEF.
[0191] It should be noted that the operand types in the operator library are classified as follows:
[0192] (1) Basic operands: basic data types such as integer type and floating-point type, which are divided into two subclasses: constant value and variable value, and their identifiers are specified as cBT (constant value) and vBT (variable value) respectively.
[0193] (2) Pointer operands: pointer variables or pointers (addresses) pointing to a certain data type, which are divided into two subclasses: constant value and variable value, and their identifiers are specified as cPT and vPT respectively.
[0194] (3) Array operands: array variables or pointers pointing to arrays, which are divided into two subclasses: constant value and variable value, and their identifiers are specified as cAT and vAT respectively.
[0195] (4) Structure operands: structure variables or pointers pointing to structures, which are divided into two subclasses: constant value and variable value, and their identifiers are specified as cST and vST respectively.
[0196] (5) Function operands: function pointers or function names, and their identifiers are specified as cFT and vFT respectively.
[0197] (6) Type operands: data type names, and their identifier is specified as OT.
[0198] (7) Model operands: model unit names, and their identifier is specified as MT.
[0199] (8) Expression operands: the entire expression is used as an operand. According to its operation type and operands, the whole can be classified into one of the basic, pointer, array, structure, and function categories.
[0200] In one example, since the character constant library has a single content, the directory entry can be not set.
[0201] In one example, the content item format of the character constant library is as follows:
[0202] constname{value}
[0203] Among them, constname is the constant name and value is the constant value.
[0204] In one example, the directory entry format of the data constant suffix library may not need to be set.
[0205] In one example, the content item format of the data constant suffix library may be as follows:
[0206] suffixname{width}
[0207] Where suffixname is the suffix name and width is the numerical bit width represented by the suffix.
[0208] In one embodiment, the user can directly reference the code elements defined in the database, and the application program generation tool completes the conversion from the reference to the C code. When the user performs an operation that may cause changes to the database content, such as adding a new function definition to the database through packfunction, at this time, the application program generation tool should sequentially execute operations such as duplicate checking, adding functions, and updating the linked list. Among them: the purpose of the duplicate checking operation is to confirm whether there is an item with the same name in the library. If there is an item with the same name, it will prompt that the addition fails; adding a function is to add the corresponding directory entry and content item of the target function to the library; updating the linked list is to update the line and file offset information in the directory entry of the library. It should be noted that when adding a function, the function content item should be the translated C code.
[0209] In one embodiment, semantic detection is performed on the use case description information after syntax detection according to the second preset rule to obtain the second detection result, which may include step S1241 and step S1242.
[0210] S1241: According to the target object corresponding to the use case description information after syntax detection, add a type identifier corresponding to the target object to the syntax tree to obtain a syntax tree including the target object type identifier.
[0211] In this embodiment, according to the target object corresponding to the use case description information after syntax detection, a type identifier corresponding to the target object can be added to the syntax tree to obtain a syntax tree including the target object type identifier.
[0212] The target objects include expressions, numerical constants, and numerical constants.
[0213] In one example, the method for determining the type of a numerical constant can be determined according to the constant suffix of the numerical constant. For example, the constant suffixes 100f and 0x100ul represent the types float and uint32_t respectively. An integer numerical constant without a suffix is defaulted to the type int32_t, and a floating-point numerical constant without a suffix is defaulted to the type double. The type identifier of the numerical constant is cBT.
[0214] In one example, the way to determine the type of a symbolic variable can be to determine it according to the initial value type of the variable. For variables of basic data types, if the user does not explicitly indicate the type when defining the variable, the compiler will determine its appropriate type according to the principle of "wide bit first, floating point first, sign first" in the process of using the variable (assignment). Among them: "wide bit first" means that each time the variable is assigned a value, the pending bit width is recorded as the maximum bit width of the operands of the right value expression; "floating point first" means that if there is a floating point type operand in the right value expression, the pending type is recorded as the floating point type; "sign first" means that if there is a signed operand in the right value expression, the pending sign is recorded as signed. Finally, the final type of the variable is obtained by synthesizing the above information. For variables of non-basic data types, their types can usually be clearly judged according to their initial values without further explanation. It should be noted that when explicitly specifying different types for the same variable, the translator considers it a type conflict and reports an error. The type identifier of the symbolic variable can be cBT, vBT, cPT or vPT.
[0215] In one example, the type of an expression (including sub-operation expressions) is determined by the operator and the operands. When it comes to the operand factor, the principle of "wide bit first, floating point first, sign first" is still followed for judgment. Generally, the types of each expression are deduced level by level from the leaf nodes of the syntax tree upwards. The type identifier of the expression variable can be cBT, vBT, cPT, vPT, cAT, vAT, cST, vST or MT. However, except for member reference expressions and pointer expressions, other types of expressions can usually only be used as right values.
[0216] In one example, Figure 3 After adding the type identifier corresponding to the target object to the syntax tree in Figure 5 as shown, where each target object in the syntax tree corresponds to a type identifier.
[0217] S1242: Perform semantic detection on the syntax tree including the type identifier of the target object according to the second preset rule to obtain the second detection result.
[0218] In this embodiment, semantic detection can be performed on the syntax tree including the type identifier of the target object according to the second preset rule to obtain the second detection result.
[0219] It can be understood that after the syntax tree has the type identifier corresponding to the target object, the translator can further judge the legality of the expression. The main judgment content is whether the expression has a left value and whether the left value type is correct. Expressions without a left value or with an incorrect left value type are regarded as illegal expressions and an error is reported. In addition, more judgment items can also be introduced according to the usage requirements.
[0220] In the embodiments of the present disclosure, by adding corresponding type identifiers to the syntax tree corresponding to the use case description information after syntax detection, it is convenient to perform semantic detection based on the syntax tree including type identifiers, thereby improving the accuracy of semantic detection.
[0221] In one embodiment, when the operation domain information of the use case description information to be translated includes a hardware resource reference symbol, a translation operation is performed on the use case description information to be translated to obtain an application program corresponding to the use case description information to be translated, which may include steps S131 - S137.
[0222] S131: Based on the hardware resource reference symbol, obtain the corresponding hardware resource information from the hardware model.
[0223] Among them, the hardware model includes multiple registers.
[0224] In this embodiment, if the translator detects that the operation domain information in the use case description information includes a hardware resource reference symbol, it obtains the corresponding hardware resource information from the hardware model according to the hardware resource reference symbol.
[0225] In one example, the hardware resource reference symbol is represented by " / / ".
[0226] In one example, the operation domain information of the use case description information includes {busy = UART / / STS / / BUSY}, which represents that it is necessary to read the BUSY value of the STS register of the UART in the hardware model.
[0227] It should be noted that the use case description information has the characteristic of being tightly coupled with the hardware, that is, the use case description information directly operates on the DUT hardware to implement the function to be verified. To adapt to this characteristic, the application program generation tool abstracts the DUT hardware resources and organizes them into a hardware model according to a specific structure, enabling users to refer to specific hardware through the model (entry) when writing use case description information, thereby simplifying the complexity of the use case description and enhancing the readability of the use case. The application program generation tool automatically converts the model (entry) into the corresponding register or storage unit when translating the use case description information.
[0228] S132: Generate corresponding variable definition information based on the second detection result.
[0229] In this embodiment, corresponding variable definition information can be generated based on the second detection result.
[0230] In one embodiment, corresponding variable definition information can be generated in the C language format based on the second detection result.
[0231] S133: Generate a structure initialization function and an array initialization function according to the use case description information to be translated.
[0232] In this embodiment, according to the information of the use case to be translated, a structure initialization function and an array initialization function are generated.
[0233] In one example, the structure initialization function and the array initialization function are respectively used to assign initial values to structure variables or array variables, aiming to prevent illegal values from appearing in the members of the structure variables (for the structure storing hardware configuration parameters, illegal values of the members may cause the hardware to malfunction) and to implement the feature of directly assigning values during array initialization.
[0234] S134: Obtain the built-in code.
[0235] In this embodiment, the built-in code is obtained.
[0236] In one example, the built-in code can be the built-in code of the application generation tool, and the built-in code is used for the translator to translate specific operations.
[0237] S135: According to the information of the use case to be translated, obtain the corresponding annotation information.
[0238] In this embodiment, the corresponding annotation information can be obtained according to the information of the use case to be translated.
[0239] In one embodiment, the corresponding annotation information can be obtained according to the annotation domain information in the information of the use case to be translated. The annotation information can be placed above the code lines generated by the translator as code comments.
[0240] S136: Based on the variable definition information, the built-in code, the annotation information, the hardware resource information, the structure initialization function and the array initialization function, obtain the core code.
[0241] In this embodiment, the core code is obtained according to the variable definition information, the built-in code, the annotation information, the hardware resource information, the structure initialization function and the array initialization function.
[0242] S137: According to the core code, the preset common code and the configuration file, obtain the application program.
[0243] In one embodiment, after obtaining the core code, the application program is obtained according to the core code, the preset common code and the configuration file.
[0244] It should be noted that in the simulation use case project, a part of the code or configuration does not change with the use case description information, or only changes a fixed small amount of content, such as startup files, interrupt / exception handling code, Makefile and link scripts, etc. The application generation tool stores this part of the common code or configuration in the form of C header / source files or project files in the tool root directory for subsequent merging with the core code to obtain the application program.
[0245] In one example, after obtaining the core code, the translator copies the core code, the preset common code, and the configuration file to the project directory, calls the generated test function in the main function, then adds the generated code file to the Makefile, and selects an appropriate link script to generate a source application that can be directly compiled.
[0246] By obtaining variable definition information, built-in code, annotation information, hardware resource information, structure initialization functions, and array initialization functions, the embodiments of the present disclosure can obtain the core code, which facilitates obtaining the application program based on the core code subsequently.
[0247] In one embodiment, if the operation domain information of the use case description information to be translated does not include a hardware resource reference symbol, a translation operation is performed on the use case description information to be translated to obtain an application program corresponding to the use case description information to be translated, which may include the following steps: generating corresponding variable definition information based on the second detection result; generating structure initialization functions and array initialization functions according to the use case description information to be translated; obtaining the built-in code; obtaining corresponding annotation information according to the use case description information to be translated; obtaining the core code based on the variable definition information, the built-in code, the annotation information, the hardware resource information, the structure initialization functions, and the array initialization functions; and obtaining the application program according to the core code, the preset common code, and the configuration file.
[0248] In one embodiment, before obtaining the core code, the translator can process the remaining untranslated block headers of the use case description block expanded into use case description lines. The main processing methods are as follows:
[0249] (1) For the packfunction block, replace the packfunction block with a encapsulated function and add the function to the database.
[0250] (2) For the packstructure block, define a structure variable using the encapsulated structure type and add the structure type to the database.
[0251] (3) For the loop block, generate a for loop structure according to the block header and replace the loop block.
[0252] (4) For the if block, generate an if branch structure according to the block header and replace the if block.
[0253] (5) For the wait block, generate a while loop structure according to the block header and replace the wait block.
[0254] In one embodiment, the hardware model may include general-purpose function registers (GPRs), control and status registers (CSRs), bus-mapped registers (BMRs), and bus-mapped memory units (BMMs). Among them, the general-purpose function registers may be general registers within the core. The control and status registers may be control and status registers within the core. The bus-mapped registers refer to peripheral registers and some registers within the core that are mapped to the bus address space. The bus-mapped memory units refer to memory units that are mapped to the bus address space.
[0255] In one embodiment, the hardware model may include a three-level structure of "module-register-bit field" to cover the above various registers and their corresponding minimum functional units.
[0256] In one example, the model structure of the hardware model is as Figure 6 shown. Among them, the model header is used to store flag information indicating the start of the model, the starting position of the module directory, the number of block directory entries, and other model description information. The module directory is used to store information such as the base address, type, starting position of the lower-level register directory, and the number of register directory entries of each module. The register directory is used to store information such as the address / offset, read / write property, starting address of the lower-level bit field, and the number of bit field entries of each register. The bit field is used to store bit field information, including bit offset, bit width, read / write property, and default value, etc. The model tail is used to store flag information indicating the end of the model.
[0257] In one example, the hardware model may also insert specific delimiters between the register directory entries of different modules and between the bit field entries of different registers for easy reference by users.
[0258] In one embodiment, since there are many entries in the module directory, register directory, and bit field, a unified format needs to be adopted.
[0259] In one example, the format of the module directory is as follows:
[0260] modname{type}{base}{size}{subitem}{line}{offset}
[0261] Among them, modname represents the module name, such as CORE_GPR, CORE_CSR, UART, FLASH, etc. type represents the module type, which can be GPR, CSR, BMR, BMM. base represents the module base address. For GPR and CSR types, the value is UNDEF. size represents the module size. It is only valid for BMM type. For other types, the value is UNDEF. subitem represents the number of sub-items of the lower-level register of the module. For BMM type, the value is UNDEF. line represents the line number of the first item of the lower-level register of the module. For BMM type, the value is UNDEF. The main purpose of setting this field is to facilitate manual review by users. offset represents the offset of the first item of the lower-level register of the module in the file. For BMM type, the value is UNDEF. The main purpose of setting this field is to facilitate tool retrieval.
[0262] In an example, the register directory format is as follows:
[0263] regname{addr / offset}{r / w}{subitem}{line}{offset}
[0264] Among them, regname represents the register name, such as CTRL, STS, etc. addr / offset represents the register address or the offset relative to the base address. For GPR type, this value is UNDEF. r / w represents the read / write nature of the register, such as RO, WO, or RW. subitem represents the number of subitems in the lower bit field of the register. For GPR type, this value is UNDEF. line represents the line number of the first item in the lower bit field of the register. For GPR type, this value is UNDEF. offset represents the offset of the first item in the lower bit field of the register in the file. For GPR type, this value is UNDEF.
[0265] In an example, the bitfield format is as follows:
[0266] fieldnum{offset}{width}{r / w}{default}
[0267] Among them, fieldname represents the bit field name, such as TXEN, RXEN, etc. offset represents the bit offset of the bit field in the register. width represents the width of the bit field. r / w represents the read / write nature of the bit field. default represents the default value of the bit field.
[0268] like Figure 7 As shown, the embodiment of the present disclosure further provides a device 700 for generating an application program, and the device 700 for generating an application program includes:
[0269] A receiving module 701, configured to receive use case description information input by a user. The use case description information is generated by the user based on a preset definition rule, and the use case description information includes at least one of a use case description line and a use case description block. The use case description line and the use case description block respectively include annotation domain information and operation domain information. The annotation domain information represents a textual description of a test operation, and the operation domain information includes test operation information;
[0270] A detection module 702, configured to detect the use case description information according to a preset detection rule, and obtain to-be-translated use case description information that meets the preset detection rule;
[0271] A translation module 703, configured to perform a translation operation on the to-be-translated use case description information, and obtain an application program corresponding to the to-be-translated use case description information.
[0272] In an embodiment of the present disclosure, use case description information is obtained; the use case description information is detected according to a preset detection rule, and to-be-translated use case description information that meets the preset detection rule is obtained; a translation operation is performed on the to-be-translated use case description information, and an application program corresponding to the to-be-translated use case description information is obtained. By translating the use case description information generated by the user based on a preset definition rule to obtain an application program, the verification quality of the application program for chip verification can be improved.
[0273] In some embodiments, the use case description information further includes keywords, and the keywords are used to combine multiple use case description lines to obtain a use case description block.
[0274] In some embodiments, the operation domain information further includes variable information, and the variable information is generated based on a non-explicit declaration type manner.
[0275] In some embodiments, the use case description line and the use case description block further include target function codes, and the target function codes represent codes for describing complex operations.
[0276] In some embodiments, the generating device 700 of the application program further includes a preprocessing module, and the preprocessing module is configured to perform a preprocessing operation on the use case description information to obtain preprocessed use case description information;
[0277] Perform syntax detection on the preprocessed use case description information according to a first preset rule to obtain a first detection result;
[0278] In a case where the first detection result indicates that the preprocessed use case description information meets the first preset rule, obtain the use case description information after syntax detection;
[0279] Perform semantic detection on the use case description information after syntax detection according to a second preset rule to obtain a second detection result;
[0280] When the use case description information after syntax detection in the second detection result satisfies the second preset rule, the use case description information to be translated is obtained.
[0281] In some embodiments, the detection module 702 is specifically configured to:
[0282] Detect the format information and structure information corresponding to the preprocessed use case description information according to the first preset rule to obtain a detection result;
[0283] When the detection result indicates that the format information and structure information corresponding to the preprocessed use case description information satisfy the first preset rule, a corresponding syntax tree is generated based on the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information;
[0284] When the syntax tree is successfully generated, the first detection result is obtained.
[0285] In some embodiments, the detection module 702 is specifically configured to:
[0286] Detect the consistency between the objects and elements in the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information and the target data information stored in the database, where the database is used for translation feature detection, to obtain a third detection result;
[0287] When the third detection result indicates that the objects and elements in the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information are consistent with the target data information stored in the database, a syntax tree is generated.
[0288] In some embodiments, the generating device 700 of the application further includes an adding module, and the adding module is configured to add a type identifier corresponding to the target object to the syntax tree according to the target object corresponding to the use case description information after syntax detection, to obtain a syntax tree including the target object type identifier, where the target objects include expressions, numerical constants, and numerical constants;
[0289] Perform semantic detection on the syntax tree including the target object type identifier according to the second preset rule to obtain a second detection result.
[0290] In some embodiments, the generating device 700 of the application further includes an obtaining module, and the obtaining module is configured to obtain corresponding hardware resource information from the hardware model based on the hardware resource reference symbol, where the hardware model includes multiple registers;
[0291] Generate corresponding variable definition information based on the second detection result;
[0292] Generate a structure initialization function and an array initialization function according to the use case description information to be translated;
[0293] Obtain built-in code;
[0294] Obtain the corresponding annotation information according to the description information of the use case to be translated;
[0295] Based on the variable definition information, built-in code, annotation information, hardware resource information, structure initialization function, and array initialization function, obtain the core code;
[0296] According to the core code, the preset common code, and the configuration file, obtain the application program.
[0297] Figure 7 Each module / unit in the shown device has the function of implementing Figures 1 to 2 each step executed by the application system in, and can achieve its corresponding technical effects. For the sake of concise description, it will not be elaborated here.
[0298] Figure 8 The figure shows a schematic hardware structure diagram for generating an application program provided by an embodiment of the present disclosure.
[0299] The device for generating the application program may include a processor 801 and a memory 802 storing computer program instructions.
[0300] Specifically, the above-mentioned processor 801 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0301] The memory 802 may include a mass storage for data or instructions. By way of example and not limitation, the memory 802 may include a Hard Disk Drive (HDD), a floppy disk drive, a flash memory, an optical disc, a magneto-optical disc, a magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. In a suitable case, the memory 802 may include removable or non-removable (or fixed) media. In a suitable case, the memory 802 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 802 is a non-volatile solid-state memory.
[0302] The memory 802 may include a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical, or other physical / tangible memory storage device. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0303] The processor 801 reads and executes the computer program instructions stored in the memory 802 to implement the generation method of any one of the application programs in the above embodiments.
[0304] In one example, the application program generation device may further include a communication interface 803 and a bus 804. Among them, as Figure 8 shown, the processor 801, the memory 802, and the communication interface 803 are connected through the bus 804 to complete communication with each other.
[0305] The communication interface 803 is mainly used to implement communication between each module, device, unit, and / or device in the embodiments of the present application.
[0306] The bus 804 includes hardware, software, or both, and couples the components of the online data flow metering device to each other. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, the bus 804 may include one or more buses. Although the embodiments of the present invention describe and illustrate specific buses, the present invention contemplates any suitable bus or interconnect. Additionally, in combination with the method for generating an application program in the above embodiments, an embodiment of the present application also provides a computer storage medium for implementation. Computer program instructions are stored on the computer storage medium; when the computer program instructions are executed by a processor, any one of the methods for generating an application program in the above embodiments is implemented.
[0307] An embodiment of the present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, any one of the methods for generating an application program in the above embodiments is implemented.
[0308] It should be clear that the present invention is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present invention is not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications, and additions, or change the order between steps after understanding the spirit of the present invention.
[0309] The functional blocks shown in the above structural block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, and so on. When implemented in software, the elements of the present invention are programs or code segments for performing the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted over a transmission medium or communication link via a data signal carried in a carrier wave. "Machine-readable medium" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical discs, hard disks, fiber optic media, radio frequency (RF) links, and so on. The code segment can be downloaded via a computer network such as the Internet, an intranet, and so on.
[0310] It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps can be executed in the order mentioned in the embodiments, or different from the order in the embodiments, or several steps can be executed simultaneously.
[0311] Aspects of the present disclosure have been described above with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block in the flowcharts and / or block diagrams, and the combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the functions / actions specified in one or more blocks of the flowcharts and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It should also be understood that each block in the block diagrams and / or flowcharts, and the combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware for performing the specified functions or actions, or by a combination of dedicated hardware and computer instructions.
[0312] The above are only specific embodiments of the present invention. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules, and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be elaborated herein. It should be understood that the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention.
Claims
1. A method for generating an application, characterized in that: The method comprises: Receive use case description information input by a user, the use case description information is generated by the user based on a preset definition rule, the use case description information includes at least one of a use case description line and a use case description block, the use case description line and the use case description block respectively include comment domain information and operation domain information, the comment domain information represents a text description of a test operation, and the operation domain information includes test operation information; Detecting the use case description information according to a preset detection rule to obtain the use case description information to be translated that meets the preset detection rule; A translation operation is performed on the use case description information to be translated to obtain an application corresponding to the use case description information to be translated.
2. The method according to claim 1, characterized in that The use case description information further includes a keyword, and the keyword is used to combine multiple use case description lines to obtain a use case description block.
3. The method according to claim 1, characterized in that The operation domain information also includes variable information, and the variable information is generated based on a non-explicitly declared type.
4. The method according to claim 1, characterized in that The use case description line and the use case description block also include a target function code, wherein the target function code represents a code that describes a complex operation.
5. The method according to claim 1, characterized in that The detecting the use case description information according to the preset detection rules to obtain the use case description information to be translated that satisfies the preset detection rules includes: Performing a preprocessing operation on the use case description information to obtain preprocessed use case description information; Performing grammar detection on the preprocessed use case description information according to a first preset rule to obtain a first detection result; When the first detection result indicates that the preprocessed use case description information satisfies the first preset rule, obtaining the use case description information after grammar detection; Performing semantic detection on the use case description information after the grammatical detection according to a second preset rule to obtain a second detection result; When the second detection result indicates that the use case description information after the grammar detection satisfies the second preset rule, the use case description information to be translated is obtained.
6. The method according to claim 5, characterized in that The performing grammar detection on the preprocessed use case description information according to the first preset rule to obtain a first detection result includes: According to a first preset rule, the format information and the structure information corresponding to the preprocessed use case description information are detected to obtain a detection result; In a case where the detection result indicates that the format information and the structure information corresponding to the preprocessed use case description information satisfy the first preset rule, generating a corresponding syntax tree based on the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information; When the syntax tree is generated successfully, the first detection result is obtained.
7. The method according to claim 6, characterized in that The generating of a corresponding syntax tree based on the sub-operation expression corresponding to the operation domain information of the pre-processed use case description information comprises: Detecting the consistency of objects and elements in the sub-operation expression corresponding to the operation domain information of the preprocessed use case description information and the target data information stored in the database to obtain a third detection result, wherein the database is used for translation feature detection; The syntax tree is generated when the third detection result indicates that the objects and elements in the sub-operation expressions corresponding to the operation domain information of the preprocessed use case description information are consistent with the target data information stored in the database.
8. The method according to claim 6, characterized in that The performing semantic detection on the use case description information after the grammatical detection according to the second preset rule to obtain a second detection result includes: According to the target object corresponding to the use case description information after the grammar detection, a type identifier corresponding to the target object is added to the grammar tree to obtain a grammar tree including the target object type identifier, wherein the target object includes an expression, a numerical constant and a numerical constant; The semantic detection is performed on the syntax tree including the target object type identifier according to the second preset rule to obtain the second detection result.
9. The method according to claim 5, characterized in that In a case where the operation domain information of the use case description information to be translated includes a hardware resource reference symbol, the translating operation on the use case description information to be translated to obtain an application corresponding to the use case description information to be translated includes: Based on the hardware resource reference, obtaining corresponding hardware resource information from a hardware model, wherein the hardware model includes a plurality of registers; generating corresponding variable definition information based on the second detection result; Generate a structure initialization function and an array initialization function according to the description information of the use case to be translated; Get the built-in code; Obtaining corresponding annotation information according to the description information of the use case to be translated; Based on the variable definition information, built-in code, annotation information, hardware resource information, structure initialization function and array initialization function, a core code is obtained; The application is obtained according to the core code, the preset common code and the configuration file.
10. A device for generating an application, characterized in that: The device comprises: A receiving module, the receiving module is used to receive use case description information input by a user, the use case description information is generated by the user based on a preset definition rule, the use case description information includes at least one of a use case description line and a use case description block, the use case description line and the use case description block respectively include comment domain information and operation domain information, the comment domain information represents a text description of a test operation, and the operation domain information includes test operation information; A detection module, the detection module is used to detect the use case description information according to a preset detection rule to obtain the use case description information to be translated that meets the preset detection rule; A translation module is used to translate the use case description information to be translated to obtain an application corresponding to the use case description information to be translated.