A finite state machine coverage statistics method for VCD files

By processing VCD files through hash table mapping and custom hash algorithm, the problems of slow parsing speed and high memory usage in the existing technology are solved, fast and effective finite state machine coverage statistics are achieved, and the efficiency of integrated circuit design verification is improved.

CN119473872BActive Publication Date: 2025-09-19GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411411033.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-09-19
Estimated Expiration
2044-10-10

AI Technical Summary

Technical Problem

When processing VCD files, the existing technology has the problems of processing a lot of irrelevant information, slow parsing speed, high memory usage and inability to effectively analyze the coverage of finite state machines.

Method used

Hash table mapping technology is used to process YAML format files. A custom hash algorithm and strategic file reading method are combined to directly parse signal names and state transition information. Hash table matching with O(1) time complexity is used to achieve fast coverage statistics.

Benefits of technology

It significantly improves the speed of finite state machine coverage statistics and verification process efficiency, reduces resource consumption, and improves the performance of the integrated circuit design verification stage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473872B_ABST
    Figure CN119473872B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for statistically analyzing the finite state machine coverage of a VCD file. By directly parsing a YAML format file containing a finite number of states and transition behaviors between states compiled during the design phase, a hash table mapping technique is used to establish a mapping relationship between signal names and state transition information, thereby achieving a constant-level efficiency of O(1) with a time complexity reduced to O(1). When processing the VCD file generated by simulation, two strategic file reading methods are adopted to simplify the file processing process. A custom hash algorithm is used to ensure the uniqueness and accuracy of data processing. In the processing of simulation data, data is filtered based on the regularity of the first character, and only the key state transition information is retained. The present invention can effectively overcome the shortcomings of the existing technology in processing VCD files and statistically analyzing finite state machine coverage under resource-constrained conditions. It not only accelerates the statistical speed of finite state machine coverage, but also improves the efficiency of the verification process, bringing significant performance improvements to the verification stage of integrated circuit design.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computers, and in particular to a finite state machine coverage statistics method for VCD files. Background Art

[0002] VCD (Value Change Dump), part of the IEEE 1364 standard (Verilog Hardware Description Language), is an ASCII-encoded file format that records signal changes during simulation in detail. These records make it possible to track signal value changes during simulation, thereby accurately analyzing whether the states and transitions of the finite state machine (FSM) are adequately covered by tests. However, existing research indicates that traditional VCD file processing techniques primarily rely on sequential reading methods, that is, reading from the beginning to the end of the file. This method not only processes a large amount of irrelevant information, but also, due to the use of a common information storage structure, results in slow parsing speed and high memory usage. More importantly, these methods fail to provide effective analysis and statistics of the finite state machine coverage. Summary of the Invention

