Clock burr detection method, device and equipment and computer readable storage medium
Through the clock glitch detection method based on the frequency-multiplied reference clock signal, the level status of the clock signal to be measured is analyzed, the problem of clock glitch detection in the existing technology is solved, and the efficiency and security of the clock signal system are improved.
Patent Information
- Application Number
- CN202410844767.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-09-03
AI Technical Summary
The existing technology lacks a mature clock glitch detection method, which makes it difficult to accurately monitor the level activity of the clock signal in real time, and cannot resist clock glitch attacks in a timely manner, which reduces the security of the system.
Based on the reference clock signal multiplied by the clock signal under test, determine the reference level state sequence of the clock signal under test, and when triggered on the specified clock edge of the reference clock signal, analyze whether the current level state of the clock signal under test meets the standard , thereby detecting burrs at various cycle stages.
It achieves real-time and accurate detection of clock glitches, improves the security of the clock signal system, and can resist glitch attacks in a timely manner.
Smart Images

Figure CN118590212A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of clock signals, and in particular to a clock glitch detection method, device, equipment and computer-readable storage medium. Background Art
[0002] Fault injection attack is an attack method that introduces faults during the execution of encryption algorithms to obtain key-related information. Among them, clock glitches are a widely used and effective fault injection technology, which injects faults into hardware circuits by tampering with normal clock signals into clock signals with glitches. In order to avoid causing significant losses, it is necessary to detect and identify clock glitches in clock signals. However, there is a lack of a mature clock glitch detection method in the relevant technology, which makes it difficult to monitor the level activity of the clock signal in real time and accurately throughout its life cycle and detect clock glitches, thereby failing to resist the attack of clock glitches in a timely manner, reducing the security of the system where the clock signal is located.
[0003] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve at present. Summary of the invention
[0004] The purpose of the present invention is to provide a clock glitch detection method, device, equipment and computer-readable storage medium, which can determine the reference level state sequence of the clock signal to be measured based on a reference clock signal that is multiplied by the frequency of the clock signal to be measured, and when triggered by a specified clock edge of the reference clock signal, analyze whether the current level state of the clock signal to be measured meets the standard, so that the glitch detection can be achieved in each cycle stage of the clock signal to be measured, and the clock glitch can be detected in real time and accurately, which is conducive to timely resisting the attack of the clock glitch and improving the security of the system where the clock signal is located.
[0005] In order to solve the above technical problems, the present invention provides a clock glitch detection method, comprising:
[0006] Determine a reference level state sequence of the clock signal to be measured, wherein the reference level state sequence includes the level state of the standard clock signal to be measured at the occurrence time of each specified clock edge of the reference clock signal within a single cycle, the reference clock signal has no phase difference with the clock signal to be measured, the frequency is a preset integer multiple of the frequency of the clock signal to be measured, the preset integer is greater than one, and the specified clock edge includes a rising edge and / or a falling edge;
[0007] At the time when any designated clock edge of the reference clock signal occurs, taking the level state corresponding to the current designated clock edge of the reference clock signal in the reference level state sequence as the standard level state;
[0008] At the time when any designated clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is not equal to the standard level state, it is determined that the clock signal to be measured has a glitch.
[0009] On the other hand, at the time when any designated clock edge of the reference clock signal occurs, taking the level state corresponding to the current designated clock edge of the reference clock signal in the reference level state sequence as the standard level state includes:
[0010] At the time when any specified clock edge of the reference clock signal occurs, the level state corresponding to the current cycle phase identifier in the reference level state sequence is used as the standard level state, wherein the cycle phase identifier is used to indicate the cycle phase of the clock signal to be measured in a single cycle;
[0011] The clock glitch detection method further comprises:
[0012] At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to a cycle phase identifier corresponding to the next cycle phase;
[0013] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the cycle phase identifier corresponding to the first cycle phase;
[0014] At the time when any designated clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is not equal to the standard level state, the clock glitch detection is terminated.
[0015] On the other hand, the cycle phase identifier includes a state of the state machine;
[0016] At the time when any specified clock edge of the reference clock signal occurs, the level state corresponding to the current cycle phase identifier in the reference level state sequence is used as the standard level state, including:
[0017] At the time when any designated clock edge of the reference clock signal occurs, the level state corresponding to the current state of the state machine in the reference level state sequence is used as the standard level state;
[0018] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to a cycle phase identifier corresponding to the next cycle phase includes:
[0019] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is not the final state, updating the current state of the state machine to the next state;
[0020] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to the cycle phase identifier corresponding to the first cycle phase includes:
[0021] At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is the final state, the current state of the state machine is updated to the initial state.
[0022] On the other hand, the state machine also includes a waiting state indicating that the clock signal to be measured has not appeared;
[0023] The clock glitch detection method further comprises:
[0024] When starting to test the clock signal to be tested, placing the state machine in a waiting state;
[0025] At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in a waiting state and the current level state of the clock signal to be measured is a high level, the state machine is set to an initial state;
[0026] At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in a waiting state and the current level state of the clock signal to be measured is a low level, the state of the state machine is not updated;
[0027] At the occurrence time of any specified clock edge of the reference clock signal, if the state machine is not in the waiting state and the current level state of the clock signal to be measured is not equal to the standard level state, the state machine is reset to the waiting state.
[0028] On the other hand, the clock glitch detection method further includes:
[0029] In response to the state read instruction, the current state of the state machine is pushed.
[0030] On the other hand, the clock glitch detection method further includes:
[0031] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, it is determined that there is no burr in the clock signal to be measured;
[0032] In response to the status reading instruction, obtaining the latest determination result of whether the clock signal to be tested has a burr;
[0033] The determination result is pushed.
[0034] On the other hand, after determining that the clock signal to be tested has a glitch, the clock glitch detection method includes:
[0035] Set the glitch indication signal to high level;
[0036] After determining that the clock signal to be measured does not have a glitch, setting the glitch indication signal to a low level;
[0037] In response to the status reading instruction, obtaining the latest determination result of whether the clock signal to be tested has a glitch includes:
[0038] In response to the status reading instruction, the latest glitch indication signal is acquired.
[0039] In order to solve the above technical problems, the present invention further provides a clock glitch detection device, comprising:
[0040] A first determination module is used to determine a reference level state sequence of the clock signal to be measured, wherein the reference level state sequence includes the level state of the standard clock signal to be measured at the occurrence time of each specified clock edge of the reference clock signal within a single cycle, the reference clock signal has no phase difference with the clock signal to be measured, the frequency is a preset integer multiple of the frequency of the clock signal to be measured, the preset integer is greater than one, and the specified clock edge includes a rising edge and / or a falling edge;
[0041] A second determining module is used for taking, at the time when any designated clock edge of the reference clock signal occurs, a level state in the reference level state sequence corresponding to the current designated clock edge of the reference clock signal as a standard level state;
[0042] The first determination module is used to determine that a glitch exists in the clock signal to be measured if the current level state of the clock signal to be measured is not equal to the standard level state at the time when any specified clock edge of the reference clock signal occurs.
[0043] In order to solve the above technical problems, the present invention further provides a clock glitch detection device, comprising:
[0044] Memory for storing computer programs;
[0045] A processor is used to implement the steps of the clock glitch detection method as described above when executing the computer program.
[0046] In order to solve the above technical problem, the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the clock glitch detection method described above are implemented.
[0047] Beneficial effect: The present invention provides a clock glitch detection method. Considering that the standard clock signal is a periodic and edge-sensitive signal, as long as the position of the current clock edge is determined, the position of the next clock edge can be predicted. Therefore, the level state of the standard clock signal in each stage is determined and cyclical. If the level state of the clock signal to be measured in each stage meets the standard, it can be determined that there is no glitch. Therefore, the present invention can determine the reference level state sequence of the clock signal to be measured based on the reference clock signal that is multiplied by the clock signal to be measured, and when triggered by the specified clock edge of the reference clock signal, analyze whether the current level state of the clock signal to be measured meets the standard, so that the glitch detection can be achieved in each periodic stage of the clock signal to be measured, and the clock glitch can be detected in real time and accurately, which is conducive to timely resisting the attack of the clock glitch and improving the security of the system where the clock signal is located.
[0048] The present invention also provides a clock glitch detection device, equipment and computer-readable storage medium, which have the same beneficial effects as the above clock glitch detection method. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the relevant technologies and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0050] Figure 1 A schematic diagram of a flow chart of a clock glitch detection method provided by the present invention;
[0051] Figure 2 A state transition diagram of a state machine provided by the present invention;
[0052] Figure 3A schematic diagram of detecting a glitch-free clock signal provided by the present invention;
[0053] Figure 4 A schematic diagram of detecting a glitch-prone clock signal provided by the present invention;
[0054] Figure 5 A schematic structural diagram of a clock glitch detection device provided by the present invention;
[0055] Figure 6 A schematic diagram of the structure of a clock glitch detection device provided by the present invention;
[0056] Figure 7 A schematic diagram of the structure of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION
[0057] The core of the present invention is to provide a clock glitch detection method, device, equipment and computer-readable storage medium, which can determine the reference level state sequence of the clock signal to be measured based on a reference clock signal that is multiplied by the frequency of the clock signal to be measured, and when triggered by the specified clock edge of the reference clock signal, analyze whether the current level state of the clock signal to be measured meets the standard, so that the glitch detection can be achieved in each cycle stage of the clock signal to be measured, and the clock glitch can be detected in time and accurately, which is conducive to timely resisting the attack of the clock glitch and improving the security of the system where the clock signal is located.
[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] Please refer to Figure 1 , Figure 1 A schematic flow chart of a clock glitch detection method provided by the present invention, the clock glitch detection method comprising:
[0060] S101: Determine a reference level state sequence of a clock signal to be measured, wherein the reference level state sequence includes the level state of a standard clock signal to be measured at the occurrence time of each specified clock edge of the reference clock signal within a single cycle, the reference clock signal has no phase difference with the clock signal to be measured, the frequency is a preset integer multiple of the frequency of the clock signal to be measured, the preset integer is greater than one, and the specified clock edge includes a rising edge and / or a falling edge;
[0061] Specifically, taking into account the technical problems in the above background technology, and considering that the period of the glitch clock is usually shorter than the period of the conventional clock signal, and the level state of the conventional clock signal in each stage is determined, therefore, if the level state of the clock signal to be measured in each stage meets the standard, it can be determined that there is no glitch. Therefore, based on the above ideas, in an embodiment of the present invention, the level state of the clock signal to be measured is analyzed in stages to detect clock glitches.
[0062] Specifically, considering that the specified clock edge of the reference clock signal that has no phase difference with the clock signal to be measured and is a multiple of the clock signal to be measured can be efficiently and conveniently triggered multiple times within a single cycle of the clock signal to be measured, thereby conducting an analysis of the multi-stage level states within a single cycle of the clock signal to be measured, the embodiment of the present invention can first determine a reference clock signal that meets the preset conditions, that is, a reference clock signal that is homologous to the clock signal to be measured and has no phase difference, and a frequency that is a preset integer multiple of the frequency of the clock signal to be measured, so as to use it as the data basis for subsequent steps.
[0063] The reference clock signal may be obtained in a variety of ways, such as being generated in real time, being prepared in advance, or being directly received from other sources for use, etc., and the embodiments of the present invention do not limit this.
[0064] Specifically, the reference clock signal may be of the same source as the clock signal to be measured, so that a reference clock signal having no phase difference with the clock signal to be measured and having a frequency multiple of the clock signal to be measured can be obtained conveniently and quickly.
[0065] Among them, the preset integer can be set independently, for example, it can be set to any one of 2 to 8, etc. Different preset integers determine different burr detection accuracy. The larger the preset integer, the higher the burr detection accuracy. The embodiment of the present invention is not limited here.
[0066] Specifically, considering that the purpose of the embodiment of the present invention is to analyze the level state of the clock signal to be measured under the triggering of the specified clock edge of the reference clock signal, in order to achieve this purpose, it is necessary to determine the "standard level state" used for reference when analyzing the level state of the clock signal to be measured. Therefore, in the embodiment of the present invention, the level state of the standard clock signal to be measured at the time when each specified clock edge of the reference clock signal occurs within a single cycle can be determined, and used as a reference level state sequence. Since each level state in the reference level state sequence belongs to the level state of the "standard clock signal to be measured", and the "standard clock signal to be measured" refers to the clock signal to be measured without glitches, each level state in the reference level state sequence can be used as a "standard level state" for reference when analyzing the level state of the clock signal to be measured.
[0067] Among them, each level state in the reference level state sequence corresponds one-to-one to a specified clock edge of the reference clock signal. The level state usually includes a high level and a low level. The high level and the low level are relative. For example, when the high level is 1, the low level is 0.
[0068] S102: At the time when any designated clock edge of the reference clock signal occurs, taking the level state corresponding to the current designated clock edge of the reference clock signal in the reference level state sequence as the standard level state;
[0069] Specifically, based on the above principle of determining the reference level state sequence, the standard level state of the clock signal to be measured corresponding to each specified clock edge of the reference clock signal can be known. Therefore, in the detection process, at the occurrence moment of any specified clock edge of the reference clock signal, the level state corresponding to the current specified clock edge of the reference clock signal in the reference level state sequence is used as the standard level state, so as to use it as the data basis for subsequent steps.
[0070] S103: At the time when any designated clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is not equal to the standard level state, it is determined that a glitch exists in the clock signal to be measured.
[0071] Specifically, in the process of being triggered by the specified clock edge of the reference clock signal to realize the detection of the level state of the clock signal to be measured, on the one hand, the level state of the clock signal to be measured at the triggering moment (that is, the occurrence moment of the specified clock edge) can be determined, and on the other hand, the standard level state corresponding to the current specified clock edge of the reference clock signal can be determined, and then the two can be compared. Since the injection of glitches will cause an abnormal mutation in the level state of the clock signal to be measured, the level state of the clock signal to be measured will not be equal to the standard level state when glitches exist. Therefore, in this step: at the occurrence moment of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is not equal to the standard level state, it is determined that the clock signal to be measured has glitches.
[0072] In addition, it is worth mentioning that the appearance of glitches may cause a sudden change in the level state of the clock signal to be measured, for example, causing the clock signal to be measured to suddenly change from a normal high level state to a low level state, or from a normal low level state to a high level state, thereby affecting the period length of the clock signal to be measured, that is, the appearance of glitches may cause the period of the clock signal to be measured to become longer than the standard period, or may cause the period of the clock signal to be measured to become shorter than the standard period.
[0073] The present invention provides a clock glitch detection method. Considering that the level state of a standard clock signal at each stage is determined, if the level state of a clock signal to be tested at each stage meets the standard, it can be determined that there is no glitch. Therefore, the present invention can determine a reference level state sequence of the clock signal to be tested based on a reference clock signal that is multiplied by the frequency of the clock signal to be tested, and when triggered by a specified clock edge of the reference clock signal, analyze whether the current level state of the clock signal to be tested meets the standard, thereby realizing glitch detection in each cycle stage of the clock signal to be tested, and can detect clock glitches in real time and accurately, which is conducive to timely resisting the attack of clock glitches and improving the security of the system where the clock signal is located.
[0074] Based on the above embodiments:
[0075] As an optional embodiment, at the time when any specified clock edge of the reference clock signal occurs, the level state corresponding to the current specified clock edge of the reference clock signal in the reference level state sequence is used as the standard level state, including:
[0076] At the occurrence time of any specified clock edge of the reference clock signal, the level state corresponding to the current cycle phase identifier in the reference level state sequence is used as the standard level state, wherein the cycle phase identifier is used to indicate the cycle phase of the clock signal to be measured in a single cycle;
[0077] The clock glitch detection method also includes:
[0078] At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the cycle phase identifier corresponding to the next cycle phase;
[0079] At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the cycle phase identifier corresponding to the first cycle phase;
[0080] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is not equal to the standard level state, the clock glitch detection is terminated.
[0081] Specifically, in order to quickly and accurately find the level state corresponding to the current specified clock edge of the reference clock signal in the reference level state sequence, considering that each level state in the reference level state sequence itself has an identifier corresponding to the order, and in order to correspond the "specified clock edge of the reference clock signal" with the "level state in the reference level state sequence", a cycle stage identifier can be established to determine which stage of the clock signal cycle to be measured the current specified clock edge of the reference clock signal belongs to, thereby quickly and accurately determining the "level state corresponding to the current specified clock edge of the reference clock signal" in the reference level state sequence. Therefore, in the process of "being triggered by the specified clock edge of the reference clock signal for clock glitch detection", the embodiment of the present invention can update and maintain a "cycle stage identifier" to indicate which stage the analysis of the clock signal to be measured has reached, thereby facilitating real-time determination of the standard level state corresponding to the current specified clock edge of the reference clock signal.
[0082] Specifically, the basis for updating and maintaining the cycle phase identifier is that each designated clock edge of the reference clock signal in a single cycle of the clock signal to be measured has a corresponding cycle phase identifier. Therefore, the cycle phase identifier can be updated according to the "detection progress of the level state of the clock signal to be measured", that is, when a certain "cycle phase" of a single cycle of the clock signal to be measured is detected, the cycle phase identifier is updated to the cycle phase identifier corresponding to the "cycle phase" detected at that time. Therefore, in the embodiment of the present invention, it is possible to: (1) at the time when any designated clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the next (1) At the occurrence of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the cycle phase identifier corresponding to the first cycle phase (so as to perform level state detection on the first cycle phase of the next cycle of the clock signal to be measured); (2) At the occurrence of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the cycle phase identifier corresponding to the first cycle phase (so as to perform level state detection on the first cycle phase of the next cycle of the clock signal to be measured); (3) At the occurrence of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is not equal to the standard level state, the clock glitch detection is terminated (at this time, the glitch detection of the clock signal to be measured can be restarted).
[0083] As an optional embodiment, the cycle phase identifier includes a state of the state machine;
[0084] At the occurrence time of any specified clock edge of the reference clock signal, the level state corresponding to the current cycle phase identifier in the reference level state sequence is used as the standard level state including:
[0085] At the occurrence time of any specified clock edge of the reference clock signal, the level state corresponding to the current state of the state machine in the reference level state sequence is used as the standard level state;
[0086] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to the cycle phase identifier corresponding to the next cycle phase includes:
[0087] At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is not the final state, the current state of the state machine is updated to the next state;
[0088] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to the cycle phase identifier corresponding to the first cycle phase includes:
[0089] At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is the final state, the current state of the state machine is updated to the initial state.
[0090] Specifically, considering that each state of the state machine can represent each cycle stage identifier respectively, and the state of the state machine can accurately indicate the stage of the clock signal to be measured in the current cycle, the cycle stage identifier can be identified by the state of the state machine in an embodiment of the present invention. In this case, the update of the cycle stage identifier is actually the update of the state machine state. In this case, there is a one-to-one correspondence between the state of the state machine and the level state in the reference level state sequence. Therefore, in an embodiment of the present invention, at the time of occurrence of any specified clock edge of the reference clock signal, the level state in the reference level state sequence corresponding to the current state of the state machine can be used as the standard level state.
[0091] Specifically, when the level state of each cycle stage of the clock signal to be measured is analyzed by triggering the specified clock edge of the reference clock signal, if the current level state is equal to the standard level state, it is necessary to update the state of the state machine (the next cycle stage is represented by the state of the state machine, so that the standard level state of the next cycle stage can be determined when the next specified clock edge is triggered), if the current level state is not equal to the standard level state, the operation of the clock signal to be measured can be terminated and restarted, and each cycle stage identifier represents a cycle stage within the same cycle of the clock signal to be measured. Therefore, in an embodiment of the present invention, at the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is not the final state, the current state of the state machine is updated to the next state, and at the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is the final state, the current state of the state machine is updated to the initial state, thereby cyclically realizing the representation of the cycle stage within each cycle of the clock signal to be measured.
[0092] When the current level state of the clock signal to be measured is not equal to the standard level state, the operation of the clock signal to be measured can be terminated and restarted, and the corresponding clock glitch detection work also needs to be restarted.
[0093] As an optional embodiment, the state machine further includes a waiting state indicating that the clock signal to be measured does not appear;
[0094] The clock glitch detection method also includes:
[0095] When starting to test the clock signal to be tested, the state machine is placed in a waiting state;
[0096] At the occurrence time of any specified clock edge of the reference clock signal, if the state machine is in the waiting state and the current level state of the clock signal to be measured is a high level, the state machine is set to the initial state;
[0097] At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in the waiting state and the current level state of the clock signal to be measured is a low level, the state of the state machine is not updated;
[0098] At the occurrence time of any specified clock edge of the reference clock signal, if the state machine is not in the waiting state and the current level state of the clock signal to be measured is not equal to the standard level state, the state machine is reset to the waiting state.
[0099] Specifically, considering that when the clock glitch detection is just started and the clock signal to be measured has not yet appeared, this time does not belong to any cycle stage of the clock signal to be measured. In order to accurately characterize this period through the state machine, in the embodiment of the present invention, when the clock signal to be measured is started to be tested, the state machine can be set to a waiting state. At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in the waiting state and the current level state of the clock signal to be measured becomes a high level, the state machine is synchronously set to the initial state. At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in the waiting state and the current level state of the clock signal to be measured is a low level, the state of the state machine is not updated and is always maintained in the waiting state, thereby accurately displaying the state of the clock glitch detection starting but the clock signal to be measured not appearing through the state machine.
[0100] As an optional embodiment, the clock glitch detection method further includes:
[0101] In response to the state read instruction, the current state of the state machine is pushed.
[0102] Specifically, in order to facilitate the staff to promptly know the current cycle stage of the clock signal to be measured, the embodiment of the present invention can also respond to the status read instruction and push the current state of the state machine. In this way, the staff can query the current state of the state machine (that is, the current cycle stage of the clock signal to be measured) by issuing the status read instruction.
[0103] As an optional embodiment, the clock glitch detection method further includes:
[0104] At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, it is determined that there is no glitch in the clock signal to be measured;
[0105] In response to the status reading instruction, obtaining the latest determination result of whether the clock signal to be tested has a burr;
[0106] Push the judgment result.
[0107] Specifically, in order to fully know whether there are glitches in the clock signal to be measured at present, in an embodiment of the present invention, at the time of occurrence of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, it is determined that there are no glitches in the clock signal to be measured. In addition, in order to facilitate the staff to promptly know the "latest determination result on whether there are glitches in the clock signal to be measured", in an embodiment of the present invention, it is also possible to respond to a status read instruction, obtain the latest determination result on whether there are glitches in the clock signal to be measured, and push the determination result.
[0108] As an optional embodiment, after determining that a glitch exists in the clock signal to be tested, the clock glitch detection method includes:
[0109] Set the glitch indication signal to high level;
[0110] After determining that the clock signal to be tested does not have a glitch, setting the glitch indication signal to a low level;
[0111] In response to the status reading instruction, obtaining the latest determination result of whether the clock signal to be tested has a glitch includes:
[0112] In response to the status read instruction, the latest glitch indication signal is acquired.
[0113] Specifically, considering that the high and low level states of a specific signal can efficiently and accurately indicate whether the clock signal to be measured has glitches, a glitch indication signal is provided in an embodiment of the present invention, and the glitch indication signal can be set to a high level after determining that the clock signal to be measured has glitches, and can be set to a low level after determining that the clock signal to be measured does not have glitches. This can efficiently and quickly indicate the "latest determination result on whether the clock signal to be measured has glitches", so that the glitch detection result can be simply and quickly obtained through a status read instruction, thereby timely pushing the current state of the state machine.
[0114] To better illustrate the embodiments of the present invention, please refer to Figures 2 to 4 , Figure 2 A state transition diagram of a state machine provided by the present invention; Figure 3 A schematic diagram of detecting a glitch-free clock signal provided by the present invention; Figure 4 A schematic diagram of detecting a glitch-containing clock signal provided by the present invention.
[0115] Specifically, Figure 2 Where n is a positive integer, that is, the frequency of the reference clock signal is a preset integer (n) times the frequency of the clock signal to be measured, clk_in is the clock signal to be measured, error is the glitch indication signal, Figure 2 All the values on the left side of " / " in the table represent the level state of the clock signal clk_in to be tested, and the values on the right side of " / " represent the level state of the glitch indication signal error. S0 to S2n are the states of the state machine in a cycle of a standard clock signal to be tested. S0 is the waiting state, S1 is the initial state, and S2n is the final state. Figure 2It can be seen that in the S0 state, if the level state of the clock signal clk_in to be measured is 0, and the level state of the glitch indication signal is set to 0, if the clock signal clk_in to be measured is always at a low level, the state machine state is not changed; if the level state of the clock signal clk_in to be measured is 1, the state machine state is set to S1, and the level state of the glitch indication signal is set to 0; similarly, in the S1 state, if the level state of the clock signal clk_in to be measured is 0, the level state of the glitch indication signal is set to 1, and the state machine state is reset to S0 (the clock glitch detection of the clock signal to be measured can be restarted), if the level state of the clock signal clk_in to be measured is 1, the level state of the glitch indication signal is set to 0, and the state machine state is updated to S2, and so on. The intermediate state machine state update and the update of the glitch indication signal are not further described here. According to the periodic level change of the standard clock signal to be measured, in the Sn state, if the level state of the clock signal clk_in to be measured is 1 (that is, the clock signal clk_in to be measured continues to maintain a high level abnormally), the level state of the glitch indication signal is set to 1, and the state machine state is reset to S0. If the level state of the clock signal clk_in to be measured is 0, the state machine state is updated to Sn+1; however, in the S2n state, if the level state of the clock signal clk_in to be measured is 0 (that is, the clock signal clk_in to be measured continues to maintain a low level abnormally), the level state of the glitch indication signal is set to 1, and the state machine state is reset to S0. If the level state of the clock signal clk_in to be measured is 1 (that is, the level of the clock signal clk_in to be measured changes from 0 to 1), the level state of the glitch indication signal is set to 0, and the state machine state is updated to S1. In summary, each state of the state machine represents each cycle stage identifier, and the state of the state machine can accurately indicate the stage of the clock signal to be measured in the current cycle, so that the state of the state machine is corresponded one by one to the level state in the reference level state sequence, and the level state of the clock signal to be measured in the entire cycle can be monitored in real time. The glitch detection result can be characterized in real time by setting the glitch indication signal synchronously, which can improve the efficiency and flexibility of detecting the glitch signal, and at the same time, the duty cycle of the clock signal to be measured can be detected, and the duty cycle information of the clock signal to be measured can be provided for subsequent algorithm encryption.
[0116] Specifically, Figure 3 and Figure 4 CP in the figure refers to the reference clock signal, and st_clk refers to the state machine. The period of the standard clock to be tested is 8, so st_clk includes 9 states 0-8, which correspond to Figure 2 S0-S8 in Figure 3 and Figure 4 The "S" is hidden in Figure 30 to 23 after the reference clock signal CP in Figure 4 The 0 to 22 after the reference clock signal CP in the reference clock signal refers to the specified clock edge of the reference clock signal (in Figure 2 The serial number of the rising edge is shown in the figure.
[0117] Specifically, Figure 3 There is no glitch in the clock signal to be tested, so the state machine continues to cycle from 0 to 8, and the glitch indication signal is always at a low level; Figure 4 The clock signal to be measured has a glitch at the third "reference clock signal cycle" after the clock signal to be measured appears, so the glitch indication signal becomes a high level at the third "reference clock signal cycle" after the clock signal to be measured appears, and the clock signal to be measured is reset. Therefore, the state machine is set to the waiting state S0 at the third "reference clock signal cycle" after the clock signal to be measured appears.
[0118] Of course, in addition to this specific form, the “latest determination result on whether the clock signal to be measured has glitches” may also be indicated in other forms, which are not limited in the embodiment of the present invention.
[0119] Please refer to Figure 5 , Figure 5 A schematic diagram of the structure of a clock glitch detection device provided by the present invention, the clock glitch detection device comprises:
[0120] A first determination module 51 is used to determine a reference level state sequence of the clock signal to be measured, wherein the reference level state sequence includes the level state of the standard clock signal to be measured at the occurrence time of each specified clock edge of the reference clock signal within a single cycle, the reference clock signal has no phase difference with the clock signal to be measured, the frequency is a preset integer multiple of the frequency of the clock signal to be measured, the preset integer is greater than one, and the specified clock edge includes a rising edge and / or a falling edge;
[0121] A second determining module 52 is used for, at the time when any designated clock edge of the reference clock signal occurs, taking the level state corresponding to the current designated clock edge of the reference clock signal in the reference level state sequence as the standard level state;
[0122] The first determination module 53 is used to determine that a glitch exists in the clock signal to be measured if the current level state of the clock signal to be measured is not equal to the standard level state at the occurrence time of any specified clock edge of the reference clock signal.
[0123] For an introduction to the clock glitch detection device provided in an embodiment of the present invention, please refer to the aforementioned embodiment of the clock glitch detection method, and the embodiment of the present invention will not be described in detail here.
[0124] Please refer to Figure 6 , Figure 6 A schematic diagram of the structure of a clock glitch detection device provided by the present invention, the clock glitch detection device comprises:
[0125] A memory 61, used for storing computer programs;
[0126] The processor 62 is used to implement the steps of the clock glitch detection method in the above embodiment when executing the computer program.
[0127] For an introduction to the clock glitch detection device provided in an embodiment of the present invention, please refer to the aforementioned embodiment of the clock glitch detection method, and the embodiment of the present invention will not be described in detail here.
[0128] Please refer to Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer-readable storage medium provided by the present invention. A computer program 71 is stored on the computer-readable storage medium 70. When the computer program 71 is executed by the processor 62, the steps of the clock glitch detection method in the aforementioned embodiment are implemented.
[0129] For an introduction to the computer-readable storage medium provided in an embodiment of the present invention, please refer to the aforementioned embodiment of the clock glitch detection method, and the embodiment of the present invention will not be described in detail here.
[0130] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should also be noted that in this specification, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the element.
[0131] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A clock glitch detection method, It is characterized in that include: Determine a reference level state sequence of the clock signal to be measured, wherein the reference level state sequence includes the level state of the standard clock signal to be measured at the occurrence time of each specified clock edge of the reference clock signal within a single cycle, the reference clock signal has no phase difference with the clock signal to be measured, the frequency is a preset integer multiple of the frequency of the clock signal to be measured, the preset integer is greater than one, and the specified clock edge includes a rising edge and / or a falling edge; At the time when any designated clock edge of the reference clock signal occurs, taking the level state corresponding to the current designated clock edge of the reference clock signal in the reference level state sequence as the standard level state; At the time when any designated clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is not equal to the standard level state, it is determined that the clock signal to be measured has a glitch.
2. The clock glitch detection method according to claim 1, It is characterized in that At the time when any designated clock edge of the reference clock signal occurs, taking the level state corresponding to the current designated clock edge of the reference clock signal in the reference level state sequence as the standard level state includes: At the time when any specified clock edge of the reference clock signal occurs, the level state corresponding to the current cycle phase identifier in the reference level state sequence is used as the standard level state, wherein the cycle phase identifier is used to indicate the cycle phase of the clock signal to be measured in a single cycle; The clock glitch detection method further comprises: At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to a cycle phase identifier corresponding to the next cycle phase; At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, the current cycle phase identifier is updated to the cycle phase identifier corresponding to the first cycle phase; At the time when any designated clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is not equal to the standard level state, the clock glitch detection is terminated.
3. The clock glitch detection method according to claim 2, It is characterized in that The cycle phase identifier includes the state of the state machine; At the time when any specified clock edge of the reference clock signal occurs, the level state corresponding to the current cycle phase identifier in the reference level state sequence is used as the standard level state, including: At the time when any designated clock edge of the reference clock signal occurs, the level state corresponding to the current state of the state machine in the reference level state sequence is used as the standard level state; At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier does not correspond to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to a cycle phase identifier corresponding to the next cycle phase includes: At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is not the final state, updating the current state of the state machine to the next state; At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, and the current cycle phase identifier corresponds to the last cycle phase of the clock signal to be measured, updating the current cycle phase identifier to the cycle phase identifier corresponding to the first cycle phase includes: At the occurrence time of any specified clock edge of the reference clock signal, if the current level state of the clock signal to be measured is equal to the standard level state, and the current state of the state machine is the final state, the current state of the state machine is updated to the initial state.
4. The clock glitch detection method according to claim 3, It is characterized in that The state machine also includes a waiting state indicating that the clock signal to be measured has not appeared; The clock glitch detection method further comprises: When starting to test the clock signal to be tested, placing the state machine in a waiting state; At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in a waiting state and the current level state of the clock signal to be measured is a high level, the state machine is set to an initial state; At the time when any specified clock edge of the reference clock signal occurs, if the state machine is in a waiting state and the current level state of the clock signal to be measured is a low level, the state of the state machine is not updated; At the occurrence time of any specified clock edge of the reference clock signal, if the state machine is not in the waiting state and the current level state of the clock signal to be measured is not equal to the standard level state, the state machine is reset to the waiting state.
5. The clock glitch detection method according to claim 4, It is characterized in that The clock glitch detection method further comprises: In response to the state read instruction, the current state of the state machine is pushed.
6. The clock glitch detection method according to any one of claims 1 to 5, It is characterized in that The clock glitch detection method further comprises: At the time when any specified clock edge of the reference clock signal occurs, if the current level state of the clock signal to be measured is equal to the standard level state, it is determined that there is no burr in the clock signal to be measured; In response to the status reading instruction, obtaining the latest determination result of whether the clock signal to be tested has a burr; The determination result is pushed.
7. The clock glitch detection method according to claim 6, It is characterized in that After determining that the clock signal to be tested has a glitch, the clock glitch detection method includes: Set the glitch indication signal to high level; After determining that the clock signal to be measured does not have a glitch, setting the glitch indication signal to a low level; In response to the status reading instruction, obtaining the latest determination result of whether the clock signal to be tested has a glitch includes: In response to the status reading instruction, the latest glitch indication signal is acquired.
8. A clock glitch detection device, It is characterized in that include: A first determination module is used to determine a reference level state sequence of the clock signal to be measured, wherein the reference level state sequence includes the level state of the standard clock signal to be measured at the occurrence time of each specified clock edge of the reference clock signal within a single cycle, the reference clock signal has no phase difference with the clock signal to be measured, the frequency is a preset integer multiple of the frequency of the clock signal to be measured, the preset integer is greater than one, and the specified clock edge includes a rising edge and / or a falling edge; A second determining module is used for taking, at the time when any designated clock edge of the reference clock signal occurs, a level state in the reference level state sequence corresponding to the current designated clock edge of the reference clock signal as a standard level state; The first determination module is used to determine that a glitch exists in the clock signal to be measured if the current level state of the clock signal to be measured is not equal to the standard level state at the time when any specified clock edge of the reference clock signal occurs.
9. A clock glitch detection device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the clock glitch detection method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the clock glitch detection method according to any one of claims 1 to 7 are implemented.
