Chip frequency anomaly detection method and system and storage medium
By obtaining the working frequency of the chip's external clock and the parameters of the frequency sensor, determining the alarm threshold and enabling the frequency sensor, the problem of low frequency detection accuracy in the existing technology is solved, and the accuracy and safety of the chip frequency detection are improved.
Patent Information
- Application Number
- CN202410729399.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-08-27
AI Technical Summary
The ring oscillation frequency of the existing chip frequency detection unit is easily affected by temperature, voltage and production process, resulting in a decrease in frequency detection accuracy, making it difficult to effectively detect frequency abnormalities of the chip.
By obtaining the expected and actual working frequency of the chip's external clock, as well as the frequency division coefficient and frequency detection accuracy of the frequency sensor, the alarm threshold of the frequency sensor is determined, and the frequency sensor is enabled to divide and count the chip's external clock to determine the chip's external clock. Check whether the working frequency is abnormal to determine the frequency status of the chip's internal clock.
It improves the frequency detection accuracy of chips, especially security chips, reduces false alarms, enhances the ability to monitor external clock frequency abnormalities, and ensures the safety of the chip.
Smart Images

Figure CN118549797A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of integrated circuits, and in particular relates to a chip frequency anomaly detection method, system and storage medium. Background Art
[0002] Chips are widely used in defense, finance, medical treatment, transportation and other fields. Chip security is directly related to the reliability of these fields. Therefore, targeted protection measures need to be taken to ensure the security of chips. When a chip is attacked, its frequency may be abnormal. The security chip password detection guidelines (GMT 0008-2012) put forward requirements for chips: when the chip performs a certain cryptographic algorithm operation, change the chip environment. When the frequency exceeds or falls below the frequency threshold declared by the chip, trigger the alarm interrupt of the corresponding sensor, and determine whether an alarm has occurred based on the action of the interrupt processing function. Therefore, by detecting the frequency of the chip, an alarm can be generated when the frequency exceeds or falls below the frequency threshold of the chip, which can effectively detect the frequency state of the chip and identify and protect against external physical attacks to a certain extent.
[0003] The patent application with application publication number CN101968840A discloses a chip anti-attack method based on voltage detection and frequency detection, and discloses storing the core data of the normal operation of the chip in a non-volatile memory; monitoring the external clock input through a frequency detection unit, once the input clock frequency is abnormal, the frequency detection unit responds to the abnormality and transmits the response result to the CPU main control unit; after the CPU main control unit receives the abnormal response of the frequency detection unit and the voltage detection unit, it controls the entire chip through the anti-attack unit to implement the protection of the core data inside the chip. However, the ring oscillator in the frequency detection unit of the above patent application will be affected by the temperature, voltage and / or production process of the chip and produce deviations, resulting in certain differences in the ring oscillator frequency between chips, which will affect the accuracy of frequency detection to a certain extent. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present invention provides a chip frequency anomaly detection method, which can detect the chip external clock operating frequency, and then facilitate determining whether the chip frequency is abnormal according to the chip external clock frequency detection result, thereby improving the frequency detection accuracy of the chip, especially the security chip.
[0005] In a first aspect, the present invention provides a method for detecting abnormal operating frequency of a chip external clock, comprising:
[0006] Obtaining the expected operating frequency of the chip's external clock, the expected operating frequency of the chip's internal clock, the frequency division coefficient of the frequency sensor, and the frequency detection accuracy of the frequency sensor;
[0007] Determine a first low-frequency alarm threshold and a first high-frequency alarm threshold of the frequency sensor according to an expected operating frequency of the chip external clock, an expected operating frequency of the chip internal clock, a frequency division coefficient of the frequency sensor, and a frequency detection accuracy of the frequency sensor;
[0008] Get the actual operating frequency of the chip's external clock;
[0009] Determine the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor;
[0010] Determine a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock;
[0011] Whether the operating frequency of the chip external clock is abnormal is determined according to the second low frequency alarm threshold and the second high frequency alarm threshold of the frequency sensor.
[0012] Optionally, determining a first low-frequency alarm threshold and a first high-frequency alarm threshold of the frequency sensor according to an expected operating frequency of an external chip clock, an expected operating frequency of an internal chip clock, a frequency division coefficient of the frequency sensor, and a frequency detection accuracy of the frequency sensor includes:
[0013] The first low-frequency alarm threshold L1 and the first high-frequency alarm threshold H1 of the frequency sensor are calculated according to the following formula:
[0014] ;
[0015] Among them, d is the frequency division coefficient of the frequency sensor; f1 is the expected operating frequency of the chip internal clock; F1 is the expected operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor.
[0016] Optionally, determining the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor includes:
[0017] Calculate the actual operating frequency f2 of the chip's internal clock according to the following formula:
[0018] ;
[0019] Among them, F2 is the actual operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor; d is the frequency division coefficient of the frequency sensor; L1 is the first low-frequency alarm threshold of the frequency sensor.
[0020] Optionally, determining the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor includes:
[0021] Calculate the actual operating frequency f2 of the chip's internal clock according to the following formula:
[0022] ;
[0023] Among them, F2 is the actual operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor; d is the frequency division coefficient of the frequency sensor; H1 is the first high-frequency alarm threshold of the frequency sensor.
[0024] Optionally, determining a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock includes:
[0025] The second low frequency alarm threshold L2 and the second high frequency alarm threshold H2 of the frequency sensor are calculated according to the following formula:
[0026] ;
[0027] Wherein, d is the frequency division coefficient of the frequency sensor; f2 is the actual operating frequency of the chip internal clock; and F1 is the expected operating frequency of the chip external clock.
[0028] Optionally, determining whether the operating frequency of the chip external clock is abnormal according to a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor includes:
[0029] Enable frequency sensor;
[0030] After the frequency sensor is enabled, the chip external clock is divided to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain;
[0031] Count the length of a single pulse of div_clk to obtain the number of cycles cnt of the chip internal clock contained in the length of a single pulse of div_clk;
[0032] According to the cycle number cnt, it is determined that the operating frequency of the chip external clock is abnormal.
[0033] Optionally, determining whether the operating frequency of the chip external clock is abnormal according to a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor includes:
[0034] Delaying the enable signal of the frequency sensor by two clock cycles in the chip internal clock domain, detecting the rising edge of the enable signal after the delay of two clock cycles, and enabling the frequency sensor at the rising edge of the enable signal;
[0035] And / or, after the frequency sensor is enabled, a counter is used to start counting at the rising edge of each chip external clock, and when the count reaches a preset frequency division coefficient, the clock after the chip external clock is divided is flipped and the counter is reset to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain;
[0036] And / or, in the chip internal clock domain, detecting the rising edge and falling edge of div_clk, setting a counter, using the chip internal clock to count the length of a single pulse of div_clk, and obtaining the number of cycles cnt of the chip internal clock included in the length of a single pulse of div_clk;
[0037] And / or, when cnt is greater than the second low-frequency alarm threshold or cnt is less than the second high-frequency alarm threshold, it is determined that the operating frequency of the chip external clock is abnormal.
[0038] In a second aspect, the present invention provides a chip frequency anomaly detection method, comprising: using the detection result of whether the chip external clock operating frequency is abnormal obtained by the chip external clock operating frequency anomaly detection method described in the first aspect as the detection result of whether the chip frequency is abnormal.
[0039] In a third aspect, the present invention provides a chip external clock operating frequency abnormality detection system, comprising:
[0040] A first acquisition module is used to acquire the expected operating frequency of the chip external clock, the expected operating frequency of the chip internal clock, the frequency division coefficient of the frequency sensor, and the frequency detection accuracy of the frequency sensor;
[0041] A first determination module is used to determine a first low-frequency alarm threshold and a first high-frequency alarm threshold of the frequency sensor according to an expected operating frequency of the chip external clock, an expected operating frequency of the chip internal clock, a frequency division coefficient of the frequency sensor, and a frequency detection accuracy of the frequency sensor;
[0042] The second acquisition module is used to acquire the actual operating frequency of the chip external clock;
[0043] A second determination module is used to determine the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock and the frequency division coefficient of the frequency sensor;
[0044] A third determination module is used to determine a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock;
[0045] The fourth determination module is used to determine whether the operating frequency of the chip external clock is abnormal according to the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor.
[0046] In a fourth aspect, the present invention provides a computer-readable storage medium for storing a computer program; when the computer program is executed by a processor, the steps of the method for detecting anomaly in the operating frequency of an external clock of a chip described in the first aspect are implemented.
[0047] Beneficial Effects
[0048] The present invention provides a method and system for detecting abnormal working frequency of an external clock of a chip. For a security chip, there are at least two clock sources, an internal clock and an external clock. The internal clock is generated by a fixed internal ring oscillator and is difficult to be attacked. The external clock is an external input clock, and the working efficiency of the internal circuit of the chip is determined by the external clock. If the frequency of the external clock is too high, the working state of the chip will be abnormal and disordered; if the frequency of the external clock is too low, the working performance and efficiency of the chip will be affected. Therefore, the present invention provides a method for detecting abnormal working frequency of an external clock of a chip, which uses the external clock as a measured clock to be monitored. According to the actual working frequency of the internal clock of the chip, the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor are determined to calibrate the frequency sensor, and then the working frequency of the external clock of the chip is detected according to the calibrated frequency sensor, so as to facilitate the determination of whether the chip frequency is abnormal according to the detection result of the external clock frequency of the chip, and improve the frequency detection accuracy of the chip, especially the security chip. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] Figure 1 A flowchart of a method for detecting abnormal operating frequency of a chip external clock provided by an embodiment of the present invention;
[0051] Figure 2 A high-frequency alarm and a low-frequency alarm flow chart provided by an embodiment of the present invention;
[0052] Figure 3 A schematic diagram of the connection between the frequency detection module and the alarm management module provided in an embodiment of the present invention;
[0053] Figure 4 A synchronous processing circuit diagram of a frequency sensor enable signal provided by an embodiment of the present invention;
[0054] Figure 5A schematic diagram of the timing of a low-frequency alarm provided by an embodiment of the present invention;
[0055] Figure 6 A schematic diagram of the timing of a high-frequency alarm provided by an embodiment of the present invention;
[0056] Figure 7 A schematic diagram of the structure of a chip external clock operating frequency anomaly detection system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0058] The present invention is based on the belief that the internal clock of the chip is difficult to be attacked compared to the external clock. The external clock is used as the measured clock to be monitored, and the frequency of the external clock (measured clock) is counted with the internal clock as the reference clock, so as to determine whether the operating frequency of the chip's external clock is abnormal, and judge whether the chip frequency is abnormal based on this.
[0059] Example 1
[0060] Ideally, the internal clock of the security chip is relatively stable, and a reference clock with a fixed frequency is usually generated by an internal ring oscillator. However, due to the influence of factors such as deviations in chip temperature, voltage and / or production process, and differences between chips, the frequency of the internal clock also varies to a certain extent. Therefore, during frequency detection in this embodiment, it is necessary to first calibrate the circuit of the frequency sensor and the frequency of the reference clock (internal ring oscillator) so that the frequency of the measured clock can be counted using the accurate frequency of the reference clock, thereby ensuring the accuracy of frequency detection.
[0061] like Figure 1 As shown, this embodiment provides a method for detecting abnormal operating frequency of a chip external clock, including:
[0062] Step 101, obtaining the expected operating frequency of the chip external clock, the expected operating frequency of the chip internal clock, the frequency division coefficient of the frequency sensor, and the frequency detection accuracy of the frequency sensor.
[0063] Step 102, determining a first low frequency alarm threshold and a first high frequency alarm threshold of the frequency sensor according to the expected operating frequency of the chip external clock, the expected operating frequency of the chip internal clock, the frequency division coefficient of the frequency sensor and the frequency detection accuracy of the frequency sensor.
[0064] In this step, the first low-frequency alarm threshold L1 and the first high-frequency alarm threshold H1 of the frequency sensor are calculated illustratively according to the following formula:
[0065] .
[0066] Among them, d is the frequency division coefficient of the frequency sensor; f1 is the expected operating frequency of the chip internal clock; F1 is the expected operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor.
[0067] Step 103, obtaining the actual operating frequency of the chip external clock.
[0068] Step 104 , determining the actual operating frequency of the chip internal clock according to the first low frequency alarm threshold or the first high frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor.
[0069] In this step, illustratively, when determining the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor, the actual operating frequency f2 of the chip internal clock is calculated according to the following formula:
[0070] .
[0071] Among them, F2 is the actual operating frequency of the chip external clock.
[0072] When determining the actual operating frequency of the chip internal clock according to the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor, the actual operating frequency f2 of the chip internal clock is calculated according to the following formula:
[0073] .
[0074] Wherein, H1 is the first high-frequency alarm threshold of the frequency sensor.
[0075] Step 105 , determining a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock.
[0076] In this step, the second low-frequency alarm threshold L2 and the second high-frequency alarm threshold H2 of the frequency sensor are calculated illustratively according to the following formula:
[0077] .
[0078] Step 106 , determining whether the operating frequency of the chip external clock is abnormal according to the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor.
[0079] This step includes enabling the frequency sensor. Exemplarily, the enable signal of the frequency sensor is delayed by two clock cycles in the chip internal clock domain, and the rising edge of the enable signal after the delay of two clock cycles is detected, and the frequency sensor is enabled at the rising edge of the enable signal.
[0080] After the frequency sensor is enabled, the chip external clock is divided to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain. Exemplarily, after the frequency sensor is enabled, a counter is used to start counting at the rising edge of each chip external clock, and when the count reaches a preset division coefficient, the chip external clock is flipped and the counter is reset to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain.
[0081] The single pulse length of div_clk is counted to obtain the number of cycles cnt of the chip internal clock contained in a single pulse length of div_clk. Exemplarily, in the chip internal clock domain, the rising edge and falling edge of div_clk are detected, a counter is set, and the single pulse length of div_clk is counted using the chip internal clock to obtain the number of cycles cnt of the chip internal clock contained in a single pulse length of div_clk.
[0082] The chip external clock operating frequency is determined to be abnormal according to the cycle number cnt. Exemplarily, when cnt is greater than the second low frequency alarm threshold or cnt is less than the second high frequency alarm threshold, the chip external clock operating frequency is determined to be abnormal.
[0083] In this step, if Figure 2 As shown, after the frequency sensor circuit is calibrated, the frequency division coefficient d (div), the second low-frequency alarm threshold, and the second high-frequency alarm threshold of the frequency sensor have been configured. Enable the frequency sensor circuit and the frequency sensor starts working. Since the input signal of the frequency sensor may not be at the same frequency as the working clock of the frequency sensor, the frequency sensor needs to consider the synchronization of its input signal when it is working, and perform asynchronous handover of signals across clock domains. Since all the input signals of the frequency sensor except the enable signal (en) have been configured after calibration, it is only necessary to synchronize the enable signal (en) of the frequency sensor to the reference clock domain. As shown Figure 4 As shown, through three rising-edge triggered D flip-flops and an AND gate, the enable signal is double-beat in the reference clock domain (that is, delayed by two clock cycles to complete the synchronization operation within two consecutive clock cycles), and the rising edge of the enable signal after double beating is detected. At the rising edge of the enable signal, the frequency sensor is enabled and the frequency sensor starts working.
[0084] The working mechanism of the frequency sensor is to use the internal clock as the reference clock to count the frequency of the clock under test so as to determine whether the relative relationship of the clock frequency under test meets expectations. The frequency of the external clock of the security chip is often much higher than the internal ring oscillator clock. Therefore, the external clock needs to be divided first. The larger the division coefficient, the greater the frequency difference between the two clocks, the more accurate the counting and the higher the detection accuracy. The specific implementation method of using the counter to divide the clock under test test_clk is as follows: set an n-bit counter in the test_clk clock domain (n can be configured by external input through the bus, and n can be any natural number less than or equal to the bus data bit width). When the frequency sensor is enabled, the counter starts counting cyclically under the rising edge of the clock under test, counting from 0 to div-1. When the count reaches the set division coefficient, the clock div_clk after the clock under test is divided and the counter is reset. Finally, the clock div_clk after the clock under test is divided by 2div is obtained.
[0085] After the measured clock is divided and synchronized, the measured clock is divided to a frequency much lower than the reference clock, and the measured clock div_clk is obtained after the measured clock is divided in the reference clock domain. Then, the frequency relationship between div_clk and the reference clock ref_clk can be used to detect whether the frequency of the measured clock test_clk is within the threshold range.
[0086] Exemplarily, in the reference clock domain, an m-bit counter is set (m can be configured by external input through the bus, and m can be any natural number less than or equal to the bus data bit width), the rising edge and falling edge of div_clk are detected, the counter starts counting when triggered by the rising edge of div_clk, and the single pulse length of div_clk is counted with the reference clock ref_clk. When triggered by the falling edge of div_clk, the counter is cleared and starts cyclic counting, and the number of cycles cnt of the reference clock included in a single pulse length of div_clk is counted, and the relative relationship between the number of cycles cnt and the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor is judged at each div_clk clock edge. If it exceeds the range of the second low-frequency alarm threshold or the second high-frequency alarm threshold, the corresponding high-frequency or low-frequency alarm signal of the frequency sensor is output, that is, when cnt is greater than the second low-frequency alarm threshold or cnt is less than the second high-frequency alarm threshold, it is determined that the operating frequency of the chip external clock is abnormal, and the corresponding low-frequency or high-frequency alarm signal of the frequency sensor is output.
[0087] If the alarm signal output by the frequency sensor is directly used as the actual alarm signal, there may be a false alarm, affecting the normal operation of the chip. In order to prevent the occurrence of false alarm scenarios, the embodiment of the present invention also provides an alarm management method, which can manage alarm signals through external input, support alarm signal shielding, configurable alarm number thresholds, and queryable current alarm number status.
[0088] Exemplarily, an alarm signal shielding register is set to control the output of the alarm signal, with permissions of readable and writable, and the default value is 0, indicating output of the alarm signal. When the alarm signal shielding register is written 1, the alarm signal can be shielded and the output of the alarm signal is prohibited.
[0089] Set the alarm count register as a readable register, store the current frequency alarm count into the alarm count register, and read the current frequency alarm status.
[0090] Set the alarm signal count threshold register, the permissions are readable and writable, the default is 1, which means that an alarm signal is output as long as an alarm occurs. The alarm signal count threshold register can be configured by an external input signal through the bus to reduce the probability of false alarms. When the system alarm count reaches the threshold, the actual alarm is triggered.
[0091] like Figure 3 As shown, the input signals are the external clock (test clock) test_clk of the safety chip, the reset test_rst_n in the test clock domain, the internal clock (reference clock) ref_clk, the reset ref_rst_n in the reference clock domain, the frequency sensor enable en, the division coefficient div of the test clock, and the low frequency alarm threshold (i.e. the second low frequency alarm threshold), high frequency alarm threshold (i.e., the second high-frequency alarm threshold), alarm shielding signal alarm_mask, low-frequency alarm times threshold l_alarm_times_th, and high-frequency alarm times threshold h_alarm_times_th. The output signals are alarm times alarm_info, low-frequency alarm l_alarm, and high-frequency alarm h_alarm.
[0092] The relationship between the frequency sensor module and the alarm management module in the present invention is as follows: Figure 3 As shown, the respective interface signal descriptions are shown in Table 1 and Table 2.
[0093] Table 1 Frequency sensor module I / O interface signal list
[0094] Table 2 Alarm management module I / O interface signal list
[0095] In this embodiment, Figure 5 and Figure 6 The timing diagram shown in the figure detects a safety chip with a working frequency of 500M and an internal clock of 2M ring oscillator. The list of all registers that can be configured by external input signals through the bus is shown in Table 3. The detection accuracy of the frequency sensor can be controlled by setting appropriate frequency division coefficients and thresholds. The relationship between these parameters and accuracy is shown in Table 4. In the test stimulus, the measured clock frequencies are set to 440M and 560M respectively. When the measured clock frequency exceeds the threshold, a corresponding alarm occurs. The feasibility of the abnormal detection method of the chip external clock working frequency provided by the embodiment of the present invention is proved.
[0096] Table 3 Register List
[0097] Table 4 Parameter configuration relationship table
[0098] In summary, the present embodiment provides a method for detecting abnormal operating frequency of an external clock of a chip, by determining a first low-frequency alarm threshold and a first high-frequency alarm threshold of a frequency sensor, and determining the actual operating frequency of the internal clock of the chip according to the first low-frequency alarm threshold and the first high-frequency alarm threshold, so as to determine the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor, to calibrate the frequency sensor, and use the calibrated frequency sensor to detect the operating frequency of the external clock of the chip, thereby improving the precision and accuracy of the detection of the operating frequency of the external clock of the chip.
[0099] Example 2
[0100] The present embodiment provides a chip frequency anomaly detection method applicable to a security chip, comprising: using the detection result of whether the chip external clock operating frequency is abnormal obtained by using the chip external clock operating frequency anomaly detection method described in Example 1 as the detection result of whether the chip frequency is abnormal.
[0101] Example 3
[0102] Based on the same inventive concept as Example 1, this embodiment also provides a chip external clock operating frequency anomaly detection system. Since the principle of solving the problem by this system is similar to the aforementioned chip external clock operating frequency anomaly detection method, the implementation of this system can refer to the implementation of the chip external clock operating frequency anomaly detection method.
[0103] like Figure 7 As shown, the chip external clock operating frequency abnormality detection system includes:
[0104] The first acquisition module 10 is used to acquire the expected operating frequency of the chip external clock, the expected operating frequency of the chip internal clock, the frequency division coefficient of the frequency sensor, and the frequency detection accuracy of the frequency sensor.
[0105] The first determination module 20 is used to determine the first low frequency alarm threshold and the first high frequency alarm threshold of the frequency sensor according to the expected operating frequency of the chip external clock, the expected operating frequency of the chip internal clock, the frequency division coefficient of the frequency sensor and the frequency detection accuracy of the frequency sensor.
[0106] The second acquisition module 30 is used to acquire the actual operating frequency of the chip external clock.
[0107] The second determination module 40 is used to determine the actual operating frequency of the chip internal clock according to the first low frequency alarm threshold or the first high frequency alarm threshold, the actual operating frequency of the chip external clock and the frequency division coefficient of the frequency sensor.
[0108] The third determination module 50 is used to determine a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock.
[0109] The fourth determination module 60 is used to determine whether the operating frequency of the chip external clock is abnormal according to the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor.
[0110] Exemplarily, the first determining module includes:
[0111] The first calculation unit is used to calculate the first low-frequency alarm threshold L1 and the first high-frequency alarm threshold H1 of the frequency sensor according to the following formula:
[0112] .
[0113] Among them, d is the frequency division coefficient of the frequency sensor; f1 is the expected operating frequency of the chip internal clock; F1 is the expected operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor.
[0114] Exemplarily, the second determining module includes:
[0115] The second calculation unit is used to calculate the actual operating frequency f2 of the chip internal clock according to the following formula:
[0116] .
[0117] Among them, F2 is the actual operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor; d is the frequency division coefficient of the frequency sensor; L1 is the first low-frequency alarm threshold of the frequency sensor; H1 is the first high-frequency alarm threshold of the frequency sensor.
[0118] Exemplarily, the second determining module further includes:
[0119] The third calculation unit is used to calculate the actual operating frequency f2 of the chip internal clock according to the following formula:
[0120] .
[0121] Wherein, H1 is the first high-frequency alarm threshold of the frequency sensor.
[0122] Exemplarily, the third determining module includes:
[0123] The fourth calculation unit is used to calculate the second low-frequency alarm threshold L2 and the second high-frequency alarm threshold H2 of the frequency sensor according to the following formula:
[0124] .
[0125] Among them, d is the frequency division coefficient of the frequency sensor; f2 is the actual operating frequency of the chip internal clock; F1 is the expected operating frequency of the chip external clock; P is the frequency detection accuracy of the frequency sensor.
[0126] Exemplarily, the fourth determining module includes:
[0127] The enabling unit is used to enable the frequency sensor. Optionally, the enabling unit is used to delay the enable signal of the frequency sensor by two clock cycles in the chip internal clock domain, detect the rising edge of the enable signal after the delay of two clock cycles, and enable the frequency sensor at the rising edge of the enable signal.
[0128] The frequency division unit is used to divide the chip external clock after the frequency sensor is enabled to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain. Optionally, the frequency division unit is used to use a counter to start counting at the rising edge of each chip external clock after the frequency sensor is enabled, and when the count reaches a preset frequency division coefficient, flip the chip external clock divided clock and reset the counter to obtain the chip external clock divided clock div_clk in the chip internal clock domain.
[0129] The counting unit is used to count the length of a single pulse of div_clk to obtain the number of cycles cnt of the chip internal clock contained in the length of a single pulse of div_clk. Optionally, the counting unit is used to detect the rising edge and falling edge of div_clk in the chip internal clock domain, set a counter, and use the chip internal clock to count the length of a single pulse of div_clk to obtain the number of cycles cnt of the chip internal clock contained in the length of a single pulse of div_clk.
[0130] The determination unit is used to determine that the chip external clock operating frequency is abnormal according to the cycle number cnt. Optionally, the determination unit is used to determine that the chip external clock operating frequency is abnormal when cnt is greater than the second low frequency alarm threshold or cnt is less than the second high frequency alarm threshold.
[0131] For more specific working processes of the above modules, please refer to the corresponding contents disclosed in Example 1, which will not be repeated here.
[0132] Example 4
[0133] This embodiment provides a computer device, including a processor and a memory; wherein the processor implements the steps of the chip external clock operating frequency abnormality detection method described in Embodiment 1 when executing a computer program stored in the memory.
[0134] For more specific details of the above method, please refer to the corresponding contents disclosed in Example 1, which will not be repeated here.
[0135] Example 5
[0136] This embodiment provides a computer-readable storage medium for storing a computer program; when the computer program is executed by a processor, the steps of the method for detecting abnormal operating frequency of a chip external clock described in Embodiment 1 are implemented.
[0137] For more specific details of the above method, please refer to the corresponding contents disclosed in Example 1, which will not be repeated here.
[0138] Example 6
[0139] This embodiment provides a computer program product, including computer executable instructions or a computer program. When the computer executable instructions or the computer program are executed by a processor, the steps of the chip external clock operating frequency abnormality detection method described in Embodiment 1 are implemented.
[0140] For more specific details of the above method, please refer to the corresponding contents disclosed in Example 1, which will not be repeated here.
[0141] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the systems, devices, storage media, and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0142] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.
[0143] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0144] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0145] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.
[0146] The present invention has been described in detail above in conjunction with specific implementations and exemplary examples, but these descriptions cannot be understood as limiting the present invention. Those skilled in the art understand that, without departing from the spirit and scope of the present invention, a variety of equivalent substitutions, modifications or improvements may be made to the technical solution of the present invention and its implementation methods, all of which fall within the scope of the present invention. The scope of protection of the present invention shall be subject to the attached claims.
Claims
1. A method for detecting abnormal operating frequency of a chip external clock, It is characterized in that include: Obtaining the expected operating frequency of the chip's external clock, the expected operating frequency of the chip's internal clock, the frequency division coefficient of the frequency sensor, and the frequency detection accuracy of the frequency sensor; Determine a first low-frequency alarm threshold and a first high-frequency alarm threshold of the frequency sensor according to an expected operating frequency of the chip external clock, an expected operating frequency of the chip internal clock, a frequency division coefficient of the frequency sensor, and a frequency detection accuracy of the frequency sensor; Get the actual operating frequency of the chip's external clock; Determine the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor; Determine a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock; Whether the operating frequency of the chip external clock is abnormal is determined according to the second low frequency alarm threshold and the second high frequency alarm threshold of the frequency sensor.
2. The method for detecting abnormal operating frequency of a chip external clock according to claim 1, It is characterized in that The method of determining a first low-frequency alarm threshold and a first high-frequency alarm threshold of the frequency sensor according to an expected operating frequency of a chip external clock, an expected operating frequency of a chip internal clock, a frequency division coefficient of the frequency sensor, and a frequency detection accuracy of the frequency sensor includes: Calculate the first low-frequency alarm threshold L of the frequency sensor according to the following formula 1 and the first high frequency alarm threshold H 1 : ; Where d is the frequency division coefficient of the frequency sensor; f 1 is the expected operating frequency of the chip's internal clock; F 1 is the expected operating frequency of the chip's external clock; P is the frequency detection accuracy of the frequency sensor.
3. The method for detecting abnormal operating frequency of a chip external clock according to claim 1, It is characterized in that The method of determining the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor includes: Calculate the actual operating frequency f of the chip's internal clock according to the following formula 2 : ; Among them, F 2 is the actual operating frequency of the chip's external clock; P is the frequency detection accuracy of the frequency sensor; d is the frequency division coefficient of the frequency sensor; L 1 It is the first low frequency alarm threshold of the frequency sensor.
4. The method for detecting abnormal operating frequency of a chip external clock according to claim 1, It is characterized in that The method of determining the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock, and the frequency division coefficient of the frequency sensor includes: Calculate the actual operating frequency f of the chip's internal clock according to the following formula 2 : ; Among them, F 2 is the actual operating frequency of the chip's external clock; P is the frequency detection accuracy of the frequency sensor; d is the frequency division coefficient of the frequency sensor; H 1 It is the first high frequency alarm threshold of the frequency sensor.
5. The method for detecting abnormal operating frequency of a chip external clock according to claim 3 or 4, It is characterized in that The method of determining the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock includes: Calculate the second low frequency alarm threshold L of the frequency sensor according to the following formula 2 and the second high frequency alarm threshold H 2 : ; Where d is the frequency division coefficient of the frequency sensor; f 2 is the actual operating frequency of the chip's internal clock; F 1 is the expected operating frequency of the chip's external clock.
6. The method for detecting abnormal operating frequency of a chip external clock according to claim 1, It is characterized in that The method of determining whether the chip external clock operating frequency is abnormal according to the second low frequency alarm threshold and the second high frequency alarm threshold of the frequency sensor includes: Enable frequency sensor; After the frequency sensor is enabled, the chip external clock is divided to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain; Count the length of a single pulse of div_clk to obtain the number of cycles cnt of the chip internal clock contained in the length of a single pulse of div_clk; According to the cycle number cnt, it is determined that the operating frequency of the chip external clock is abnormal.
7. The method for detecting abnormal operating frequency of a chip external clock according to claim 6, It is characterized in that The method of determining whether the chip external clock operating frequency is abnormal according to the second low frequency alarm threshold and the second high frequency alarm threshold of the frequency sensor includes: Delaying the enable signal of the frequency sensor by two clock cycles in the chip internal clock domain, detecting the rising edge of the enable signal after the delay of two clock cycles, and enabling the frequency sensor at the rising edge of the enable signal; And / or, after the frequency sensor is enabled, a counter is used to start counting at the rising edge of each chip external clock, and when the count reaches a preset frequency division coefficient, the clock after the chip external clock is divided is flipped and the counter is reset to obtain the clock div_clk after the chip external clock is divided in the chip internal clock domain; And / or, in the chip internal clock domain, detecting the rising edge and falling edge of div_clk, setting a counter, using the chip internal clock to count the length of a single pulse of div_clk, and obtaining the number of cycles cnt of the chip internal clock included in the length of a single pulse of div_clk; And / or, when cnt is greater than the second low-frequency alarm threshold or cnt is less than the second high-frequency alarm threshold, it is determined that the operating frequency of the chip external clock is abnormal.
8. A chip frequency anomaly detection method, It is characterized in that include: The detection result of whether the chip external clock operating frequency is abnormal obtained by the chip external clock operating frequency abnormality detection method described in any one of claims 1 to 7 is used as the detection result of whether the chip frequency is abnormal.
9. A chip external clock operating frequency abnormality detection system, It is characterized in that include: A first acquisition module is used to acquire the expected operating frequency of the chip external clock, the expected operating frequency of the chip internal clock, the frequency division coefficient of the frequency sensor, and the frequency detection accuracy of the frequency sensor; A first determination module is used to determine a first low-frequency alarm threshold and a first high-frequency alarm threshold of the frequency sensor according to an expected operating frequency of the chip external clock, an expected operating frequency of the chip internal clock, a frequency division coefficient of the frequency sensor, and a frequency detection accuracy of the frequency sensor; The second acquisition module is used to acquire the actual operating frequency of the chip external clock; A second determination module is used to determine the actual operating frequency of the chip internal clock according to the first low-frequency alarm threshold or the first high-frequency alarm threshold, the actual operating frequency of the chip external clock and the frequency division coefficient of the frequency sensor; A third determination module is used to determine a second low-frequency alarm threshold and a second high-frequency alarm threshold of the frequency sensor according to the actual operating frequency of the chip internal clock; The fourth determination module is used to determine whether the operating frequency of the chip external clock is abnormal according to the second low-frequency alarm threshold and the second high-frequency alarm threshold of the frequency sensor.
10. A computer-readable storage medium, It is characterized in that Used to store computer programs; when the computer programs are executed by the processor, the steps of the chip external clock operating frequency abnormality detection method described in any one of claims 1-7 are implemented.
