Device and method for realizing regular expression processing in SV language environment

By providing regular command generation and processing modules in the System Verilog locale, we directly process regular expressions in the locale, solving the complexity and inefficiency of regular expression processing in EDA simulation, and achieving efficient string processing , avoid external file import.

CN119129494APending Publication Date: 2024-12-13CHENGDU JAGUAR MICROSYSTEMS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411220024.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The System Verilog language does not support regular expression processing in EDA simulation, resulting in increased verification complexity and inefficiency, and requires importing formatted files from the outside for processing.

Method used

Provide regular command generation module and processing module in the SV locale environment, generate and process regular expression processing commands, directly perform string processing in the locale environment, avoid external file import, and use library functions to perform regular expression operations.

Benefits of technology

The regular expression processing function in EDA simulation is implemented, which simplifies string processing operations, improves verification efficiency, and reduces dependence on external files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129494A_ABST
    Figure CN119129494A_ABST
Patent Text Reader

Abstract

The invention discloses a device and method for realizing regular expression processing in an SV language environment, and the device comprises a regular command generation module which is used for receiving first call information, generating a regular expression processing command according to the first call information and a preset rule, and writing the regular expression processing command into a command file; the regular command processing module is used for reading and analyzing a regular expression processing command in a command file, processing a regular expression and a character string to be processed, and writing a processing result into a result file; and the regular command generation module is also used for reading the processing result in the result file and returning the processing result to the user. According to the method, the regular expression processing function is realized in the SV language environment, and the character string processing operation in the EDA simulation verification process can be simplified, so that the verification efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic design automation, and in particular to a device and method for implementing regular expression processing in an SV language environment. Background Art

[0002] In the field of Electronic Design Automation (EDA), System Verilog (SV) is a hardware design and verification language that is widely used to simulate and verify complex electronic systems. System Verilog is relatively weak in the ability to export strings and texts, especially in the lack of support for regular expression processing. Therefore, when performing EDA simulation, it is necessary to import formatted files from outside, which increases the complexity of verification. Summary of the invention

[0003] In view of the shortcomings of the prior art, the present application provides a device and method for implementing regular expression processing in an SV language environment, which can implement regular expression processing functions in an SV language environment, enhance string processing operations in the EDA simulation verification process, and eliminate the need to import formatted files from the outside, thereby improving verification efficiency.

[0004] To solve the above problems, the present invention provides the following technical solutions:

[0005] In a first aspect, an embodiment of the present application provides a device for implementing regular expression processing in an SV language environment, including:

[0006] A regular command generation module, used for receiving first call information input by a user in an SV language environment, generating a regular expression processing command according to the first call information and a preset rule, and writing the regular expression processing command into a command file under a preset path, wherein the first call information at least includes a regular expression to be processed, a command type of the regular expression, and a character string to be processed;

[0007] A regular command processing module is used to read and parse the regular expression processing command in the command file, obtain the regular expression, command type and character string to be processed of the regular expression processing command, use the processing command corresponding to the command type to process the regular expression and the character string to be processed, and write the processing result into the result file under the preset storage path;

[0008] The regular command generation module is also used to read the processing result in the result file and return the processing result to the user.

[0009] In some embodiments, the command file and the result file are both text files;

[0010] Each line in the command file is used to store a regular expression processing command, and the regular expression processing command includes the regular expression to be processed, the command type of the regular expression and the character string to be processed;

[0011] Each line in the result file represents a processing result of a regular expression command, and the lines in the result file correspond one-to-one to the lines in the command file.

[0012] In some implementations, the regular command generation module is further configured to receive and parse a path setting command input by a user to obtain the preset storage paths of the command file and the result file.

[0013] In some embodiments, the regular command generation module is also used to send a second call information to the regular command processing module to call the regular command processing module to perform regular expression processing command processing after writing the regular expression processing command into the command file under the preset path, wherein the second call information includes the storage path of the result file.

[0014] In some implementations, the regular command processing module has library functions related to regular expression processing.

[0015] In a second aspect, an embodiment of the present application provides a method for implementing regular expression processing in an SV language environment, including:

