VVP file pre-analysis method and computer-readable storage medium

By pre-analyzing the VVP file, analyzing the official document to generate recognition rules, performing syntax analysis and outputting logical relationships, the problem of difficult reading of the VVP file is solved, automatic parsing and logical relationship output is realized, and simulation efficiency is improved.

CN113515907BActive Publication Date: 2025-04-15SHENZHEN STATE MICRO TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110363636.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-02
Publication Date
2025-04-15
Estimated Expiration
2041-04-02

AI Technical Summary

Technical Problem

In the prior art, when processing VVP files, it is difficult for users to quickly read and understand the file content, resulting in low simulation efficiency.

Method used

A pre-analysis method for VVP files is proposed. By analyzing the official documents of VVP files, analyzing the clones and labeling the category tags, storing them as indexes, finding the logic gate and the driver relationship, and outputting them to the Json file.

Benefits of technology

The automatic analysis of VVP files and the output of logical relationships are realized, so that users can clearly understand the logical units and driving relationships of gate-level circuits, and improve simulation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113515907B_ABST
    Figure CN113515907B_ABST
Patent Text Reader

Abstract

The present invention discloses a pre-analysis method for a VVP file and a computer-readable storage medium. The pre-analysis method for a VVP file includes: parsing the official document of the VVP file to generate an identification rule for the VVP file; performing grammatical analysis on the statements of the VVP file according to the identification rule, annotating the fields identified by the grammatical analysis with corresponding category labels according to their categories and storing them as indexes; reading the statements of the VVP file according to the index, finding all the logic gates of the VVP file and the driving and driven relationships between the logic gates and outputting them. The present invention can pre-analyze the VVP file, extract important logic information from it and automatically generate corresponding files with logical dependencies, thereby improving simulation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a VVP file content analysis technology, and in particular to a VVP file pre-analysis method. Background Art

[0002] In the process of simulating gate-level circuits, analysis of Verilog (Verilog HDL, a hardware description language that can represent logic circuit diagrams) is essential.

[0003] VVP files are unique to iVerilog (short for icarus Verilog, known as the "world's fourth largest" digital chip simulator, and a completely open source simulator) and have unique analytical value. VVP is an assembly-like executable format generated by this open source general EDA tool. The program itself is an interpreter that only uses .vvp files as input. The generation of VVP input files is handled by / tgt-vvp. Therefore, although the syntax is readable, it is not very convenient for users to read, which will lead to low simulation efficiency in this link. Summary of the invention

[0004] In order to solve the technical problem that the VVP files processed in the prior art are inconvenient for users to read, the present invention proposes a VVP file pre-analysis method and a computer-readable storage medium.

[0005] The VVP file pre-analysis method proposed by the present invention includes:

[0006] Step 1, parse the official document of the VVP file to generate the identification rules of the VVP file;

[0007] Step 2, perform grammatical analysis on the statements of the VVP file according to the identification rules, annotate the fields identified by the grammatical analysis with corresponding category labels according to their categories and store them as indexes;

[0008] Step 3: read the statements of the VVP file according to the index, find all the logic gates of the VVP file and the driving and driven relationships between the logic gates, and output them.

[0009] Furthermore, the parsing of the official document of the VVP file in step 1 specifically involves dividing the VVP file into an executor path, a header statement, multiple modules, and a file list.

[0010] Further, the step 3 comprises:

[0011] Step 3.1, find a statement containing a logic gate according to the index, use the statement as the current statement, and use the logic gate as the current logic gate;

[0012] Step 3.2, find the input information of the current logic gate in the current statement;

[0013] Step 3.3, search for the output information of the current logic gate in other statements other than the current statement;

[0014] Step 3.4, check the module where the current statement is located;

[0015] Step 3.5, organize the contents found in steps 3.2 to 3.4 to form the logic unit of the current logic gate and output it to the Json file, return to step 3.1 to read the next statement of the VVP file until the logic units of all logic gates are output.

[0016] Furthermore, the category tags include: Header, Label, Opcode, Operand, Comment, and Filename.

[0017] Furthermore, in step 3.5, the contents found in steps 3.2 to 3.4 are organized to form a logic unit of the current logic gate and output, specifically including:

