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

CN118228648BActive Publication Date: 2024-11-15NANJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410351293.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-26
Publication Date
2024-11-15
Estimated Expiration
2044-03-26

AI Technical Summary

Technical Problem

[0005]本发明正是针对现有FSM覆盖率统计算法底层效率不足的问题,提供一种基于桶排序的FSM状态转移覆盖率计算方法及系统,首先根据FSM模型,创建用于存储FSM状态转移信息的数组,以确保状态转移信息的唯一性;再通过解析VCD文件,追踪状态变量的变化,判断是否发生状态转移,当发生状态转移时,利用该状态转移信息将对应的数组元素值从0置为1,将所有提取到的状态转移信息存储到同一个数组中;遍历数组的所有元素并累加数组元素的值,得到产生的状态转移总数或多文件合并状态转移总数,将其除以状态转移总数,计算得到FSM状态转移覆盖率或多文件合并覆盖率

Benefits of technology

[0018] (1) The present invention proposes a bucket sorting-based FSM state transfer coverage calculation method, which attributes the state transfer analysis process to an array element access process (indexing process) with a time complexity of 0(1). The overall theoretical implementation time The coverage calculation with complexity 0(n) improves the calculation speed of ultra-large-scale FSM state transfer coverage and the speed of multi-file merge coverage calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118228648B_ABST
    Figure CN118228648B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for calculating the coverage of FSM state transition based on bucket sorting. First, according to the FSM model, an array for storing FSM state transition information is created to ensure the uniqueness of the state transition information; then, by parsing the VCD file, the change of the state variable is tracked to determine whether the state transition occurs. When the state transition occurs, the corresponding array element value is set from 0 to 1 using the state transition information, and all the extracted state transition information is stored in the same array; all elements of the array are traversed and the values ​​of the array elements are accumulated to obtain the total number of state transitions generated or the total number of state transitions merged by multiple files, which is divided by the total number of state transitions to calculate the FSM state transition coverage or the multi-file merge coverage. The method of the present invention realizes efficient statistics of ultra-large-scale FSM state transition coverage, and can effectively improve verification efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of integrated circuit EDA (Electronics Design Automation), and in particular to the technical field of EDA verification, and mainly relates to a method and system for calculating FSM state transition coverage based on bucket sorting. Background Art

[0002] Finite state machine (FSM) coverage statistics is an important technique in digital circuit verification, which is used to evaluate the coverage of the designed finite state machine by the test suite. A finite state machine is an abstract mathematical model used to describe the behavior of a system in different states and the transition relationship between states. In digital circuit design, finite state machines are often used to control and coordinate various parts of the system, so it is very important to test and cover them comprehensively.

[0003] At present, digital circuit designs are usually written in hardware description languages ​​such as Verilog or VHDL, and functional verification is performed using simulation tools such as ModelSim, VCS, etc. These simulation tools can generate waveform files, usually in VCD format, to record changes in signals during simulation, including state transitions of finite state machines. In order to evaluate the coverage of the test suite for the finite state machine, it is usually necessary to use a dedicated coverage analysis tool. These tools can parse the waveform data in the VCD file, identify the state transitions of the finite state machine, and calculate the coverage of the state transitions by the test suite. In order to improve the coverage of the finite state machine, automatic test generation tools can be used to generate test cases for specific state transitions. These tools can automatically generate new test cases based on the results of coverage statistics to fill the coverage gaps in the test suite.

[0004] The development of finite state machine coverage statistics technology enables engineers to better evaluate test quality and coverage, thereby improving the reliability and stability of digital circuit design. However, the current coverage statistics algorithm is insufficient at the bottom level, and for complex finite state machine models, the number of state transition combinations may increase exponentially. For example, when simulating and verifying ultra-large-scale digital circuits, using existing coverage statistics algorithms will consume a lot of time and resources, slowing down verification efficiency. Summary of the invention