[0016] The regular command generation module receives first call information input by a user in an SV language environment, generates a regular expression processing command according to the first call information and a preset rule, and writes the regular expression processing command into a command file under a preset path, wherein the first call information at least includes a regular expression to be processed, a command type of the regular expression, and a character string to be processed;

[0017] The regular command processing module reads and parses the regular expression processing command in the command file, obtains the regular expression, command type and character string to be processed of the regular expression processing command, processes the regular expression and the character string to be processed using a processing command corresponding to the command type, and writes the processing result into the result file under the preset storage path;

[0018] The regular command generation module reads the processing result in the result file and returns the processing result to the user.

[0019] In some embodiments, the command file and the result file are both text files;

[0020] Each line in the command file is used to store a regular expression processing command, and the regular expression processing command includes the regular expression to be processed, the command type of the regular expression and the character string to be processed;

[0021] Each line in the result file represents a processing result of a regular expression command, and the lines in the result file correspond one-to-one to the lines in the command file.

[0022] In some embodiments, the method further comprises:

[0023] The regular command generation module receives and parses the path setting command input by the user, and obtains the preset storage paths of the command file and the result file.

[0024] In some embodiments, the method further comprises:

[0025] After writing the regular expression processing command into the command file under the preset path, the regular command generation module sends a second call information to the regular command processing module to call the regular command processing module to perform regular expression processing command processing, wherein the second call information includes the storage path of the result file.

[0026] In some implementations, the regular command processing module has library functions related to regular expression processing.

[0027] The present application provides a device and method for implementing regular expression processing in an SV language environment. The present application generates a regular expression processing command according to a set rule based on the first call information input by a user through a regular command generation module. The regular command processing module reads and parses the regular expression processing command, and uses a processing command function of the corresponding command type to process the regular expression and the string to be processed. The regular expression processing function can be implemented in the SV language environment, and the string processing operation in the EDA simulation verification process is enhanced. There is no need to import formatted files from the outside, thereby improving verification efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a structural diagram of an apparatus for implementing regular expression processing in an SV language environment provided in an embodiment of the present application.

[0029] Figure 2 It is a flowchart of a method for implementing regular expression processing in an SV language environment provided in an embodiment of the present application.

[0030] Figure 3 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0031] Figure 4 It is a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0033] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0034] See also Figure 1 , Figure 1 Schematic diagram of the structure of the apparatus for implementing regular expression processing in the SV language environment provided by the embodiment of the present application. Figure 1 As shown, in some embodiments, the device 100 for implementing regular expression processing in the SV language environment includes a regular command generation module 110 and a regular command processing module 120. The regular command generation module 110 is used to receive the first call information input by the user in the SV language environment, generate a regular expression processing command according to the first call information and in accordance with preset rules, and write the regular expression processing command into a command file under a preset path, wherein the first call information at least includes the regular expression to be processed, the command type of the regular expression, and the string to be processed. The regular command processing module 120 is used to read and parse the regular expression processing command in the command file, obtain the regular expression, command type, and string to be processed of the regular expression processing command, use the processing command of the corresponding command type to process the regular expression and the string to be processed, and write the processing result into the result file under the preset path. The regular command generation module 110 is also used to read the processing result in the result file and return the processing result to the user.

[0035] The present application generates a regular expression processing command from the first call information input by the user through a regular command generation module. The regular command processing module reads and parses the regular expression processing command, writes the regular expression processing command into a command file, uses a processing command function of the corresponding command type to process the regular expression and the string to be processed, and writes the result into a result file. The regular expression processing function can be implemented in the SV language environment, thereby enhancing the string processing operation in the EDA simulation verification process, and there is no need to import formatted files from the outside, thereby improving verification efficiency.

[0036] In a specific implementation, the preset rule for generating a regular expression processing command is cmd="regular expression command type", pattern="regular expression", string="string to be processed".

[0037] Exemplarily, the first call information is match("hello.*", "hello, world"), where match indicates the command type of the regular expression, hello.* is a specific regular expression to be processed, and hello, world is a specific string to be processed. The first call information indicates that it is necessary to return the result of whether "hello, world" completely matches "hello.*", and the regular expression processing command generated by the regular command generation module 110 is: cmd = "match", pattern = "hello.*", string = "hello, world".