[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a finite state machine coverage statistics method for VCD files.

[0004] To achieve the above objectives, the technical solutions provided by the present invention are:

[0005] A finite state machine coverage statistics method for a VCD file, comprising:

[0006] Read the YAML format file of the finite states and transition behaviors between states written in the design phase to obtain the state transition information of the signal;

[0007] Read the VCD file generated after simulation to obtain the state transition information generated by the simulation under the stimulus condition;

[0008] Calculate the coverage of the finite state machine of the specified signal in the VCD file and output it to the file in the specified format.

[0009] Furthermore, the YAML format file of the finite states and transition behaviors between states written in the design phase is read to obtain the state transition information of the signal, including:

[0010] Open a YAML file that records a limited number of states and the transition behavior between states;

[0011] Read the YAML file word by word, set the enumeration type as an environment variable and name it Title, and assign a value to the environment variable Title based on the read word;

[0012] Extract information based on the environment variable Title and store the extracted information in an unordered hash table object of type std::unordered_map, using the signal name as the mapping location;

[0013] After reading the YAML format file, an unordered hash table object of type std::unordered_map is returned.

[0014] Furthermore, in the process of reading the YAML format file, the string type representing the state transfer is converted into a long integer (long long type) through string processing to reduce the memory used in the calculation process.

[0015] Furthermore, when reading a YAML format file, the std::unordered_map::size() method is used to determine the total number of signals to be processed; the determined total number of signals to be processed will serve as a benchmark for subsequent loops; in each iteration of the loop, the std::unordered_map::size() method will be called again for each signal to retrieve the total number of state transitions associated with a specific signal name, so that each signal defined in the YAML format file and its corresponding number of state transitions can be accurately processed.

[0016] Furthermore, the VCD file generated after the simulation is read to obtain the state transition information generated by the simulation of the signal under the stimulus condition, including:

[0017] Open the VCD file and read the signal variable definition part in the VCD file word by word.

[0018] Among them, the conditional statement is used to process the word content information, record the identifier corresponding to the specified information and calculate the hash value of the custom hash function for this signal identifier, and store it in a vector type object;

[0019] Next, the simulation information part of the VCD file is read line by line. The switch method is used to process the first character of each line of string to record the new state of the specified signal at the simulation time and the corresponding old state.

[0020] After reading the VCD file, return the vertor container including the required signals and corresponding state transitions, and close the VCD file.

[0021] Furthermore, calculating the hash value of the signal identifier using the custom hash function includes:

[0022] Receive the string to be hashed, create an integer variable named len, calculate the length of the string using the std::string.length() function and assign it to the variable len;

[0023] Iterate over each character in the string, subtract 33 from the ASCII code value of each character and multiply the result by 94 to the power of i, where i is the position of the character in the string, and accumulate the result to get the hash value;

[0024] Convert the calculation method of multiplying by 94 to the power of n into a shift calculation. The shift calculation consumes much less time than calling the pow power function in C++.

[0025] Returns the result of calculating the current identifier string using a custom hash function;

[0026] The calculation formula is:

[0027]

[0028] Among them, n is the length of the string, i is the position of the current character in the string (from right to left), ASCII (X i ) is the ASCII code corresponding to the i-th character.

[0029] Furthermore, the coverage of the finite state machine of the specified signal in the VCD file is calculated, including:

[0030] Use the std::unordered_map::size() method to process the unordered hash table variable returned by reading the YAML format file to determine the total number of signals to be processed;

[0031] For each signal, call the std::unordered_map::size() method to retrieve the total number of state transitions associated with the specific signal name;

[0032] Using the total number of state transitions associated with each signal name as the small loop benchmark, traverse and match whether the transition between the old state and the new state of the current signal during the simulation corresponds to the specified state transition. If the match is successful, the total number of coverage variables is increased by one;

[0033] The finite state machine coverage of the current signal is calculated using the coverage calculation formula.

[0034] Furthermore, the finite state machine coverage calculation formula is:

[0035]

[0036] Compared with the existing technology, the principles and advantages of this technical solution are as follows:

[0037] By directly parsing the YAML format file that records finite states and their transition behaviors, a mapping relationship between signal names and state transition information is established using hash table mapping technology, achieving constant-level efficiency with time complexity reduced to O(1).

[0038] When processing the VCD files generated by simulation, two strategic file reading methods are adopted, targeting the variable definition and simulation data parts respectively, which simplifies the file processing process.

[0039] In order to solve the hash table conflict problem of identifiers in VCD files, a custom hash algorithm is used to ensure the uniqueness and accuracy of data processing.

[0040] In the processing of simulation data, we filter the data according to the specific rules of the first character, and only retain the key state transition information. At the same time, when storing this information, we use a custom hash function to quickly locate the target container position, further reducing the time complexity to O(1).

[0041] During the calculation phase of the finite state machine coverage, a hash algorithm is applied to efficiently match the predetermined state transitions, reducing the time complexity of the matching process to O(1).

[0042] This technical solution can effectively overcome the shortcomings of existing technologies in processing VCD files and counting finite state machine coverage under resource-constrained conditions. It not only speeds up the statistical speed of finite state machine coverage, but also improves the efficiency of the verification process, bringing significant performance improvements to the verification stage of integrated circuit design. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the services required for use in the embodiments or the prior art descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0044] Figure 1 A flow chart showing the principle of a finite state machine coverage statistics method for a VCD file according to the present invention;

[0045] Figure 2 A flowchart showing the principle of reading a YAML file that records a finite number of states and transition behaviors between states in a finite state machine coverage statistics method for a VCD file of the present invention to obtain state transition information of a signal;

[0046] Figure 3A flow chart showing the principle of reading a VCD file generated after simulation in a finite state machine coverage statistics method of a VCD file according to the present invention to obtain state transition information generated by simulation of a signal under excitation conditions;

[0047] Figure 4 A flow chart showing the principle of calculating the hash value of a custom hash function for a signal identifier in a finite state machine coverage statistics method for a VCD file according to the present invention;

[0048] Figure 5 A flow chart showing the principle of calculating the coverage of a finite state machine of a specified signal in a VCD file in a finite state machine coverage statistics method of a VCD file according to the present invention;

