A variable clock frequency detection circuit and its working method

By adding high and low level sampling and maximum error tolerance parameters to the clock frequency detection circuit, combined with the frequency conversion alarm mechanism, the problems of limited detection accuracy and high misjudgment in the existing technology are solved, and the security and safety of the SOC chip clock system are improved. reliability.

CN114721899BActive Publication Date: 2024-09-06TIH MICROELECTRONIC TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210272078.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-18
Publication Date
2024-09-06
Estimated Expiration
2042-03-18

AI Technical Summary

Technical Problem

Existing clock frequency detection circuits have problems such as limited detection accuracy and high probability of misjudgment, especially the problem of misjudgment caused by the limited frequency of the internal reference clock and process deviation.

Method used

A variable clock frequency detection circuit is used to expand the detection range and reduce the probability of misjudgment by increasing the high and low level sampling count comparison of the divided clock and setting the maximum error tolerance parameters. A variable frequency alarm mechanism is introduced to detect frequency changes.

Benefits of technology

It improves the safety and reliability of the SOC chip clock system, reduces missed detections and misjudgments, expands the frequency detection range, and reduces the probability of misjudgments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721899B
    Figure CN114721899B
Patent Text Reader

Abstract

A variable clock frequency detection circuit and working method. The present invention solves the problem of missed detection of frequency conversion within a single detection cycle and misjudgment caused by process problems such as reference clock jitter by adding parameter settings for high and low level sampling count comparison of the divided clock and maximum fault tolerance, thereby greatly improving the safety and reliability of the SOC chip clock system. The present invention takes into account practical application problems such as process problems or different external attack methods, reduces the problem of missed judgment and misjudgment in the digital clock frequency detection system, and improves the safety and reliability of the system. By adding a frequency conversion alarm, the safety of the frequency detection system is improved to a certain extent, and the concept of maximum fault tolerance is introduced, which reduces the probability of misjudgment caused by the jitter of the reference clock.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention discloses a variable clock frequency detection circuit and a working method thereof, belonging to the technical field of security chip clock system protection. Background Art

[0002] The normal operation of different SOC chips is based on the regularity of the clock. When the clock signal jitters, deflects, changes in duty cycle or abnormal frequency changes, the SOC chip may have abnormal functional problems or fail directly. Therefore, safety chips pay special attention to the safety protection of the clock system. Ensuring the normal behavior of the clock system is the cornerstone of ensuring the normal function and performance of the chip.

[0003] Based on the above description of the prior art, the following patent documents are disclosed in the art:

[0004] Chinese patent document CN103647552A discloses a clock frequency detection circuit, which is composed of an analog frequency detection module and a digital frequency detection module. The analog frequency detection module provides frequency detection affected by process deviations, and the digital frequency detection module further improves the frequency detection accuracy on the basis of the frequency detection of the analog frequency detection module, thereby achieving higher-precision frequency detection. The frequency detection accuracy of this frequency detection circuit does not depend on process deviations but mainly depends on the frequency accuracy of the reference clock. In this patent document, analog detection and digital detection are compared to improve detection accuracy, but since the area of ​​the analog circuit is relatively large, the circuit cost is also increased.

[0005] Chinese patent document CN110887992A discloses a clock frequency detection circuit, wherein the clock to be tested passes through the frequency division unit 1, and after the frequency division, it is synchronized to the clock domain after the frequency division of the high-frequency unit through the synchronization unit; secondly, a pulse signal is obtained through the rising edge generation unit; then, the high-frequency clock generated by the high-frequency clock unit passes through the frequency division unit 2 to obtain a ruler clock, which is counted by the ruler counting unit and stored in the count value storage unit; finally, the ruler count value stored in the count value unit is compared with the expected value, and the result is output respectively. This patent document only has digital circuit detection and has clock stop and frequency conversion alarm.