[0038] Exemplarily, if the first call information is sub("this", "that", "this tree"), where sub indicates that the command type is a string replacement command type, this is a specific regular expression to be processed, this tree is a string to be processed, and that is a replaced string of the regular expression matching part. The first call information indicates that the result string after "this" in "this tree" needs to be replaced by "that". The corresponding regular expression processing command generated by the regular command generation module 110 is: cmd = "sub", pattern = "this", repl = "that", string = "thistree".

[0039] In some implementations, each time a user inputs a first call information, the regular command generation module writes a regular expression processing command corresponding to the first call information into a command file.

[0040] In some implementations, the command file is a text file, and each line in the command file is used to store a regular expression processing command. Optionally, the file format of the text file is txt, csv, html or htm, etc.

[0041] In some implementations, the regular command generation module 110 also supports writing a series of commands into a command file, with each line representing a command.

[0042] In some embodiments, the regular command generation module 110 is also used to receive and parse the path setting command input by the user to obtain the preset storage path of the command file and the result file. The regular command generation module 110 also writes the regular expression processing command into the command file under the preset storage path. The regular command generation module 110 is also used to send a second call information to the regular command processing module to call the regular command processing module to process the regular expression processing command after writing the regular expression processing command into the command file under the preset path.

[0043] Optionally, the regular command generation module is also used to send a second call information to the regular command processing module through $system() in the SV language environment to call the regular command processing module, wherein the second call information includes the storage path of the regular expression processing command file and the storage path of the result file of the regular expression processing result.

[0044] In some embodiments, the regular command processing module 120 is used to read and parse the regular expression processing command in the command file, obtain the regular expression, command type and string to be processed of the regular expression processing command, and use the processing function of the corresponding command type to process the regular expression and the string to be processed.

[0045] In some embodiments, the regular command processing module is written in Python. The regular command processing module has library functions related to regular expression processing. A library function is used to implement a regular expression processing. For example, a string matching function, a string search function, a string replacement function, and a string matching grouping function. Among them, the string matching function is used to implement a string matching function, the string search function is used to implement a string search function, the string replacement function is used to implement a string replacement function, and the string matching grouping function is used to implement a string matching grouping function.

[0046] In some embodiments, each line in the command file is used to store a regular expression processing command, and the regular command processing module reads each line in the command file to read the regular expression processing command. Each line in the result file represents the processing result of a regular expression command, and the lines in the result file correspond to the lines in the command file one by one.

[0047] In some embodiments, the regular command generation module 110 supports writing a series of commands into a command file, each line represents a command, and the regular command processing module 120 performs batch processing on the regular processing commands to obtain results, and each line in the result file corresponds to each line in the command file. In this way, it is convenient for the regular command processing module to process multiple regular expression commands once, and it is not necessary to process once for each first call information input, which can improve processing efficiency when the user needs to process a large number of character strings.

[0048] Exemplarily, when the regular expression processing command is: cmd = "match", pattern = "hello.*", string = "hello, world", the regular command processing module parses the regular expression and obtains the specific regular expression command type to be processed as match, the regular expression as hello.*, and the string to be processed as hello, world. The regular command processing module calls the match function, passes the regular expression and the string to be processed to the match function, and then executes re.match ("hello.*", "hello, world") to obtain the corresponding processing result, and writes the processing result to the corresponding line in the result file under the storage path. For example, when the first string completely matches the first regular expression, the return result of the string matching function is 1, otherwise it is 0. By using a one-to-one correspondence between the lines in the command file and the lines in the result file, the one-to-one correspondence between the corresponding commands and the results can be ensured, avoiding processing errors caused by the mismatch between the commands and the results.

[0049] In some implementations, the regular command generation module is further used to read the processing result in the result file and return the processing result to the user. The processing result corresponding to the regular expression command indicates whether the processing is successful or unsuccessful.

[0050] Optionally, when a line of processing results in the result file is empty text, it indicates that the processing is unsuccessful, otherwise it indicates that the processing is successful.

[0051] See also Figure 2 , Figure 2 1 is a flow chart of a method for implementing regular expression processing in an SV language environment provided by an embodiment of the present application. Figure 2 As shown, the method for implementing regular expression processing in the SV language environment includes steps S100 to S300. The specific content of the method refers to the above related description.