[0049] Figure 6 A YAML format file content diagram of a finite number of states and transition behaviors between states written in the design phase of a finite state machine coverage statistics method for a VCD file of the present invention;

[0050] Figure 7 This is a VCD file content diagram generated after simulation in a finite state machine coverage statistics method for a VCD file of the present invention. DETAILED DESCRIPTION

[0051] The present invention will be further described below in conjunction with specific embodiments:

[0052] like Figure 1 As shown, the finite state machine coverage statistics method of a VCD file described in this embodiment includes the following steps:

[0053] S1. Read the YAML format file of the finite states and transition behaviors between states written in the design phase to obtain the state transition information of the signal;

[0054] like Figure 2 As shown, the specific process of this step is as follows:

[0055] S1-1. Open the YAML file. If the opening fails, an error message is output and the program exits. If the opening succeeds, an enumeration type variable is created and named Title.

[0056] S1-2. Read the YAML file word by word. The reading results are as follows: "FSM:", "LINKS:", "MODULE:", "STATES:", and "TRANSITIONS:". The Title is assigned a corresponding value, indicating that the corresponding character is read.

[0057] S1-3. Extract information according to the environment variable Title. If "FSM:" is read, the Title is 0. Read the next word and record the current word as the signal name. Then access it to the std::unordered_map type and name it the fsmsignalmap unordered hash table object. Use the signal name as the mapping position and assign the signal name string to its string type member and name it signal_name. If "MODULE:" is read, the Title is assigned to 1. Read the next word. The current word is the name of the module to which the signal belongs. Then record the current string in the string type member module_name of the unordered hash table object fsmsignalmap. If "STATES:" is read, the Title is assigned to 2. Read the next word. The current string is the state name. Extract the state through string processing. Access the state name through a temporary variable and continue to read the next word. The string is the decimal number corresponding to the state name and is converted into a long integer long through string processing. The long type is mainly used to reduce the memory usage during the calculation process. The two are accessed in the secondary unordered hash table of states_map in the fsmsignalmap unordered hash table object, which is mapped by the signal name. There are usually multiple consecutive lines of state names and their corresponding decimal numbers. Continue to read the next word. Since the Title has not changed, it will continue to read until the Title changes. If "TRANSITIONS:" is read, the Title is assigned a value of 3. Read the next word. The current string is the state migration. The old and new state names are extracted through string processing. The state name is mapped through the previously accessed states_map secondary unordered hash table to find the decimal number corresponding to the state name, and access it in the transitions_map secondary unordered hash table mapped by the signal name in the fsmsignalmap unordered hash table object. There are usually multiple consecutive lines of state migration. Continue to read the next word. Since the Title has not changed, it will continue to read until the Title changes.

[0058] S1-4, continue to read the YAML format file until the end, and use

[0059] The std::unordered_map::size() method is used to determine the total number of signals to be processed. This number serves as a baseline for subsequent loops. In each iteration of the loop, the std::unordered_map::size() method is called again for each signal to retrieve the total number of state transitions associated with that particular signal name. This allows for accurate processing of each signal and its corresponding state transitions defined in the YAML file.

[0060] S2. Read the VCD file generated after the simulation to obtain the state transition information generated by the simulation of the signal under the stimulus condition;

[0061] like Figure 3 As shown, the specific process of this step is as follows:

[0062] S2-1. Open the VCD file and read it word by word. There are five situations that need to be processed for the string content: "$var", "$scope", "$upscope", "$enddefinitions", and "$timescale".

[0063] S2-2. Use the if statement to process according to the word content information. When the string is "$var", continue to read the next word. If the next word is one of "wire", "reg", or "integer", continue to read the next word. The current string represents the bit width of the current signal state. Continue to read the next word. The current string represents the identifier corresponding to the current signal, which is stored in the string type of the structure, named identifier variable. Continue to read the next word. The current string represents the name corresponding to the current signal. Then read the next word. If it is "$end", it means that the bit width of the current signal state starts from bit 0 by default. If not, the string represents the bit width range of the current signal state. Using the read signal name as an index, the std::unordered_map::count() function is used to check whether the corresponding signal exists in the fsmsignalmap unordered hash table object that stores the signal's state transition information. If not, the loop exits and enters the next loop. If so, the custom hash calculation method, computer_hash(), is used to calculate the hash value corresponding to the read signal identifier. This hash value is stored as the index in the corresponding base position of the std::vector container named vcdinfo. The bool successread object in the vcdinfo structure object is set to true (the default state is false). If the string is "$scope", the next word is read. If the next word is one of "module", "begin", or "function", the two words are read. If the current string is "$end", the loop exits and continues to the next loop. If the string is "$upscope", the next word is read. If the current string is "$end", the loop exits and continues to the next loop. When the string is "$timescale", extract the time unit and continue to read the next word. When the current string is judged to be "$end", jump out of the current loop and continue to the next loop. When the string is "$enddefinitions", continue to read the next word. When the current string is judged to be "$end", it marks the end of the VCD variable definition part and ends the entire loop.

