A clock spurs detection circuit and detection method
Clock glitch detection is implemented using System Verilog programming language through a clock glitch detection circuit. This automates the identification of clock glitches, solves the reliability and efficiency problems of clock glitch detection in large-scale integrated circuits, simplifies the circuit structure, and quickly locates glitch.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHIPINTELLI TECH CO LTD
- Filing Date
- 2026-02-05
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies cannot efficiently and reliably automate the detection of clock glitches in large-scale integrated circuits, and traditional methods are complex or require external high-frequency clock assistance, resulting in low detection efficiency and a high susceptibility to errors.
A clock glitch detection circuit is adopted, and the rising edge and falling edge sampling modules are implemented using System Verilog language. Combined with the level period calculation module and the SVA assertion automatic judgment unit, clock glitch is automatically judged by detecting the edge sampling of the clock itself, simplifying the circuit structure.
It achieves reliable and efficient detection of clock glitches, avoids missed detections and false detections, simplifies circuit design, and quickly locates the cause of glitches.
Smart Images

Figure CN121633799B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of integrated circuit technology and relates to clock signal calibration, specifically to a clock glitch detection circuit and detection method. Background Technology
[0002] Clock glitches in chip development can lead to instability in chip circuits and even logic failures, causing the chip to malfunction. Therefore, avoiding clock glitches is crucial during chip development. However, as chip development scales up and clock circuits become more complex, the requirements for the efficiency and reliability of clock glitch detection become even higher.
[0003] In existing technologies, a common method is to simulate clock test cases and then manually examine the waveform of the clock simulation results to analyze whether clock glitches are generated during clock configuration. This method is not only inefficient but also introduces the risk of detection errors, making it unsuitable for large-scale integrated circuit verification. Another method is to build a clock glitch detection circuit using the System Verilog hardware programming language. This involves introducing a high-frequency sampling clock externally to count the adjacent edges of the clock to be tested, and then comparing the count value with the frequency ratio of the high-frequency sampling clock and the detection clock at the rising or falling edge of the detection clock to detect clock glitches. While this method can automate clock glitch detection, it requires an externally introduced high-frequency clock proportional to the detection clock, and the implementation circuit is relatively complex. Furthermore, glitches cannot be detected if the period of the clock glitch is shorter than the period of the high-frequency sampling clock.
[0004] In summary, traditional clock glitch detection technologies cannot meet the requirements of high reliability, high efficiency, and simple and rapid glitch location in automated detection circuits. Summary of the Invention
[0005] To overcome the technical defects of the existing technology, this invention discloses a clock glitch detection circuit and detection method.
[0006] The clock glitch detection circuit of the present invention includes a rising edge sampling module and a falling edge sampling module; the sampling output terminals of the rising edge sampling module and the falling edge sampling module are connected to a level period calculation module, the output terminal of the level period calculation module is connected to the clock glitch detection module, and the output terminal of the clock glitch detection module is connected to an automatic judgment unit.
[0007] The rising edge sampling module and falling edge sampling module are used to sample and output the occurrence time of the rising edge and falling edge; the level period calculation module is used to calculate the difference between the occurrence time of adjacent rising edges and falling edges; the clock glitch detection module determines whether it is a glitch based on the difference; and the automatic judgment unit outputs glitch information.
[0008] Preferably, the rising edge sampling module and the falling edge sampling module are implemented using System Verilog language, and the system function $realtime provided by System Verilog language is used to capture the time of the rising edge and the falling edge.
[0009] Preferably, the automatic judgment unit is implemented by the SVA assertion function of System Verilog.
[0010] A clock glitch detection method, based on the detection circuit, includes the following steps:
[0011] Step 1. Detect the rising edge and falling edge times of the clock;
[0012] Step 2. Subtract the rising edge time points from the falling edge time points to obtain the stable level period value TH and save it;
[0013] Step 3. Clock glitch detection, specifically:
[0014] Step 31. Set the stable quantity threshold D1 and the stable difference threshold D2, and start detection from the second clock cycle;
[0015] Step 32. Compare the current stable level period with the previous stable level period value. If the difference between the two is less than the stability difference threshold D2, the clock signal is considered to be output stably. When the number of consecutive stable clock signals reaches the stability number threshold D1, calculate the average value MA of these D1 consecutive stable level periods, and use it as the current stable level period value MS.
[0016] In step 32, if the difference between adjacent stable level periods is greater than the stable difference threshold D2 before reaching the stable quantity threshold D1, the counting restarts until the number of continuously stable clock signals reaches the stable quantity threshold D1.
[0017] Step 33. After reaching the stable quantity threshold D1 and the stable level period of continuous operation is greater than the pre-exemption threshold D3, the subsequent stable level periods are continuously compared. If the difference between the value of the subsequent stable level period and the stable value MS of the current stable level period is found to be greater than the stable difference threshold D2, then proceed to step 34; otherwise, continue with step 33.
[0018] Step 34. For stable level period T(N) where the difference between the stable level period value and the current stable level period value MS is greater than the stable difference threshold D2, continue to detect subsequent stable level periods of stable level period T(N);
[0019] Step 341. If the difference between the subsequent stable level period value and the stable level period value of the stable level period T(N) is greater than the stable difference threshold D2, then the stable level period T(N) is determined to be a glitch;
[0020] Step 342. If the difference between the subsequent stable level period value and the stable level period value of the stable level period T(N) is less than the stable difference threshold D2, then the clock signal is considered to be output stably. When the number of consecutive stable clock signals reaches the stable number threshold D1, the average value MA of these consecutive D1 stable level periods is calculated as the updated stable level period value MS.
[0021] In step 342, if after the clock signal is determined to be output stably, the number of continuously output clock signals does not reach the stable quantity threshold D1 and the difference is greater than the stable difference threshold D2 again, then the stable level period T(N) and the subsequent stable level period before reaching the stable quantity threshold D1 are still regarded as glitches.
[0022] After detecting a glitch or updating the stable level period value MS, return to step 33 to continue detection;
[0023] Set the stable voltage level to high and low respectively, and repeat step 3;
[0024] Step 4. Output burr information.
[0025] Preferably, step 31 further includes a pre-exemption threshold D3, during which no glitch detection is performed within the initial D3 stable level cycles.
[0026] The clock glitch detection circuit and method described in this invention use the clock being detected to sample its own edges without counting to obtain the clock period, thus avoiding missed or false detections of clock glitch and simplifying the clock detection circuit. This invention uses the SVA assertion method to automatically detect clock glitch and output glitch information, improving detection efficiency and facilitating the location of the time point and cause of clock glitch occurrence. Attached Figure Description
[0027] Figure 1 This is a schematic diagram of a specific embodiment of the clock glitch detection circuit described in this invention;
[0028] Figure 2 This is a schematic diagram illustrating a specific embodiment of the clock glitch detection method described in this invention;
[0029] Figure 3 This is a schematic diagram of a specific embodiment of step 3 of the present invention. Detailed Implementation
[0030] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0031] The clock glitch detection circuit of the present invention includes a rising edge sampling module and a falling edge sampling module; the sampling output terminals of the rising edge sampling module and the falling edge sampling module are connected to a level period calculation module, the output terminal of the level period calculation module is connected to the clock glitch detection module, and the output terminal of the clock glitch detection module is connected to an automatic judgment unit.
[0032] The rising edge sampling module uses the clock being detected itself to sample the rising edge of the clock being detected, thereby obtaining the rising edge time point of the clock being detected. There is no need to introduce a high-frequency clock to sample the rising edge of the detection clock, which ensures that every rising edge of the detection clock is sampled and that no glitches of the clock being detected are missed.
[0033] The falling edge sampling module uses the clock being detected itself to sample the falling edge of the clock being detected, thereby obtaining the falling edge time point of the clock being detected. There is no need to introduce a high-frequency clock to sample the falling edge of the clock being detected, ensuring that every falling edge of the clock being detected is sampled and that no glitches of the clock being detected are missed.
[0034] The rising edge sampling module and falling edge sampling module are implemented using System Verilog. The built-in System Verilog function `$realtime` captures and saves the time point of each rising and falling edge. Both normal clock signals and clock glitches generate rising and falling edges simultaneously. By capturing each rising and falling edge, every high and low level change of the clock signal can be detected.
[0035] The level period calculation module performs a difference calculation on the rising edge time point TR of the detected clock sampled by the adjacent rising edge sampling module and the falling edge time point TF of the detected clock sampled by the falling edge sampling module to obtain the duration of each stable level of the sampled clock, that is, the duration of the high level or low level; if the TR time point comes first and the TF time point comes later, the difference obtained is the duration of the low level, and if the TF time point comes first and the TR time point comes later, the difference obtained is the duration of the high level.
[0036] The level period calculation module is implemented using System Verilog software. Its function is to calculate the difference between the time point data output by the rising edge sampling module and the falling edge sampling module. It does not require the use of the counter value to estimate the high level period of the detection clock, thus avoiding the generation of high level period errors and simplifying the clock glitch detection circuit.
[0037] The clock glitch detection module is triggered by the clock being detected. When the rising or falling edge of the clock being detected arrives, it compares and analyzes the adjacent stable level cycles of the calculation result of the level period calculation module, and outputs the detection result to ensure the reliability of the detection.
[0038] The SVA assertion auto-judgment unit is triggered by the detected clock. When the rising or falling edge of the detected clock arrives, it automatically judges the analysis results output by the clock glitch detection module, and reports and outputs errors for periods identified as glitch, ensuring detection efficiency and rapid location of glitch problems. Both the clock glitch detection module and the SVA assertion auto-judgment unit are implemented using System Verilog.
[0039] Specific testing methods include:
[0040] Step 1. Detect the rising edge and falling edge times of the clock, as shown below:
[0041] When the rising and falling edges of the clock are detected, the current time can be obtained and saved using the System Verilog system function $realtime.
[0042] Step 2. Detect the duration of the clock level, which is manifested as follows:
[0043] The duration of the stable level is obtained by subtracting the rising edge time from the falling edge time of the acquired detection clock and then saving it.
[0044] The level period calculation module performs a difference calculation on the rising edge time point TR of the detected clock sampled by the adjacent rising edge sampling module and the falling edge time point TF of the detected clock sampled by the falling edge sampling module to obtain the duration of each stable level of the sampled clock, that is, the duration of the high level or low level; if the TR time point comes first and the TF time point comes later, the difference obtained is the duration of the low level, and if the TF time point comes first and the TR time point comes later, the difference obtained is the duration of the high level.
[0045] The following explanation will use the duration of a stable level as an example of the duration of a high level.
[0046] Step 3. Clock glitch detection, manifested as:
[0047] The calculated high-level period value is stored in a multi-level clock register under the detection clock to compare and analyze the high-level periods of adjacent periods. If a high-level period is inconsistent with the previous few high-level periods and also inconsistent with the subsequent few high-level periods, then the high level is considered a glitch.
[0048] Taking a stable high level as an example, the specific implementation method is as follows:
[0049] Step 31. Set the stable quantity threshold D1 and the stable difference threshold D2, and start detection from the second high-level cycle;
[0050] A threshold D3 for the number of items exempted from inspection can also be set. During the first D3 high-level cycles, since the clock is still being established, no glitches are detected. D3 is usually 1.5 to 3 times D1.
[0051] Step 32. Compare the current high-level cycle value with the previous high-level cycle value. If the difference between the two is less than the stable difference threshold D2, the clock signal is considered to be output stably. When the number of consecutive stable clock signals reaches the stable number threshold D1, calculate the average value MA of these D1 consecutive high-level cycles, and use it as the current high-level cycle stable value MS.
[0052] In step 32, if the difference between adjacent high-level cycles is greater than the stable difference threshold D2 before reaching the stable quantity threshold D1, the counting restarts until the number of continuously stable clock signals reaches the stable quantity threshold D1.
[0053] Step 33. After reaching the stable quantity threshold D1 and the continuous high-level period is greater than the pre-exemption threshold D3, the subsequent high-level periods are continuously compared. If the difference between the subsequent high-level period value and the current stable high-level period value MS is found to be greater than the stable difference threshold D2, then proceed to step 34; otherwise, continue with step 33.
[0054] Step 34. For high-level periods T(N) where the difference between the high-level period value and the current stable high-level period value MS is greater than the stable difference threshold D2, continue to detect subsequent high-level periods of high-level periods T(N);
[0055] Step 341. If the difference between the subsequent high-level period value and the high-level period value of high-level period T(N) is greater than the stable difference threshold D2, then the high-level period T(N) is determined to be a glitch;
[0056] Step 342. If the difference between the subsequent high-level period value and the high-level period value of high-level period T(N) is less than the stability difference threshold D2, then the clock signal is considered to be output stably. When the number of consecutive stable clock signals reaches the stability number threshold D1, it indicates that the clock period itself has undergone controlled adjustment starting from the high-level period T(N), rather than glitches. In this case, the average value MA of these consecutive D1 high-level periods is calculated as the updated high-level period stability value MS.
[0057] In step 342, if after the clock signal is determined to be output stably, the number of continuously output clock signals does not reach the stable number threshold D1 and the difference is greater than the stable difference threshold D2 again, then the high-level period T(N) and the subsequent high-level period before reaching the stable number threshold D1 are still regarded as glitches.
[0058] After detecting a glitch or updating the stable value of the high-level period MS, return to step 33 to continue the detection.
[0059] For example, set a stable quantity threshold D1=3, a stable difference threshold D2=0.4, and a pre-exemption quantity threshold D3=6. Figure 3 As shown, the horizontal axis represents the number of cycles, and the vertical axis represents the high-level cycle value. The high-level cycle values for the first 7 cycles T1 to T7 are all equal to 2. The high-level cycle values for the 8th and 9th cycles T8 and T9 are both 2.5. After the 10th cycle T10, the high-level cycle values are all equal to 3.
[0060] Replace the high level with a low level and repeat step 3. When detecting either level, either detection is judged as a glitch.
[0061] In step 32, the current high-level period is compared with the previous high-level period in the first 4 cycles. When the difference between the two is less than the stable difference threshold D2=0.4 and the number of clock signals that are continuously and stably output reaches the stable number threshold D1=3, the average value of these 3 consecutive high-level periods, 2, is taken as the current high-level period stable value MS=2.
[0062] In step 33, after the continuous high-level cycle is greater than the pre-exemption threshold D3=6, starting from the seventh cycle, it is detected whether the difference between the current high-level cycle value and the current high-level cycle stable value MS=2 is greater than the stable difference threshold D2. If it is not greater in the seventh cycle, then step 33 is repeated.
[0063] If the high-level period value of the 8th cycle is 2.5, which is greater than the stability difference threshold D2, then proceed to step 34 to continue detecting the subsequent high-level periods of the high-level period T(N). If the difference between the 9th cycle and the 8th cycle is not greater than the stability difference threshold D2, then the clock signal is considered to be output stably, and proceed to step 342. Since the high-level period value of the 10th cycle is 3, the difference is again greater than the stability difference threshold D2, so the 8th and 9th cycles are still considered as glitches.
[0064] Starting from the 10th cycle, if the difference between the 11th and 10th cycles is not greater than the stable difference threshold D2, the clock signal is considered to be output stably, and the process continues to step 342. Since the high-level cycle value of each cycle after the 10th cycle is 3, when the number of continuously stable clock signals reaches the stable number threshold D1, it indicates that the clock cycle itself has undergone controlled adjustment since the 10th cycle, rather than glitches. In this case, starting from the 10th cycle, the average value of the 10th, 11th, and 12th consecutive high-level cycles is calculated to be 3, which is used as the updated high-level cycle stability value MS=3, thereby eliminating glitches and updating the MS value when the clock signal itself changes.
[0065] Replace the high level with a low level and repeat step 3.
[0066] Step 4. Detection result determination: By using SVA assertions under the trigger of the detection clock, the detection result of each clock glitch can be determined and output. The output includes information such as the occurrence time of the clock glitch and the glitch width.
[0067] Based on traditional clock glitch detection solutions, this solution demonstrates significant improvements in reliability, efficiency, circuit simplification, and rapid clock glitch location.
[0068] This invention uses the clock being tested as the sampling clock, enabling glitches to be detected on clocks of any frequency. It can accurately sample each rising and falling edge of the clock being tested and obtain the corresponding time point, then calculate each high-level period of the clock being tested, and then determine whether clock glitches are generated by analyzing the differences between multiple adjacent high-level periods, ensuring that clock glitches are not missed or falsely detected, thus guaranteeing the reliability of clock glitches detection.
[0069] The clock detection circuit samples and detects at each edge of the clock. The detection results are determined using SVA assertions. It can achieve fully automated real-time detection and determination without manual intervention and print out the results, ensuring high efficiency in clock glitch detection.
[0070] Using the detection clock as the sampling clock eliminates the need to manually generate a high-frequency sampling clock when detecting clock glitches. The high-level period is calculated by directly sampling the rising and falling edges of the detection clock, without using a counter to estimate the high-level period. The existing mature SVA assertion is used for result determination, which simplifies the implementation of the automated clock glitch detection circuit and allows for quick start-up, thus ensuring the simplification of the automated clock glitch detection circuit.
[0071] SVA assertions are used to determine the clock glitch detection results. When a clock glitch is detected, it will output in real time that a glitch has occurred at the current time point. Furthermore, the specific cause can be quickly located by viewing and analyzing the SVA assertion simulation waveform, ensuring rapid location of clock glitch problems.
[0072] The foregoing descriptions are preferred embodiments of the present invention. Unless there is a clear contradiction between the preferred embodiments or a prerequisite for a particular preferred embodiment, the preferred embodiments can be arbitrarily combined and used. The embodiments and specific parameters described are only for clearly illustrating the inventor's invention verification process and are not intended to limit the scope of patent protection of the present invention. The scope of patent protection of the present invention shall still be determined by its claims. Similarly, any equivalent structural changes made based on the description and drawings of the present invention shall also be included within the scope of protection of the present invention.
Claims
1. A method for detecting clock glitch, characterized in that... A clock glitch detection circuit is provided, comprising a rising edge sampling module and a falling edge sampling module; the sampling output terminals of the rising edge sampling module and the falling edge sampling module are connected to a level period calculation module, the output terminal of the level period calculation module is connected to the clock glitch detection module, and the output terminal of the clock glitch detection module is connected to an automatic judgment unit. The function of the rising edge sampling module and the falling edge sampling module is to sample and output the occurrence time points of the rising edge and the falling edge; The level period calculation module is used to calculate the difference between the occurrence times of adjacent rising and falling edges. The clock glitch detection module determines whether it is a glitch based on the difference. The automatic judgment unit outputs glitch information. The detection method includes the following steps: Step 1. Detect the rising edge and falling edge times of the clock; Step 2. Subtract the rising edge time points from the falling edge time points to obtain the stable level period value and save it; Step 3. Clock glitch detection, specifically: Step 31. Set the stable quantity threshold D1 and the stable difference threshold D2, and start detection from the second clock cycle; Step 32. Compare the current stable level period with the previous stable level period value. If the difference between the two is less than the stable difference threshold D2, the clock signal is considered to be output stably. When the number of consecutive stable clock signals reaches the stable number threshold D1, calculate the average value MA of these consecutive D1 stable level periods, and use it as the current stable level period value MS. In step 32, if the difference between adjacent stable level periods is greater than the stable difference threshold D2 before reaching the stable quantity threshold D1, the counting restarts until the number of continuously stable clock signals reaches the stable quantity threshold D1. Step 33. After reaching the stable quantity threshold D1 and the stable level period of continuous operation is greater than the pre-exemption threshold D3, the subsequent stable level periods are continuously compared. If the difference between the subsequent stable level period value and the current stable level period value MS is found to be greater than the stable difference threshold D2, then proceed to step 34; otherwise, continue with step 33. Step 34. For stable level period T(N) where the difference between the stable level period value and the current stable level period value MS is greater than the stable difference threshold D2, continue to detect subsequent stable level periods of stable level period T(N); Step 341. If the difference between the subsequent stable level period value and the stable level period value of the stable level period T(N) is greater than the stable difference threshold D2, then the stable level period T(N) is determined to be a glitch; Step 342. If the difference between the subsequent stable level period value and the stable level period value of the stable level period T(N) is less than the stable difference threshold D2, the clock signal is considered to be output stably. When the number of consecutive stable clock signals reaches the stable number threshold D1, the average value MA of these consecutive D1 stable level periods is calculated as the updated stable level period value MS. In step 342, if after the clock signal is determined to be output stably, the number of continuously output clock signals does not reach the stable number threshold D1 and the difference is greater than the stable difference threshold D2 again, then the stable level period T(N) and the subsequent stable level period before reaching the stable number threshold D1 are still regarded as glitches. After detecting a glitch or updating the stable level period value MS, return to step 33 to continue detection; Set the stable voltage level to high and low respectively, and repeat step 3; Step 4. Output burr information.
2. The clock glitch detection method as described in claim 1, characterized in that, In step 31, a threshold D3 for the number of items exempted from inspection is set, and no glitch judgment is performed within the first D3 stable level cycles.
Citation Information
Patent Citations
Signal monitoring device, signal monitoring method, electronic equipment and storage medium
CN120761818A