[0005] The present invention is aimed at the problem of insufficient underlying efficiency of the existing FSM coverage statistics algorithm, and provides a FSM state transition coverage calculation method and system based on bucket sorting. First, according to the FSM model, an array for storing FSM state transition information is created to ensure the uniqueness of the state transition information; then, by parsing the VCD file, the changes in the state variables are tracked to determine whether a state transition occurs. When a state transition occurs, the corresponding array element value is set from 0 to 1 using the state transition information, and all extracted state transition information is stored in the same array; all elements of the array are traversed and the values ​​of the array elements are accumulated to obtain the total number of state transitions generated or the total number of state transitions merged from multiple files, which is divided by the total number of state transitions to calculate the FSM state transition coverage or the merged coverage of multiple files. The present invention innovates the coverage calculation method from the bottom layer, realizes efficient statistics of ultra-large-scale FSM state transition coverage, and can effectively improve verification efficiency.

[0006] In order to achieve the above object, the technical solution adopted by the present invention is: a method for calculating the FSM state transition coverage based on bucket sorting, comprising the following steps:

[0007] S1, create an array: according to the FSM model, create an array for storing FSM state transition information, wherein the length of the array is based on the number of states and the number of bits in the FSM model to ensure the uniqueness of the state transition information;

[0008] S2, state transfer judgment: by parsing the VCD file, tracking the changes of state variables, judging whether state transfer occurs, if state transfer does not occur, repeat this step until state transfer occurs, and enter step S3;

[0009] S3, storing state transition information: when a state transition occurs, the corresponding array element value is set from 0 to 1 using the state transition information, and all extracted state transition information is stored in the same array;

[0010] S4, coverage calculation: using the array of all stored state transition information obtained in step S3, calculate the FSM state transition coverage or the multi-file merged state transition coverage.

[0011] As an improvement of the present invention, the FSM state transfer information stored in the array in step S1 is specifically as follows: according to the FSM model, all possible states are listed and numbered as 0, 1, 2, 3...N-1, and the number combination of the states before and after the state transfer is represented as a unique integer; if the number of digits of the total number of states is greater than the number of state digits, zeros are padded on the left before the number combination.

[0012] As an improvement of the present invention, the total length of the array in step S1 is N*10 m , where m is the number of state bits and N is the total number of states.

[0013] As another improvement of the present invention, the method for judging the state transfer in step S2 is specifically: starting from the initial assignment of the variable at time zero, the value of the state variable at each timestamp is recorded, and compared with the previous value. If a change occurs, a state transfer is recorded, otherwise continue with the next comparison.

[0014] As another improvement of the present invention, the method for recording state transition in step S3 is specifically as follows: the two numbers corresponding to the state transition are padded with zeros on the left according to the total number of digits m of the state, and then the two are connected to obtain a 2m-digit number for uniquely identifying this type of state transition; this number is used as the index of the corresponding array, the corresponding array value is set from 0 to 1, and all extracted state transition information is stored in the same array.

[0015] As another improvement of the present invention, step S4 is specifically: traversing all elements of the array and accumulating the values ​​of the array elements to obtain the total number of state transitions generated or the total number of multi-file merged state transitions, dividing it by the total number of state transitions to obtain the FSM state transition coverage or the multi-file merge coverage.

[0016] In order to achieve the above purpose, the present invention also adopts a technical solution: a FSM state transition coverage calculation system based on bucket sorting, including a computer program, which implements the steps of any of the above methods when executed by a processor.

[0017] Compared with the prior art, the present invention has the following beneficial effects:

[0018] (1) The present invention proposes a method for calculating the coverage of FSM state transitions based on bucket sorting, which reduces the state transition analysis process to an array element access process (indexing process) with a time complexity of 0(1), and theoretically achieves coverage calculation with a time complexity of 0(n), thereby improving the speed of calculating the coverage of ultra-large-scale FSM state transitions and the speed of calculating the coverage of multiple file merges.

[0019] (2) The present invention uses the value of an array element to represent whether a state transition occurs. 0 is the initial value, representing that it does not occur, and setting it to 1 represents that a state transition occurs. Simultaneously setting the same array element from 0 to 1 under multi-threading will not cause synchronization problems. Therefore, there is no need to introduce a mutex lock to maintain synchronization, which can improve the efficiency of large-scale FSM coverage calculation under multi-core and multi-threading. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flowchart of the steps of the FSM state transition coverage calculation method based on bucket sorting of the present invention;

[0021] Figure 2is a schematic diagram of the state transition occurring in step S2 of embodiment 2 of the present invention;