[0064] S2-3. After processing the variable definition part of the VCD file, the simulation information part of the VCD file is processed next, and the information is read line by line. For the first character of each line of string, there are five situations that need to be processed: "#", "b", "1", "0", "x", and "z". Use the switch statement to process them. The specific processing process is that when the first character of the string is "#", the current string contains time information, and the time information is obtained after string processing. When the first character of the string is "b", the current string is a multi-bit width signal status value. The string contains the identifier, status value, and bit width information corresponding to the signal. First, extract the identifier, use the computer_hash() function to calculate the hash value corresponding to the identifier, and then use the hash value as an index to find whether the successread of the corresponding position of the vector type vcdinfo container is true. If so, it means that the signal is the signal that needs to be recorded. The status information string is extracted through string processing, and the string is converted to a decimal number in combination with the bit width read in the variable definition part. The decimal number corresponding to the current status value is recorded, the current switch ends and the next line is read. If not, jump out of the current switch and continue to read the next line. When the first character in the string is "1", the current string is a unit-width signal state value with a state value of 1. The string contains the identifier and state value corresponding to the signal. First, extract the identifier, use the computer_hash() function to calculate the hash value corresponding to the read signal identifier, then use the hash value as an index to find whether successread is true in the corresponding position of the vector type vcdinfo container. If so, it means that the signal is the signal that needs to be recorded. The decimal number corresponding to the current state value is recorded, the current switch ends, and the next line is read. If not, jump out of the current switch and continue reading the next line. When the first character in the string is "0", the current string is a unit-width signal state value with a state value of 0. The same operation is performed here as for "1", except that the state value is 0. When the first character in the string is "x" or "z", the current string is a unit-width signal state value set to -1. The same operation is performed here as for "1", except that the state value is -1. In other cases, skip the current switch and continue reading the next line. When the reading is completed, the variable simulation part is extracted, the VCD file is closed, and the vector type vcdinfo container is returned.

[0065] In step S2-2 and step S2-3, if Figure 4 As shown, the hash value of the custom hash function of the signal identifier is calculated, specifically including:

[0066] Receive the string to be hashed, create an integer variable named len, calculate the length of the string using the std::string.length() function and assign it to the variable len;

[0067] Iterate over each character in the string, subtract 33 from the ASCII code value of each character and multiply the result by 94 to the power of i, where i is the position of the character in the string, and accumulate the result to get the hash value;

[0068] Convert the calculation method of multiplying by 94 to the power of n into a shift calculation. The shift calculation consumes much less time than calling the pow power function in C++.

[0069] Returns the result of calculating the current identifier string using a custom hash function. The data type is int.

[0070] The calculation formula is:

[0071]

[0072] Among them, n is the length of the string, i is the position of the current character in the string, ASCII (X i ) is the ASCII code corresponding to the i-th character.

[0073] S3. Calculate the coverage of the finite state machine of the specified signal in the VCD file.

[0074] like Figure 5 As shown, the specific process includes:

[0075] S3-1. Use the std::unordered_map::size() method to process the unordered hash table variable fsmsignalmap returned by reading the YAML format file to determine the total number of signals to be processed. The total number of signals is specified as an int integer variable named signalnum, which will serve as the benchmark for subsequent loops. In each iteration of the loop, the std::unordered_map::size() method is called again for each signal to retrieve the total number of state transitions associated with the specific signal name, which is recorded as an int type variable named statesnum. This allows accurate processing of each signal defined in the YAML format file and the corresponding number of state transitions.

[0076] S3-2. The number of the specified total number of signals signalnum will be used as the benchmark of the large loop. The hash value of the signal corresponding identifier is calculated by using the custom computer_hash() hash function as the base mark of the vector type vcdinfo container returned by querying the VCD file. The total number of state transitions associated with the signal name, the variable statesnum, is used as the benchmark of the small loop. The transition between the old state and the new state of the current signal during the simulation process corresponds to the specified state transition. If the match is successful, the total number variable is overwritten and increased by one, which is recorded as the int type variable success.