[0006] Combined with the existing technology, the clock of the SOC system generally consists of two parts: internal clock and external clock. The internal clock is generally generated by an internal oscillator, which generates a high-frequency clock through an internal phase-locked loop circuit and then distributed to each clockdomain; the external clock is generally a communication clock or an external crystal oscillator. It is generally believed that the probability of the internal clock being attacked is small and negligible, that is, the internal clock is highly secure and reliable, so it is only necessary to monitor the external clock to ensure the security of the SOC chip clock system. The general digital frequency detection schematic is shown in the attached figure. Figure 1As shown, the basic frequency detection process is as follows:

[0007] First, the external clock is divided and the divided signal is synchronized to the reference clock domain;

[0008] The sampling count is then aligned with the reference clock, and the count value is compared with the set parameters (high frequency threshold, low frequency threshold) at the end of each detection cycle, and the corresponding high frequency alarm and low frequency alarm are issued.

[0009] According to the above process, the frequency detection alarm is realized "perfectly", but there are still the following technical problems in the actual implementation process:

[0010] 1. Since the reference clock used is an internal clock with limited frequency, the frequency range of detection is limited. At the same time, due to the influence of the synchronization process, the accuracy of detection will also be affected.

[0011] 2. Since the above method is essentially to perform frequency discrimination through a counter, the count value is compared with the discrimination value at the end of the count, that is, there is a detection cycle. Therefore, it is possible that the external clock changes frequency twice within one detection cycle, but the frequency is normal in actual detection.

[0012] 3. In addition, the reference clock actually has process deviations, which also increases the probability of misjudgment to a certain extent. Summary of the invention

[0013] In view of the problems existing in the prior art, the present invention provides a variable clock frequency detection circuit.

[0014] The invention also discloses a working method of the detection circuit. Summary of the invention:

[0016] The present invention solves the problems of missed detection of frequency conversion within a single detection cycle and misjudgment caused by process problems such as reference clock jitter by adding parameter settings for comparison of high and low level sampling counts of the divided clock and maximum fault tolerance, thereby greatly improving the safety and reliability of the SOC chip clock system.

[0017] The detailed technical scheme of the present invention is as follows:

[0018] A variable clock frequency detection circuit, characterized in that the detection circuit comprises: an external clock module, a reference clock module, a parameter configuration module and a counter;

[0019] The external clock module includes a clock frequency division module and a synchronization circuit;

[0020] The external clock signal to be tested is converted into a divided signal div_clk through the clock frequency division module, and then converted into div_clk_sync through the synchronization circuit for reference clock ref_clk counting; the clock frequency division module is used to increase the detection period. Since the counting error caused by the synchronization circuit is fixed to 1, the influence of the synchronization error on the frequency detection result is reduced by increasing the proportion of the detection period; in addition, the effective detection range of the frequency to be tested can be expanded by increasing the frequency division ratio; the role of the synchronization circuit is to reduce the probability of metastable state, because the divided clock div_clk needs to be sampled and counted in the ref_clk clock domain, and if it is not synchronized, it may bring the risk of metastable state;

[0021] The parameter configuration module: the upper layer configures relevant parameters to this module, including the external clock division ratio D, the maximum fault tolerance value GAP, the upper threshold CH corresponding to the high and low frequency alarms, and the lower threshold CL corresponding to the high and low frequency alarms; wherein, the calculation formulas of the upper threshold CH corresponding to the high and low frequency alarms and the lower threshold CL corresponding to the high and low frequency alarms are:

[0022]

[0023] In formula (1), N is the upper and lower thresholds, corresponding to CH and CL; CH: The signal of the boundary frequency of the low-frequency alarm after frequency division synchronization is a detection cycle, and the CH value represents the number of ref_clk cycles contained in one detection cycle; CL: The signal of the boundary frequency of the high-frequency alarm after frequency division synchronization is a detection cycle, and the CL value represents the number of ref_clk cycles contained in one detection cycle; The frequency of the reference clock ref_clk is a known fixed value; The supported frequency detection range is The maximum measurable frequency is affected by the input reference clock frequency Fr and the external clock division ratio D; Fe is the external clock frequency;

[0024] The counter is used to measure the number of ref_clk cycles contained in the signal cycle of the external clock after frequency division and synchronization, and compare this count value with the CH value and the CL value respectively:

[0025] When the count value is not greater than the CL value, a high-frequency alarm signal is output;