[0018] When a statement with the category label Opcode and the content of the field .functor is found, it is regarded as a statement containing a logic gate, and the statement is the current statement, and the logic gate pointed to by .functor is the current logic gate;

[0019] Read the label of the current logic gate and output it to a Json file in the preset format;

[0020] Read the first Operand of the current statement, output the functor type of the current logic gate in the content before the space in the Operand according to the preset format, and then output the content after the space in the first Operand as the corresponding input bit width in the preset format;

[0021] Read the second Operand of the current statement until the semicolon as the input of the current logic gate and output it to the Json file in the preset format;

[0022] Search the label of the current logic gate in the Operand list of other statements containing .functor. If it matches, the matched logic gate is used as the driven logic gate. The label of the driven logic gate is taken out and output to the driver list of the current logic gate in the Json file.

[0023] Check the module where the current statement is located and output it to a Json file in the preset format.

[0024] Furthermore, the index specifically stores the identified fields and their corresponding category labels via key-value pairs.

[0025] Furthermore, the identification rules include: grammatical rules constituting Label, grammatical rules constituting Opcode, grammatical rules constituting Operand, grammatical rules constituting each sentence in the VVP file, and grammatical rules constituting the header sentence.

[0026] Furthermore, the identification rules are respectively represented by railway diagrams.

[0027] The computer-readable storage medium proposed in the present invention is used to store a computer program. When the computer program is executed by at least one processor, the pre-analysis method of the VVP file described in the above technical solution is executed.

[0028] The present invention realizes automatic parsing of VVP files and generates Json file output with logical relationships, so that users can clearly understand the driving and driven relationship of each logic unit of the gate-level circuit, and solves the problem of converting the RTL-level description of the Verilog HDL file into the gate-level circuit grid expression. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The present invention is described in detail below with reference to the embodiments and accompanying drawings, wherein:

[0030] Figure 1 This is the VVP file structure analyzed by the present invention.

[0031] Figure 2 It is a railroad diagram of the grammatical rules that constitute Label in the present invention.

[0032] Figure 3 It is a railroad diagram of the grammatical rules that constitute the Opcode of the present invention.

[0033] Figure 4 It is a railroad diagram of the grammatical rules that constitute Operand of the present invention.

[0034] Figure 5 It is a railroad diagram of the grammatical rules that constitute each sentence in the VVP file of the present invention.

[0035] Figure 6 It is a railway diagram of the grammatical rules for forming the head sentence of the present invention.

[0036] Figure 7 is an output example of the logic unit of the present invention.

[0037] Figure 8 It is a schematic diagram of index storage of the present invention. DETAILED DESCRIPTION

[0038] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0039] Thus, a feature indicated in this specification will be used to illustrate one of the features of an embodiment of the present invention, rather than implying that each embodiment of the present invention must have the described feature. In addition, it should be noted that this specification describes many features. Although some features can be combined together to illustrate possible system designs, these features can also be used in other combinations that are not explicitly described. Thus, unless otherwise stated, the described combinations are not intended to be limiting.

[0040] The principle of the present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0041] The VVP file pre-analysis method proposed in the present invention needs to first parse the official documents of the VVP file to generate the corresponding VVP file identification rules. Different VVP files have different official documents. By analyzing the official documents of the VVP file, the present invention finds that the contents of the VVP file can be classified and divided, such as Figure 1 As shown, the content of the VVP file can be divided into four parts. The first line is the executor path, followed by the header statement, which starts with a colon; followed by various modules (Scope), each module contains various functional statements, and there is a file list at the end of the file to store the original file information.

[0042] Each module in the VVP file is composed of multiple statements. Each scope block contains variable definitions, port information, function statements, and event family statements, etc. Then the present invention finds that the components of each statement can be divided into labels, instructions, operations, comments, file lists, etc. Based on the rules found by the present invention in parsing the VVP official document, the corresponding VVP file recognition rules are generated. In this embodiment, the recognition rules include the grammatical rules that constitute the Label, the grammatical rules that constitute the Opcode, the grammatical rules that constitute the Operand, the grammatical rules that constitute each statement in the VVP file, and the grammatical rules that constitute the header statement. And the present invention represents these grammatical rules through a grammatical railway diagram, making the grammar of the VVP file more intuitive. Through these rules, the category of the corresponding field can be automatically identified, so that it can be classified and stored as an index, so that when searching for the logical relationship between gate units in the later stage, the corresponding content can be quickly found.