[0052] Step S100: The regular command generation module receives the first call information input by the user in the SV language environment, generates a regular expression processing command based on the first call information and in accordance with preset rules, and writes the regular expression processing command into a command file under a preset path, wherein the first call information includes at least the regular expression to be processed, the command type of the regular expression and the character string to be processed.

[0053] In some implementations, the regular command generation module receives and parses the path setting command input by the user to obtain the storage paths of the command file and the result file.

[0054] In some embodiments, after the regular command generation module writes the regular expression processing command into a command file under a preset path, the second call information is sent to the regular command processing module to call the regular command processing module to perform regular expression processing command processing, wherein the second call information includes the storage path of the result file.

[0055] Step S200: The regular command processing module reads and parses the regular expression processing command in the command file, obtains the regular expression, command type and character string to be processed of the regular expression processing command, processes the regular expression and the character string to be processed using the processing command of the corresponding command type, and writes the processing result into a result file under a preset path.

[0056] In some implementations, the regular command processing module has library functions related to regular expression processing.

[0057] In some implementations, the regular command processing module uses a processing command of a corresponding command type and calls a corresponding library function to process the regular expression and the string to be processed.

[0058] In some embodiments, both the command file and the result file are text files.

[0059] Optionally, each line in the command file is used to store a regular expression processing command, and the regular expression processing command includes a regular expression to be processed, a command type of the regular expression, and a character string to be processed.

[0060] Optionally, each line in the result file represents a processing result of a regular expression command, and the lines in the result file correspond one-to-one to the lines in the command file.

[0061] Step S300: The regular command generation module reads the processing result in the result file and returns the processing result to the user.

[0062] See also Figure 3 , Figure 3Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 As shown, the electronic device 400 includes: one or more processors 410 and a memory 420, Figure 3 A processor 410 is taken as an example.

[0063] In some implementations, the processor 410 and the memory 420 may be connected via a bus or other means. Figure 3 The example of connecting through bus is taken in the following.

[0064] In some implementations, the processor 410 stores a regular command generation module and a regular command processing module.

[0065] In some embodiments, the regular command generation module is used to receive first call information input by a user in an SV language environment, generate a regular expression processing command based on the first call information and in accordance with preset rules, and write the regular expression processing command into a command file under a preset path, wherein the first call information includes at least the regular expression to be processed, the command type of the regular expression, and the string to be processed.

[0066] The regular command processing module is used to read and parse the regular expression processing commands in the command file, obtain the regular expression, command type and string to be processed of the regular expression processing command, use the processing command of the corresponding command type to process the regular expression and the string to be processed, and write the processing results into the result file under a preset path.

[0067] The regular command generation module is also used to read the processing results in the result file and return the processing results to the user.

[0068] In some embodiments, the memory 420, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules for implementing the method of regular expression processing in the SV language environment in the embodiment of the present application. The processor 410 executes various functional applications and data processing of the electronic device 400 by running the non-volatile software programs, instructions and modules stored in the memory 420, that is, the implementation method of the regular expression function in the SV language environment of the above method embodiment.

[0069] In some embodiments, the memory 420 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device 400, etc. In addition, the memory 420 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 420 may optionally include a memory remotely arranged relative to the processor 410, and these remote memories may be connected to the controller via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0070] In some embodiments, one or more modules are stored in the memory 420, and when executed by one or more processors 410, the implementation method of the regular expression function in the SV language environment in any of the above method embodiments is executed, for example, the above described Figure 1 The method comprises steps S100 to S400.

[0071] Please refer to Figure 4 , Figure 4 is a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. Figure 4 As shown, the computer-readable storage medium 500 stores a program code 510, and the program code 510 can be called by a processor to execute the method for implementing regular expression processing in the SV language environment described in the above method embodiment.

[0072] The computer-readable storage medium 500 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium 500 has a storage space for program codes for executing any method steps in the method for implementing the regular expression function in the above-mentioned SV language environment. These program codes can be read from or written into one or more computer program products. The program code can be compressed, for example, in an appropriate form.

[0073] In some implementations, the embodiments of the present application further provide a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned method for implementing regular expression processing in an SV language environment.