[0022] Figure 3 It is a schematic diagram of recording the state transition information occurring in step S3 of embodiment 2 of the present invention into a bucket. DETAILED DESCRIPTION

[0023] The present invention will be further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.

[0024] Example 1

[0025] The FSM state transition coverage calculation method based on bucket sorting, such as Figure 1 As shown, the following steps are included:

[0026] Step S1: Design an array (bucket) of appropriate size, which is used to store the relevant information of FSM state transition. The length of the array is set based on the number of states and bits in the FSM model to ensure the uniqueness of the state transition information.

[0027] According to the state machine model, all states are listed and numbered as continuous natural numbers such as 0, 1, 2, 3, etc. The state transition can be represented by connecting two numbers. Suppose the number of states is N, which is m digits, then the total number of buckets needs to be N*10 m That is, the array length is N*10 m .

[0028] Step S2: By parsing the VCD file, etc., the changes of the state variables are tracked to determine whether a state transfer occurs.

[0029] The method to determine whether a state variable has undergone a state transition is: starting from the initial assignment of the variable at time zero, record the value of the state variable at each timestamp and compare it with the previous time. If it changes, a state transition is recorded, otherwise continue with the next comparison.

[0030] Step S3: Once a state transition occurs, use the state transition information to index the corresponding bucket and set its value from 0 to 1, and so on.

[0031] The two numbers corresponding to the generated state transition are padded with zeros on the left according to the total number of digits m of the state, and then the two are concatenated to obtain a 2m-digit number to uniquely identify this type of state transition. Use this number as the index of the corresponding array (bucket), set the corresponding array value from 0 to 1, and mark the occurrence of this type of state transition. When calculating the combined coverage of multiple files, store all the extracted state transition information in the same array.

[0032] Step S4: Using the information stored in all buckets, calculate the coverage or the combined coverage of multiple files.

[0033] By traversing all elements of the array and accumulating the values ​​of the array elements, the total number of state transitions generated or the total number of state transitions merged from multiple files can be obtained. In step S1, the total number of all possible state transitions has been obtained based on the state machine model. The two are divided to finally calculate the FSM state transition coverage or the multi-file merge coverage.

[0034] Example 2

[0035] The FSM state transition coverage calculation method based on bucket sorting includes four steps:

[0036] Step S1: According to the state machine model, all possible states and possible state transitions are listed.

[0037] Assume that there are N states and x state transitions. Each state is numbered as N consecutive natural numbers such as 0, 1, 2, 3...N-2, N-1. In this case, each state of the state machine is represented by an integer. Connect the numbers corresponding to the states before and after the state transition to obtain a number string that uniquely identifies this state transition. Assume that the total number of states N is m digits. In order to ensure the uniqueness of the number string, 0 needs to be added in front of the number representing the state to ensure that it is m digits. In this case, the length of the number string is 2m. For example Figure 2 As shown, a state transition from 20->23 occurs, and the total number of states is 50. Then the number string 2023 can represent this type of state transition. If the total number of states is a three-digit number 500, then it should be represented as 020023.

[0038] In order to store all state transition information, memory space needs to be allocated for the bucket. Considering the maximum value S of the string representing the state transition max for:

[0039] S max =(N-1)*(10 m +1)

[0040] So the total number of buckets is set to N*10 m The corresponding array A subscript starts from 0 to N*10 m In addition, since array A only needs to store 0 or 1, setting it to bool type can save memory space.

[0041] Step S2: The information of state changes is stored in files such as VCD. It is necessary to determine whether the value of the state variable has changed at each timestamp. The specific method is to record the initial value of the state variable, and then check whether the state has a new value at each timestamp. If it has, determine whether it has changed compared with the last time and update the last value, otherwise continue to check the next timestamp. If there is a change, the state before and after the change is corresponded to the natural number agreed in step S1, and then it is connected into a number string according to the rules in step S1.

[0042] Step S3: Whenever a new string of numbers is obtained, use it to index the corresponding element in array A, and then set the value of the array element to 1. Figure 3 As shown in the figure, the value of the 2023rd bucket (corresponding to the array value with the subscript 2022) is rewritten to 1, indicating the occurrence of the state transition from 20 to 23. If the state transition occurs repeatedly, the corresponding array element value is still 1, achieving the purpose of deduplication. By using this feature, when calculating the combined coverage of multiple files, the state transition information is stored in the same array, which can conveniently merge the state transition information of multiple files and facilitate the calculation of the combined coverage of multiple files.