[0043] Figure 2 To express the grammatical rules of Label through railroad diagrams, Label starter represents the starting symbol of Label (because Label cannot start with a number or a decimal point), Digit represents numbers (0-9), Letter represents letters (Aa-Zz), and Special Symbol represents special symbols ($<>_. / ).

[0044] Figure 3 The grammatical rules for forming Opcodes are expressed through railway diagrams, where "% or ." represents the Opcode's starting symbol as "%" (percent sign) or "." (decimal point), Special Symbol represents special symbols ($<>_. / ), and Letter represents letters (Aa-Zz).

[0045] Figure 4 The grammatical rules for forming Operands are expressed through a railway diagram, where Digit represents numbers (0~9), Letter represents letters (Aa-Zz), and Special Symbol represents special symbols ($<>_. / ). Operands can start with any number, letter, or special symbol, and the subsequent content can be any combination of numbers, letters, and special symbols.

[0046] Figure 5 To express the grammatical rules of each statement in the VVP file through the railway diagram, a statement can consist of only one Label; or it can consist of Opcode, Label, and Operand. A comment can be added after each statement ";".

[0047] Figure 6 The syntax rules for forming a head statement are expressed through a railway diagram. The head statement starts with a ":" (colon) and can be composed of only letters (Aa~Zz); or it can be composed of digits, letters, and special symbols. A comment can be added after each statement ";".

[0048] Through the railway diagram of the above grammatical rules, the visualization operation of grammar is realized, which is more convenient for users to understand.

[0049] After obtaining the above-mentioned VVP file recognition rules, the sentences of the VVP file are parsed according to these recognition rules, and then the fields recognized by the parsing are annotated with corresponding category tags according to their categories and stored as indexes. In this embodiment, the index is stored in the form of key-value pairs, and the category tags may include: Header, Label, Opcode, Operand, Comment, Filename. The representation form after index storage can be as follows: Figure 8 As shown, Figure 8 What is displayed is the output result of a VVP statement after analysis, where type is the category label and string is the specific content.

[0050] In the specific implementation, taking Python language as an example, by designing a Parser class and a corresponding Token class, the Parser class completes the lexical analysis function and the formatted output of each Token, that is, the separated Tokens are made in the Parser class, and then the Token value is returned, so that the returned Token value can form an index. The following is an explanation of the writing of the Parser class and the Token class, in which the function completed by the Parser class is to read the input text and perform syntax analysis.

[0051] After obtaining the index that can understand the content of the VVP file, the statements of the VVP file are read according to the index, and all the logic gates in the VVP file and the driving and driven relationships between the logic gates are found and output.

[0052] The specific implementation includes the following steps:

[0053] Step 3.1, find a statement containing a logic gate according to the index, use the statement as the current statement, and use the logic gate as the current logic gate;

[0054] Step 3.2, find the input information of the current logic gate in the current statement;

[0055] Step 3.3, search for the output information of the current logic gate in other statements other than the current statement;

[0056] Step 3.4, check the module where the current statement is located;

[0057] Step 3.5, organize the contents found in steps 3.2 to 3.4 to form the logic unit of the current logic gate and output it to the Json file, return to step 3.1 to read the next statement of the VVP file until the logic units of all logic gates are output.

[0058] The above steps find the driving and driven relationships between all logic gates through two iterative cycles. In specific implementation, a logic unit formed by finding the driving and driven relationships between a logic gate and other logic gates is taken as an example. When a statement with the category label Opcode and the field content .functor is found, it is treated as a statement containing a logic gate, and the statement is the current statement. The logic gate pointed to by .functor is the current logic gate. The label of the current logic gate is read and then output to the Json file in the preset format; the first Operand of the current statement is read, and the content before the space in the Operand is output as the functor type of the current logic gate in the preset format, and then the content after the space in the first Operand is output as the corresponding input bit width in the preset format; the second Operand of the current statement is read until the semicolon as the input of the current logic gate and output to the Json file in the preset format; the label of the current logic gate is searched in the Operand list of other statements containing .functor. If it matches, the matched logic gate is used as the driven logic gate, and the label of the driven logic gate is taken out and output to the driver list of the current logic gate in the Json file; the module where the current statement is located is checked and output to the Json file in the preset format.