[0077] S3-3. Using the total number of signals (signalnum) as the benchmark for the macroloop, calculate the finite state machine coverage of the current signal using the coverage calculation formula and output it to a file in the specified format. The output format is "module name.signal name," "total number of current signal coverage," "number of specified state transitions for the current signal," and "coverage (to two decimal places)."

[0078] The coverage calculation formula is:

[0079]

[0080] The embodiments described above are only preferred embodiments of the present invention and are not intended to limit the scope of implementation of the present invention. Therefore, any changes made based on the shape and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A finite state machine coverage statistics method for VCD files, characterized in that ,include: Read the YAML format file of the finite states and transition behaviors between states written in the design phase to obtain the state transition information of the signal; Read the VCD file generated after simulation to obtain the state transition information generated by the simulation under the stimulus condition; Calculate the coverage of the finite state machine of the specified signal in the VCD file and output it to the file in the specified form; Read the YAML format file of the finite states and transition behaviors between states written in the design phase to obtain the state transition information of the signal, including: Open a YAML file that records a limited number of states and the transition behavior between states; Read the YAML file word by word, set the enumeration type as an environment variable and name it Title, and assign a value to the environment variable Title based on the read word; Extract information based on the environment variable Title and store the extracted information in an unordered hash table object of type std::unordered_map, using the signal name as the mapping location; After reading the YAML format file, an unordered hash table object of type std::unordered_map is returned; Read the VCD file generated after simulation to obtain the state transition information generated by the simulation under the stimulus conditions, including: Open the VCD file and read the signal variable definition part in the VCD file word by word. Among them, the conditional statement is used to process the word content information, record the identifier corresponding to the specified information and calculate the hash value of the custom hash function for this signal identifier, and store it in a vector type object; Next, the simulation information part of the VCD file is read line by line. The switch method is used to process the first character of each line of string to record the new state of the specified signal at the simulation time and the corresponding old state. After reading the VCD file, return the vertor container including the required signals and corresponding state transitions, and close the VCD file; Calculate the hash value of the signal identifier using the custom hash function, including: Receive the string to be hashed, create an integer variable named len, calculate the length of the string using the std::string.length() function and assign it to the variable len; Iterate over each character in the string, subtract 33 from the ASCII code value of each character and multiply the result by 94 to the power of i, where i is the position of the character in the string, and accumulate the result to get the hash value; Convert the calculation method of multiplying by 94 to the power of i into a shift calculation. The shift calculation consumes much less time than calling the pow power function in C++. Returns the result of calculating the current identifier string using a custom hash function; The calculation formula is: Among them, n is the length of the string, i is the position of the current character in the string, ASCII (X i ) is the ASCII code corresponding to the i-th character.

2. The finite state machine coverage statistics method for a VCD file according to claim 1, characterized in that: When reading a YAML file, the string type representing the state transition is converted into a long integer through string processing.

3. The finite state machine coverage statistics method for a VCD file according to any one of claims 1-2, characterized in that: When reading a YAML file, the std::unordered_map::size() method is used to determine the total number of signals to be processed. The total number of signals to be processed will be used as a benchmark for subsequent loops. In each iteration of the loop, for each signal, the std::unordered_map::size() method to retrieve the total number of state transitions associated with a particular signal name.

4. The finite state machine coverage statistics method for a VCD file according to claim 1, characterized in that: Calculates the coverage of the finite state machine of the specified signal in the VCD file, including: Use the std::unordered_map::size() method to process the unordered hash table object returned by reading the YAML file to determine the total number of signals to be processed; For each signal, call the std::unordered_map::size() method to retrieve the total number of state transitions associated with the specific signal name; Using the total number of state transitions associated with each signal name as the small loop benchmark, traverse and match whether the transition between the old state and the new state of the current signal during the simulation corresponds to the specified state transition. If the match is successful, the total number of coverage variables is increased by one; The finite state machine coverage of the current signal is calculated using the coverage calculation formula.

5. The finite state machine coverage statistics method for a VCD file according to claim 4, characterized in that: The formula for calculating the finite state machine coverage is:

Citation Information

Patent Citations

  • VCD file analysis method based on perfect hash structure and post-processing logic

    CN117272976A

  • FSM state transition coverage rate calculation method and system based on bucket sorting

    CN118228648A