[0043] If multiple threads detect the same type of state transition at the same time, the corresponding array elements will be set to 1 at the same time, but no error will occur. The final result is that the corresponding array elements are correctly set to 1, and the occurrence of this state transition is correctly detected.

[0044] Step S4: After the entire VCD file is parsed, all generated state transition types will be recorded into a series of buckets. m The total number of state transitions or the total number of state transitions merged from multiple files can be obtained by traversing each bucket and accumulating the values ​​stored in the buckets. Dividing it by the theoretical number of state transitions x, the coverage or merged coverage value n can be obtained as follows:

[0045]

[0046] In summary, the present invention proposes a method for calculating the coverage of FSM state transitions based on bucket sorting. Through the method of dividing and parsing VCD files with iconic symbols, the signal change information and corresponding symbols therein are extracted by traversal and conditional matching, and the information is converted and stored into an array suitable for coverage statistics; a bucket sorting algorithm is used for deduplication and statistics and multi-threaded acceleration is performed to improve the efficiency of large-scale coverage verification. The method of the present invention takes into account that the time complexity of accessing array elements is 0(1), and takes the possible state transitions as the index of the array, indexes the captured state transitions to the corresponding array elements, and sets their values ​​from 0 to 1 to mark their occurrence. After the statistics are completed, the array will store all state transition information, realizing the FSM state transition coverage calculation with a time complexity of 0(n), realizing efficient statistics of ultra-large-scale FSM state transition coverage, and effectively improving the verification efficiency.

[0047] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0048] It should be noted that the above content only illustrates the technical idea of ​​the present invention and cannot be used to limit the protection scope of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications all fall within the protection scope of the claims of the present invention.

Claims

1. The FSM state transition coverage calculation method based on bucket sorting is characterized by: The steps include: S1, create an array: according to the FSM model, create an array for storing FSM state transition information, the array length is based on the number of states and the number of bits in the FSM model to ensure the uniqueness of the state transition information; the FSM state transition information stored in the array is specifically as follows: according to the FSM model, all possible states are listed and numbered as 0, 1, 2, 3...N-1, N is the total number of states, and the number combination of the states before and after the state transition is represented as a unique integer; if the number of digits in the total number of states is greater than the number of state digits, zeros are padded on the left before the number combination; S2, state transfer judgment: by parsing the VCD file, tracking the changes of state variables, judging whether state transfer occurs, if state transfer does not occur, repeat this step until state transfer occurs, and enter step S3; S3, storing state transition information: when a state transition occurs, the corresponding array element value is set from 0 to 1 using the state transition information, and all extracted state transition information is stored in the same array; the method of recording state transition is specifically: the two numbers corresponding to the state transition are padded with zeros on the left according to the number of digits m of the total number of states, and then the two numbers are connected to obtain a 2m-digit number to uniquely identify this type of state transition; Use this number as the index of the corresponding array, set the corresponding array value from 0 to 1, and store all the extracted state transition information into the same array; S4, coverage calculation: using the array of all stored state transition information obtained in step S3, calculate the FSM state transition coverage or the multi-file merged state transition coverage.

2. The method for calculating the FSM state transition coverage rate based on bucket sorting according to claim 1, characterized in that: The total length of the array in step S1 is N*10 m , where m is the number of state bits and N is the total number of states.

3. The method for calculating the FSM state transition coverage rate based on bucket sorting according to claim 2, characterized in that: The method for determining the state transfer in step S2 is specifically as follows: starting from the initial assignment of the variable at time zero, the value of the state variable at each timestamp is recorded, and compared with the previous value. If a change occurs, a state transfer is recorded, otherwise the next comparison is continued.

4. The method for calculating the FSM state transition coverage rate based on bucket sorting according to claim 3, characterized in that: The step S4 is specifically as follows: traverse all elements of the array and accumulate the values ​​of the array elements to obtain the total number of state transitions generated or the total number of state transitions merged from multiple files, and divide it by the total number of state transitions to obtain the FSM state transition coverage or the multi-file merge coverage.

5. A FSM state transition coverage calculation system based on bucket sorting, including a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.