A clock detection device, method and chip

By clearing the reference counter with overflow flags in the clock detection device, the metastable problem when the clock frequency is higher than the reference clock is solved, and the detection of a wider range of clock frequency is realized, which improves the universality and accuracy of the detection.

CN118017981BActive Publication Date: 2024-11-22北京中科昊芯科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410259111.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-07
Publication Date
2024-11-22
Estimated Expiration
2044-03-07

AI Technical Summary

Technical Problem

When detecting a clock signal, the existing clock detection device needs to be measured to be lower than the reference clock frequency, otherwise metastable problems may occur, resulting in detection errors.

Method used

The overflow is generated by driving the counter to the measured clock and clearing the reference clock counter with the overflow flag, realizing the detection of a wider range of clock frequencies, avoiding frequency limitations.

Benefits of technology

The detection of a wider range of clock frequencies is realized, which avoids metastable problems and improves the universality and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118017981B_ABST
    Figure CN118017981B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a clock detection device, method and chip, wherein the device comprises: a measured clock counter, whose input end is connected to the measured clock and is configured to perform cumulative counting on the rising edge of the measured clock; a reference clock counter, whose input end is connected to the reference clock and is configured to perform cumulative counting on the rising edge of the reference clock; a measured clock counter overflow detection unit, whose input end is connected to the output end of the measured clock counter and whose output end is connected to the reset signal end of the reference clock counter and is configured to generate a reset signal of the reference clock counter after detecting an overflow of the measured clock counter; and a reference clock counter overflow detection unit, whose input end is connected to the output end of the reference clock counter and is configured to monitor the overflow of the reference clock counter so as to confirm the loss of the measured clock through the overflow of the reference clock counter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of clock detection. Specifically, embodiments of the present application relate to a clock detection device, method and chip. Background Art

[0002] like Figure 1 As shown, the related art provides a clock detection device, which detects the clock state in real time and is used to sensitively detect whether the clock of the clock being tested exists. Figure 1 As shown, the clock detection device includes: a first counter and a second counter, a total of two counters, and each of the two counters is connected to a reference clock signal and a positive and negative clock signal to be measured respectively, and the counters output counting results to the first detection module and the second detection module respectively, and the two detection modules output the final detection results through an AND gate. Figure 1 The clock detection device is realized by a programmable logic device. One of the two counters is connected to the clock signal to be measured, and the other is connected to an inverter, and the other end of the inverter is connected to the signal to be measured. The reference clock signal is generated by a crystal oscillator. Figure 1 If the clock under test exists, the two counters will be reset alternately and will never reach the maximum value. If the clock under test is lost, no matter whether it maintains a low level or a high level, one of the counters will reach the maximum value because it cannot be reset, thereby realizing the detection of the clock under test.

[0003] Figure 1 When implementing actual digital circuits, the tested clock frequency must not be higher than the reference clock frequency. When resetting the rising and falling edges of the tested clock, in order to avoid metastable problems, synchronous reset is required. The rising and falling edges of the tested clock are sampled by the reference clock and then the counters in the same clock domain are reset. When the tested clock frequency is higher than the reference clock, sampling the reference clock will inevitably lead to the loss of the tested clock edge and errors. If the counter is reset asynchronously using the rising and falling edges of the tested clock without synchronization, severe and frequent metastable problems will occur, and the actual circuit operation will be abnormal. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a clock detection device, method and chip. By using the embodiments of the present application, the first counter is driven by the tested clock to generate an overflow, and the overflow flag of the first counter clears the second counter, so that it can be determined that there is a tested clock signal. By using the embodiments of the present application, a wider range of clocks can be detected, and it is not necessary to use the related technical solutions (such as Figure 1 Embodiment) requires limiting the measured clock frequency to be lower than the reference clock frequency.

[0005] In a first aspect, an embodiment of the present application provides a clock detection device, the device comprising: a measured clock counter, whose input end is connected to the measured clock and is configured to perform cumulative counting on the rising edge of the measured clock; a reference clock counter, whose input end is connected to the reference clock and is configured to perform cumulative counting on the rising edge of the reference clock; a measured clock counter overflow detection unit, whose input end is connected to the output end of the measured clock counter and whose output end is connected to the reset signal end of the reference clock counter, and is configured to generate a reset signal of the reference clock counter after detecting an overflow of the measured clock counter; and a reference clock counter overflow detection unit, whose input end is connected to the output end of the reference clock counter and is configured to monitor the overflow of the reference clock counter so as to confirm that the measured clock is lost through the overflow of the reference clock counter.