[0026] When the count value is greater than the CH value, a low-frequency alarm signal is output.

[0027] The working method of the above detection circuit is characterized by comprising:

[0028] (1) Configuration parameters The relevant parameters in the configuration module are: external clock division ratio D, maximum fault tolerance value GAP, CH is the upper threshold corresponding to the high and low frequency alarms, and CL is the lower threshold corresponding to the high and low frequency alarms; the calculation formulas of CH and CL are: Fr is the reference clock frequency, Fe is the external clock frequency;

[0029] (2) using the external clock frequency division ratio D configured in step (1) to divide the external clock after clock distribution, and passing it through a synchronization circuit;

[0030] (3) The reference clock samples and counts the divided and synchronized signal div_clk_sync, including:

[0031] The count values ​​cnt_high and cnt_low are obtained by sampling the high level and low level of the divided clock signal respectively;

[0032] Sampling the entire clock signal, that is, the count value clk_cnt obtained in one detection cycle, here refers to the signal div_clk_sync after the external clock signal is divided and synchronized, and one signal cycle is one frequency sampling cycle;

[0033] (4) Compare the obtained count value clk_cnt with the parameters CH and CL configured in step (1) to output the corresponding alarm information:

[0034] When clk_cnt is not greater than CL, a high-frequency alarm is output;

[0035] When clk_cnt is not less than CH, a low-frequency alarm is output;

[0036] When clk_cnt exceeds the count limit, it is determined that the external clock stops, and the clock stops alarming is output at this time. The count limit refers to the counter limit. The number of bits of the counter is limited. For example, the maximum count value of a 10-bit counter is 1023. When it exceeds 1023, the counter value will roll over to 0 and start to increase again. Therefore, the clock stops alarming will be output when the counter rolls over, that is, exceeding the counter is used as the judgment condition for the external clock to stop; because the larger the count, the lower the frequency to be measured. If the counter limit is exceeded, it is considered that the clock stops or does not exist.

[0037] When the absolute value of the difference between cnt_high and cnt_low is greater than the maximum tolerance value GAP, a frequency conversion alarm is output. The frequency conversion alarm compares the number of reference clock cycles within the high and low electrical frequency cycles of div_clk_sync. If the value exceeds the maximum tolerance value GAP, it is considered that the frequency of the external clock to be tested changes at least once within one detection cycle.

[0038] Because the normal operation of the SOC chip is based on the regularity of the clock, when the clock signal jitters, deflects, changes in duty cycle or abnormal frequency changes, the SOC chip may have abnormal functional problems or fail directly. For this reason, this solution innovatively uses variable frequency alarm: on the one hand, it detects the occurrence of jitter of the clock signal to be tested, and on the other hand, it prevents the frequency of the clock signal to be tested from changing during a detection cycle but the count value does not exceed the safety threshold. In this case, no high or low frequency alarm will be issued, but there will be a variable frequency alarm.

[0039] Beneficial effects of the present invention:

[0040] The present invention takes into account practical application problems such as process problems or different external attack methods, reduces the problem of missed judgment and misjudgment in the digital clock frequency detection system, and improves the safety and reliability of the system. By adding a frequency conversion alarm, the safety of the frequency detection system is improved to a certain extent, and the concept of maximum fault tolerance is introduced, which reduces the probability of misjudgment caused by the jitter of the reference clock. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a schematic diagram of a clock detection circuit commonly used in the prior art;

[0042] Figure 2 is a schematic diagram of the clock detection circuit of the present invention;

[0043] Figure 3 Detailed frequency detection diagram in an embodiment of the present invention. DETAILED DESCRIPTION

[0044] The present invention will be described in detail below with reference to the embodiments and the accompanying drawings, but is not limited thereto.

[0045] Embodiment 1,

[0046] like Figure 2 As shown, a variable clock frequency detection circuit comprises: an external clock module, a reference clock module, a parameter configuration module and a counter;

[0047] The external clock module includes a clock frequency division module and a synchronization circuit;

[0048] The external clock signal to be measured is converted into a divided signal div_clk by the clock frequency division module, and then converted into div_clk_sync by the synchronization circuit for counting of the reference clock ref_clk;