[0059] Figure 7 After the analysis of the present invention, the detailed information of each logic gate with logical relationship and the corresponding module are finally output. Figure 7 The output results will be more helpful for users to understand VVP files and help improve R&D efficiency.

[0060] The present invention also protects a corresponding computer-readable storage medium, which is used to store a computer program, and when the computer program is run, the above-mentioned VVP file preprocessing method is executed.

[0061] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A pre-analysis method for a VVP file, characterized in that: include: Step 1, parse the official document of the VVP file to generate the identification rules of the VVP file; Step 2, perform grammatical analysis on the statements of the VVP file according to the identification rules, annotate the fields identified by the grammatical analysis with corresponding category labels according to their categories and store them as indexes; Step 3, reading the statements of the VVP file according to the index, finding all the logic gates of the VVP file and the driving and driven relationships between the logic gates and outputting them; The step 3 comprises: Step 3.1, find a statement containing a logic gate according to the index, use the statement as the current statement, and use the logic gate as the current logic gate; Step 3.2, find the input information of the current logic gate in the current statement; Step 3.3, search for the output information of the current logic gate in other statements other than the current statement; Step 3.4, check the module where the current statement is located; Step 3.5, organize the contents found in steps 3.2 to 3.4 to form the logic unit of the current logic gate and output it to the Json file, return to step 3.1 to read the next statement of the VVP file until the logic units of all logic gates are output.

2. The pre-analysis method of a VVP file according to claim 1, characterized in that: The parsing of the official document of the VVP file in step 1 specifically involves dividing the VVP file into an executor path, a header statement, multiple modules, and a file list.

3. The pre-analysis method of a VVP file according to claim 1, characterized in that: The category tags include: Header, Label, Opcode, Operand, Comment, and Filename.

4. The pre-analysis method of a VVP file according to claim 3, characterized in that: In step 3.5, the contents found in steps 3.2 to 3.4 are sorted to form a logic unit of the current logic gate and output, specifically including: When a statement with the category label Opcode and the content of the field .functor is found, it is regarded as a statement containing a logic gate, and the statement is the current statement, and the logic gate pointed to by .functor is the current logic gate; Read the label of the current logic gate and output it to a Json file in the preset format; Read the first Operand of the current statement, output the functor type of the current logic gate in the content before the space in the Operand according to the preset format, and then output the content after the space in the first Operand as the corresponding input bit width in the preset format; Read the second Operand of the current statement until the semicolon as the input of the current logic gate and output it to the Json file in the preset format; Search the label of the current logic gate in the Operand list of other statements containing .functor. If it matches, the matched logic gate is used as the driven logic gate. The label of the driven logic gate is taken out and output to the driver list of the current logic gate in the Json file. Check the module where the current statement is located and output it to a Json file in the preset format.

5. The pre-analysis method of a VVP file according to claim 1, characterized in that: The index specifically stores the identified fields and their corresponding category labels via key-value pairs.

6. The pre-analysis method of a VVP file according to claim 1, characterized in that: The identification rules include: grammatical rules constituting Label, grammatical rules constituting Opcode, grammatical rules constituting Operand, grammatical rules constituting each sentence in the VVP file, and grammatical rules constituting the header sentence.

7. The pre-analysis method of a VVP file according to claim 1, characterized in that: The identification rules are respectively represented by railway diagrams.

8. A computer-readable storage medium for storing a computer program, characterized in that: When the computer program is executed by at least one processor, the VVP file pre-analysis method according to any one of claims 1 to 5 is executed.

Citation Information

Patent Citations

  • Implementation method and device of intelligent operation, and computer readable storage medium

    CN109841210A