[0006] In some embodiments, the bit width of the measured clock counter is N, and the time length of an overflow of the measured clock counter is: 2 N ×T 被测时钟 , T 被测时钟 is the period of the clock being measured, and N is an integer greater than 1.

[0007] In some embodiments, the measured clock counter overflow detection unit is configured to perform synchronization after L reference clock cycles when an overflow of the measured clock counter is detected, where L is an integer greater than 1.

[0008] In some embodiments, the value of L is 2.

[0009] In some embodiments, the bit width of the reference clock counter is M and the time for the reference clock counter to overflow once is 2 M ×T 参考时钟 , T 参考时钟 is the period of the reference clock, and M is an integer greater than 1.

[0010] In some embodiments, the measured clock counter overflows once and the reference clock counter does not overflow during synchronization of the measured clock counter overflow detection unit.

[0011] In some embodiments, the time when the reference clock counter overflows once satisfies: M ×T 参考时钟 >2+(2 N ×T 被测时钟 ).

[0012] In a second aspect, some embodiments of the present application provide a chip, comprising a device as described in any embodiment of the first aspect.

[0013] In a third aspect, some embodiments of the present application provide a method for clock detection, which runs on a device as described in any one of the embodiments of the first aspect, and the method includes: driving a measured clock counter to overflow through a measured clock and generating an overflow flag; clearing a reference clock counter through the overflow flag; confirming that the measured clock is not lost; driving a reference clock counter to count through a reference clock, and the reference clock counter overflows when it is confirmed that the overflow flag of the measured clock counter is not received; and confirming that the measured clock is lost by confirming that the reference clock counter overflows.

[0014] In some embodiments,

[0015] 2 M ×T 参考时钟 >L+(2 N ×T 被测时钟 )

[0016] Wherein, N is the bit width of the clock counter under test, 2 N ×T 被测时钟 is the time length of an overflow of the clock counter under test, T 被测时钟 is the period of the measured clock, M is the bit width of the reference clock counter, 2 M ×T 参考时钟 is the time when the reference clock counter overflows once, T 参考时钟 is the period of the reference clock, and L is the number of reference clock periods required for synchronization by the measured clock counter overflow detection unit when the measured clock counter overflow is detected. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A clock detection device provided for related technologies;

[0019] Figure 2 A clock detection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0021] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0022] The embodiments of the present application can detect whether there is a clock signal of the clock under test within a wider frequency range by accumulating the count of the clock under test and clearing another counter (i.e., the reference clock counter) when a count overflow flag is detected, without the need to satisfy the restriction that the frequency of the clock under test is not higher than the frequency of the reference clock in order to confirm whether the clock under test exists as in the related art.

[0023] Please see Figure 2 , Figure 2 A clock detection device is provided for an embodiment of the present application. The device includes: a clock counter under test 110, a clock counter under test overflow detection unit 120, a reference clock counter 130 and a reference clock counter overflow detection unit 140.

[0024] The measured clock counter 110 has an input terminal connected to the measured clock and is configured to perform cumulative counting at the rising edge of the measured clock.

[0025] The reference clock counter 130 has an input terminal connected to the reference clock and is configured to perform cumulative counting at the rising edge of the reference clock.

[0026] The measured clock counter overflow detection unit 120 has an input end connected to the output end of the measured clock counter 110 and an output end connected to the reset signal end of the reference clock counter 130, and is configured to generate a reset signal for the reference clock counter 130 after detecting an overflow of the measured clock counter 110.

[0027] The reference clock counter overflow detection unit 140 has an input end connected to the output end of the reference clock counter and is configured to monitor the overflow of the reference clock counter to confirm that the measured clock is lost through the overflow of the reference clock counter.

[0028] It is not difficult to understand that the embodiment of the present application clears another counter (i.e., the reference clock counter) through the cumulative count overflow flag of the measured clock. Even if the measured clock frequency is higher than the reference clock frequency, the clock signal existing in the measured clock can be detected, which can make the measured clock in a wider frequency range, thereby improving the versatility of the technical solution.

[0029] In some embodiments of the present application, the bit width of the measured clock counter 110 is N, and the time length of an overflow of the measured clock counter 110 is: 2 N ×T 被测时钟 , T 被测时钟 is the period of the clock being measured, and N is an integer greater than 1.