[0074] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium 500. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited thereto.

[0075] In summary, the present application provides a device and method for implementing regular expression processing in an SV language environment, the device comprising: a regular command generation module, for receiving a first call information input by a user in an SV language environment, generating a regular expression processing command according to the first call information and in accordance with preset rules, and writing the regular expression processing command into a command file under a preset path, wherein the first call information at least includes a regular expression to be processed, a command type of the regular expression, and a string to be processed; a regular command processing module, for reading and parsing the regular expression processing command in the command file, obtaining the regular expression, command type, and string to be processed of the regular expression processing command, processing the regular expression and the string to be processed using a processing command of a corresponding command type, and writing the processing result into a result file under a preset path; the regular command generation module is also used to read the processing result in the result file, and return the processing result to the user. The present application uses a regular command processing module to process the regular expression and the string to be processed using a processing command of a corresponding command type, can implement the regular expression processing function in the SV language environment, can simplify the string processing operation in the EDA simulation verification process, and thus improve the verification efficiency.

[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A device for implementing regular expression processing in an SV language environment, characterized in that: include: A regular command generation module, used for receiving first call information input by a user in an SV language environment, generating a regular expression processing command according to the first call information and a preset rule, and writing the regular expression processing command into a command file under a preset path, wherein the first call information at least includes a regular expression to be processed, a command type of the regular expression, and a character string to be processed; A regular command processing module is used to read and parse the regular expression processing command in the command file, obtain the regular expression, command type and character string to be processed of the regular expression processing command, use the processing command corresponding to the command type to process the regular expression and the character string to be processed, and write the processing result into the result file under the preset storage path; The regular command generation module is also used to read the processing result in the result file and return the processing result to the user.

2. The device according to claim 1, characterized in that: The command file and the result file are both text files; Each line in the command file is used to store a regular expression processing command, and the regular expression processing command includes the regular expression to be processed, the command type of the regular expression and the character string to be processed; Each line in the result file represents a processing result of a regular expression command, and the lines in the result file correspond one-to-one to the lines in the command file.

3. The device according to claim 2, characterized in that: The regular command generation module is also used to receive and parse the path setting command input by the user, and obtain the preset storage path of the command file and the result file.

4. The device according to any one of claims 1 to 3, characterized in that: The regular command generation module is also used to send a second call information to the regular command processing module to call the regular command processing module to perform regular expression processing command processing after writing the regular expression processing command into the command file under the preset path, wherein the second call information includes the storage path of the result file.

5. The device according to claim 4, characterized in that: The regular command processing module has library functions related to regular expression processing.

6. A method for implementing regular expression processing in an SV language environment, characterized in that: include: The regular command generation module receives first call information input by a user in an SV language environment, generates a regular expression processing command according to the first call information and a preset rule, and writes the regular expression processing command into a command file under a preset path, wherein the first call information at least includes a regular expression to be processed, a command type of the regular expression, and a character string to be processed; The regular command processing module reads and parses the regular expression processing command in the command file, obtains the regular expression, command type and character string to be processed of the regular expression processing command, processes the regular expression and the character string to be processed using a processing command corresponding to the command type, and writes the processing result into the result file under the preset storage path; The regular command generation module reads the processing result in the result file and returns the processing result to the user.

7. The method according to claim 6, characterized in that: The command file and the result file are both text files; Each line in the command file is used to store a regular expression processing command, and the regular expression processing command includes the regular expression to be processed, the command type of the regular expression and the character string to be processed; Each line in the result file represents a processing result of a regular expression command, and the lines in the result file correspond one-to-one to the lines in the command file.

8. The method according to claim 7, characterized in that The method further comprises: The regular command generation module receives and parses the path setting command input by the user, and obtains the preset storage paths of the command file and the result file.

9. The method according to any one of claims 6 to 8, characterized in that: The method further comprises: After writing the regular expression processing command into the command file under the preset path, the regular command generation module sends a second call information to the regular command processing module to call the regular command processing module to perform regular expression processing command processing, wherein the second call information includes the storage path of the result file.

10. The method according to claim 9, characterized in that: The regular command processing module has library functions related to regular expression processing.