[0049] The parameter configuration module: the upper layer configures relevant parameters to this module, including the external clock division ratio D, the maximum fault tolerance value GAP, the upper threshold CH corresponding to the high and low frequency alarms, and the lower threshold CL corresponding to the high and low frequency alarms; wherein, the calculation formulas of the upper threshold CH corresponding to the high and low frequency alarms and the lower threshold CL corresponding to the high and low frequency alarms are:

[0050]

[0051] In formula (1), N is the upper and lower thresholds, corresponding to CH and CL; CH: The signal of the boundary frequency of the low-frequency alarm after frequency division synchronization is a detection cycle, and the CH value represents the number of ref_clk cycles contained in one detection cycle; CL: The signal of the boundary frequency of the high-frequency alarm after frequency division synchronization is a detection cycle, and the CL value represents the number of ref_clk cycles contained in one detection cycle; The frequency of the reference clock ref_clk is a known fixed value; The supported frequency detection range is The maximum measurable frequency is affected by the input reference clock frequency Fr and the external clock division ratio D; Fe is the external clock frequency;

[0052] The counter is used to measure the number of ref_clk cycles contained in the signal cycle of the external clock after frequency division and synchronization, and compare this count value with the CH value and the CL value respectively:

[0053] When the count value is not greater than the CL value, a high-frequency alarm signal is output;

[0054] When the count value is greater than the CH value, a low-frequency alarm signal is output.

[0055] Embodiment 2,

[0056] like Figure 2 , 3 As shown, the working method of the detection circuit as described in Example 1 includes:

[0057] (1) Configuration parameters The relevant parameters in the configuration module are: external clock division ratio D, maximum fault tolerance value GAP, CH is the upper threshold corresponding to the high and low frequency alarms, and CL is the lower threshold corresponding to the high and low frequency alarms; the calculation formulas of CH and CL are: Fr is the reference clock frequency, Fe is the external clock frequency;

[0058] (2) using the external clock frequency division ratio D configured in step (1) to divide the external clock after clock distribution, and passing it through a synchronization circuit;

[0059] (3) The reference clock samples and counts the divided and synchronized signal div_clk_sync, including:

[0060] The count values ​​cnt_high and cnt_low are obtained by sampling the high level and low level of the divided clock signal respectively;

[0061] Sampling the entire clock signal, that is, the count value clk_cnt obtained in one detection cycle;

[0062] (4) Compare the obtained count value clk_cnt with the parameters CH and CL configured in step (1) to output the corresponding alarm information:

[0063] When clk_cnt is not greater than CL, a high-frequency alarm is output;

[0064] When clk_cnt is not less than CH, a low-frequency alarm is output;

[0065] When clk_cnt exceeds the count limit, it is judged that the external clock stops, and the output clock stops alarming;

[0066] When the absolute value of the difference between cnt_high and cnt_low is greater than the maximum fault tolerance value GAP, a frequency conversion alarm is output.

[0067] In addition, it should be noted that regarding the threshold calculation:

[0068] Without considering the reference clock ref_clk clock jitter, the threshold calculation formula is The clock Fe to be measured is a fixed value; however, considering that the reference frequency Fr has a process deviation of ±p%, the boundary of the frequency Fe to be measured should also be adjusted accordingly. The specific analysis is as follows;

[0069] ① When the synchronization loss ±1 Fr is not considered, there are:

[0070]

[0071] Get

[0072] ② Considering the process deviation of Fr ±p%, we have:

[0073]

[0074] For example, when D = 16, Fr = 100MHz, p = 10, the upper and lower limits of the ideal frequency to be measured are Fe low =20MHz,Fe high =40MHz, the boundary count thresholds calculated according to formula (2) are CL=40, CH=80;

[0075] Substituting the calculated value into formula (3) can calculate the variation range of high and low frequencies, as follows:

[0076] High frequency boundary Fe high The range becomes (36, 44) MHz;

[0077] Low frequency boundary Fe low The range becomes (18, 22) MHz;