[0030] In some embodiments of the present application, the measured clock counter overflow detection unit 120 is configured to synchronize after L reference clock cycles when an overflow of the measured clock counter is detected, where L is an integer greater than 1. For example, in some embodiments of the present application, the value of L is 2.

[0031] In some embodiments of the present application, the bit width of the reference clock counter 130 is M and the time for an overflow of the reference clock counter 130 is 2 M ×T 参考时钟 , T 参考时钟 is the period of the reference clock, and M is an integer greater than 1.

[0032] In some embodiments of the present application, the measured clock counter 110 overflows once and the reference clock counter 130 does not overflow during synchronization of the measured clock counter overflow detection unit 120. For example, in some embodiments of the present application, the time when the reference clock counter overflows once satisfies: M ×T 参考时钟 >2+(2 N ×T 被测时钟 ).

[0033] That is to say, some embodiments of the present application provide a clock detection device, which includes two counters and two overflow detection units, wherein the measured clock counter accumulates and counts at the rising edge of the measured clock, and the reference clock counter accumulates and counts at the rising edge of the reference clock. The measured clock counter overflow detection unit generates a signal to reset the reference clock counter after detecting the overflow of the measured clock counter. If the measured clock is lost and maintains a high level or a low level for a long time without effective flipping, the measured clock counter will not overflow, and the reference clock counter cannot be reset. In this case, the reference clock counter will overflow, and if the overflow of the reference clock counter is detected, it is considered that the measured clock is lost.

[0034] Compared with the prior art, the embodiments of the present application do not require the measured clock frequency to be lower than the reference clock. In some embodiments of the present application, a relatively wide range of measured clocks can be detected according to the different bit width settings of the measured clock counter and the reference clock counter. For example, the clock detection method provided in some embodiments of the present application exemplarily includes: if the bit width of the measured clock counter is designed to be N, the time for the measured clock counter to overflow once is 2 N ×T 被测时钟 ; In order to avoid the metastable problem, the overflow detection unit of the measured clock counter detects the overflow of the measured clock counter and synchronizes it, which requires L (for example, L=2) reference clock cycles; the bit width of the reference clock counter is designed to be M, and the time for an overflow to occur is 2 M ×T 参考时钟 ; During normal operation, when the measured clock counter overflows once and the measured clock counter overflow check unit is synchronized, the reference clock counter cannot overflow, that is, it needs to meet the following conditions: 2 M ×T 参考时钟 >2+(2 N ×T 被测时钟 ), combined with this formula, T 被测时钟 Approximately less than 2 (M-N) ×T 被测时钟 ), that is, the measured clock frequency must be greater than about 1 / 2 (M-N) For example, M=13, N=7, the reference clock is 10 MHZ, and the minimum frequency of the clock under test that can be detected is (10 / 64) MHZ. It can be understood that M=13, N=7 are two optional values. In actual application, appropriate M and N can be selected according to application requirements.

[0035] It is not difficult to understand that compared with the prior art, the embodiments of the present application drive the measured clock counter to overflow through the measured clock, and the overflow flag of the measured clock counter clears the reference clock counter, so that a wider range of measured clocks can be detected without limiting the measured clock frequency to be lower than the reference clock frequency.

[0036] The following is an example of Figure 2 The workflow of the device is:

[0037] In the first step, the bit width of the clock counter under test is set to N, and the bit width of the reference clock counter is set to M, and M>N. According to the frequency range of the clock under test and the frequency of the reference clock, combined with 2 M ×T 参考时钟 >2+(2 N ×T 被测时钟 ) formula and select appropriate M and N.

[0038] In the second step, the initial values ​​of the measured clock counter and the reference clock counter are 0, the measured clock counter accumulates counts under the driving of the measured clock, and the reference clock counter accumulates counts under the driving of the reference clock.

[0039] In the third step, when the measured clock counter overflows, the overflow flag is synchronized with the reference clock and the reference clock counter is cleared.

[0040] In the fourth step, the measured clock counter and the reference clock counter restart counting from 0.

[0041] In the fifth step, if the measured clock is lost and maintains a low level or a high level for a long time, the measured clock counter cannot overflow, and the reference clock counter will overflow. After the overflow is detected, it is determined that the measured clock is lost.

[0042] It should be noted that the overflow flag synchronization operation within the overflow detection of some embodiments of the present application can be adjusted according to design requirements, using different synchronization designs and requiring different clock cycles, which can replace the ordinary two-bit register sampling synchronization design during design.

[0043] Some embodiments of the present application provide a chip, wherein the chip comprises: Figure 2 The clock detection device is shown.

[0044] Some embodiments of the present application provide a clock detection method, which is run on Figure 2 The device shown in the figure, the method includes: driving the measured clock counter to overflow through the measured clock and generating an overflow flag; clearing the reference clock counter through the overflow flag; confirming that the measured clock is not lost; driving the reference clock counter to count through the reference clock, and the reference clock counter overflows when it is confirmed that the overflow flag of the measured clock counter is not received; confirming that the measured clock is lost by confirming that the reference clock counter overflows.

[0045] In some embodiments,

[0046] 2 M ×T 参考时钟 >L+(2 N ×T 被测时钟 )

[0047] Wherein, N is the bit width of the clock counter under test, 2 N ×T 被测时钟 is the time length of an overflow of the clock counter under test, T 被测时钟 is the period of the measured clock, M is the bit width of the reference clock counter, 2 M ×T 参考时钟is the time when the reference clock counter overflows once, T 参考时钟 is the period of the reference clock, and L is the number of reference clock periods required for synchronization by the measured clock counter overflow detection unit when the measured clock counter overflow is detected.

[0048] It should be noted that the implementation details corresponding to this method can be specifically referred to the relevant description in the corresponding device above, and no further details will be given here to avoid repetition.

[0049] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0050] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0051] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0052] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0053] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0054] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A clock detection device, characterized in that: The device comprises: A measured clock counter, whose input terminal is connected to the measured clock and is configured to perform cumulative counting at the rising edge of the measured clock; A reference clock counter, whose input terminal is connected to a reference clock and is configured to perform cumulative counting at a rising edge of the reference clock; A measured clock counter overflow detection unit, the input end of which is connected to the output end of the measured clock counter and the output end of which is connected to the reset signal end of the reference clock counter, and is configured to generate a reset signal of the reference clock counter after detecting that the measured clock counter overflows; the measured clock counter overflow detection unit is configured to synchronize after L reference clock cycles when detecting that the measured clock counter overflows, wherein L is an integer greater than 1; The reference clock counter overflow detection unit has an input end connected to the output end of the reference clock counter and is configured to monitor the overflow of the reference clock counter to confirm that the measured clock is lost through the overflow of the reference clock counter.

2. The device according to claim 1, characterized in that The bit width of the clock counter under test is N, and the time length of an overflow of the clock counter under test is: 2 N ×T 被测时钟 , T 被测时钟 is the period of the clock being measured, and N is an integer greater than 1.

3. The device according to claim 1, characterized in that The value of L is 2.

4. The device according to claim 3, characterized in that The bit width of the reference clock counter is M and the time for the reference clock counter to overflow once is 2 M ×T 参考时钟 , T 参考时钟 is the period of the reference clock, and M is an integer greater than 1.

5. The device according to claim 4, characterized in that The measured clock counter overflows once and the reference clock counter does not overflow during synchronization of the measured clock counter overflow detection unit.

6. The device according to claim 5, characterized in that The time for the reference clock counter to overflow once satisfies: 2 M ×T 参考时钟 >2+(2 N ×T 被测时钟 ).

7. A chip, characterized in that: The chip comprises the device according to any one of claims 1-6.

8. A clock detection method, running on the device according to any one of claims 1 to 6, the method comprising: The measured clock counter is driven to overflow by the measured clock, and an overflow flag is generated; clearing the reference clock counter via the overflow flag; Confirming that the clock under test is not lost; or, The reference clock counter is driven by the reference clock to count, and the reference clock counter overflows when it is confirmed that the overflow flag of the measured clock counter is not received; and the loss of the measured clock is confirmed by confirming that the reference clock counter overflows.

9. The method according to claim 8, characterized in that 2 M ×T 参考时钟 >L+(2 N ×T 被测时钟 ) Wherein, N is the bit width of the clock counter under test, 2 N ×T 被测时钟 is the time length of an overflow of the clock counter under test, T 被测时钟 is the period of the measured clock, M is the bit width of the reference clock counter, 2 M ×T 参考时钟 is the time when the reference clock counter overflows once, T 参考时钟 is the period of the reference clock, and L is the number of reference clock periods required for synchronization by the measured clock counter overflow detection unit when the measured clock counter overflow is detected.