[0078] The above two ranges are possible alarm range changes caused by ref_clk clock jitter, so the corrected normal frequency range should be reset to (18, 44) MHz accordingly. At this time, the updated counting boundary thresholds calculated based on the corrected frequency range to be measured are CL=36.36, CH=88.89. Since the count value must be an integer, the counting boundary thresholds are slightly changed to CL=36, CH=89.

[0079] Application examples:

[0080] The detailed frequency detection process of the scenario described in Example 2 is as follows Figure 3 In the figure, the 12-frequency division of the external clock is used as a detection cycle, and the reference clock ref_clk is used to count the synchronized frequency-divided signal. The cnt_low and cnt_high are compared on the scale lines a and b, and the clock frequency conversion alarm is output according to the result; the count value clk_cnt is compared with the set count thresholds CL and CH on the scale line c, and the high-frequency and low-frequency alarms are output according to the results; if the clock stops, an alarm signal is output when clk_cnt exceeds the count limit. Figure 3 There are only three lines abc in the code. The principle followed is to compare after the counting is completed. The high and low frequency alarms are detected once in each detection cycle; the variable frequency alarm is detected after each high and low level count is completed, which is equivalent to detecting twice in each detection cycle.

Claims

1. A variable clock frequency detection circuit, characterized in that: The detection circuit includes: an external clock module, a reference clock module, a parameter configuration module and a counter; The external clock module includes a clock frequency division module and a synchronization circuit; The external clock signal to be measured is converted into a divided signal div_clk by the clock frequency division module, and then converted into div_clk_sync by the synchronization circuit for counting of the reference clock ref_clk; The parameter configuration module: upload configuration related parameters to this module, including the external clock division ratio D, the maximum fault tolerance value GAP, the upper threshold CH corresponding to the high and low frequency alarms, and the lower threshold CL corresponding to the high and low frequency alarms; wherein, the calculation formulas of the upper threshold CH corresponding to the high and low frequency alarms and the lower threshold CL corresponding to the high and low frequency alarms are: In formula (1), N is the upper and lower thresholds, corresponding to CH and CL; CH: The signal of the boundary frequency of the low-frequency alarm after frequency division synchronization is a detection cycle, and the CH value represents the number of ref_clk cycles contained in one detection cycle; CL: The signal of the boundary frequency of the high-frequency alarm after frequency division synchronization is a detection cycle, and the CL value represents the number of ref_clk cycles contained in one detection cycle; The frequency of the reference clock ref_clk is a known fixed value; The supported frequency detection range is The maximum measurable frequency is affected by the input reference clock frequency Fr and the external clock division ratio D; Fe is the external clock frequency; The counter is used to measure the number of ref_clk cycles contained in the signal cycle of the external clock after frequency division and synchronization, and compare this count value with the CH value and the CL value respectively: When the count value is not greater than the CL value, a high-frequency alarm signal is output; When the count value is not less than the CH value, a low-frequency alarm signal is output.

2. The working method of the detection circuit as claimed in claim 1, characterized in that: include: (1) Configuration parameters The relevant parameters in the configuration module are: external clock division ratio D, maximum fault tolerance value GAP, CH is the upper threshold corresponding to the high and low frequency alarms, and CL is the lower threshold corresponding to the high and low frequency alarms; the calculation formulas of CH and CL are: Fr is the reference clock frequency, Fe is the external clock frequency; (2) using the external clock frequency division ratio D configured in step (1) to divide the external clock after clock distribution, and passing it through a synchronization circuit; (3) The reference clock samples and counts the divided and synchronized signal div_clk_sync, including: The count values ​​cnt_high and cnt_low are obtained by sampling the high level and low level of the divided clock signal respectively; Sampling the entire clock signal, that is, the count value clk_cnt obtained in one detection cycle; (4) Compare the obtained count value clk_cnt with the parameters CH and CL configured in step (1) to output the corresponding alarm information: When clk_cnt is not greater than CL, a high-frequency alarm is output; When clk_cnt is not less than CH, a low-frequency alarm is output; When clk_cnt exceeds the count limit, it is judged that the external clock stops, and the output clock stops alarming; When the absolute value of the difference between cnt_high and cnt_low is greater than the maximum fault tolerance value GAP, a frequency conversion alarm is output.