Clock switching circuit and electronic equipment
By introducing enable signal generation module, delay module and gate module into the clock switching circuit, the smooth and burrless clock switching is achieved, which solves the problem of poor synchronization when switching clock sources in the traditional clock switching circuit and improves the stability of the chip Sex and reliability.
Patent Information
- Application Number
- CN202411115730.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-15
AI Technical Summary
In modern large-scale integrated circuit design, traditional clock switching circuits cannot remain synchronized when switching clock sources, resulting in glitches from the output clock signal, which may cause logic errors and chip function failure, and poor working reliability.
A clock switching circuit is designed, including an enable signal generation module, a delay module, a gate module and a clock output logic module. The gate module performs clock switching at low levels to ensure that the switching process is smooth and without glitches.
It effectively avoids the output signal glitch during clock switching, improves the stability and reliability of the chip, and ensures that the system can still operate safely under extreme fault conditions.
Smart Images

Figure CN118963487A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of electronic circuits, and in particular to a clock switching circuit and an electronic device. Background Art
[0002] With the continuous development of integrated circuit technology and design technology, the integration, design scale and performance of integrated circuits are constantly improving. In modern large-scale integrated circuit design, in order to adapt to the needs of different working states such as low power consumption and high performance, different clock frequencies are usually required in different working states inside the chip. More and more chips use multiple clock source designs, so different clocks need to be selected and switched in the design of chip clock management systems.
[0003] Normally, multiple clock sources are unrelated to each other. Traditional circuits that directly use selection signals to switch clocks will generate glitches on the output clock during operation because the clock switching signal cannot be synchronized with all input clocks. These glitches may be captured by related triggers, resulting in logical errors and failure of the entire chip function, and poor circuit reliability. Summary of the invention
[0004] An embodiment of the present invention provides a clock switching circuit, which can avoid glitches when switching between different clock sources.
[0005] In a first aspect, the present invention provides a clock switching circuit, the clock switching circuit is used to switch a first clock source and N second clock sources, N is an integer greater than or equal to 1, and the clock switching circuit includes a first enable signal generating module, a first delay module, a first gating module, N second enable signal generating modules, N second delay modules, N second gating modules, and a clock output logic module. Each of the second clock sources, each of the second enable signal generating modules, each of the second delay modules and each of the second gating modules correspond one to one. The first enable signal generating module is respectively connected to the first clock selection signal of the first clock source, each of the second delay modules, the first delay module and the first gating module, the first gating module is also connected to the first clock source and the clock output logic module, the second enable signal generating module is respectively connected to the second clock selection signal of the corresponding second clock source, each of the second delay modules, the first delay module, and the corresponding second gating module, and the second gating module is also connected to the corresponding second clock source and the clock output logic module. Among them, the first clock selection signal is used to indicate whether the first clock source is the target clock source to be switched and output, and the second clock selection signal is used to indicate whether the corresponding second clock source is the target clock source. The second enable signal generating module is used to generate a second enable signal according to the corresponding second clock selection signal, the first delay signal output by the first delay module, and the second delay signal output by other second delay modules in the clock switching circuit except the second delay module corresponding to the second enable signal generating module. The first enable signal generating module is used to generate a first enable signal according to the first clock selection signal and the second delay signal output by each second delay module. The first delay signal is a signal after the first enable signal is delayed, and the second delay signal is a signal after the second enable signal generated by the second enable signal generating module corresponding to the second delay module is delayed. The first gating module is used to output or stop outputting to the clock output logic module when the first clock source is at a low level according to the first enable signal. The second gating module is used to output or stop outputting to the clock output logic module when the corresponding second clock source is at a low level according to the second enable signal. The clock output logic module is used to output the target clock source through the output end of the clock output logic module according to the output signals of the first gating module and the second gating module.
[0006] In some embodiments, the clock switching circuit further includes N first logic modules. Each of the first logic modules, each of the second clock sources, each of the second delay modules corresponds to each of the second enable signal generating modules one by one, and the first logic module is respectively connected to the indication signal of the corresponding second clock source, the reset signal of the corresponding second clock source, the corresponding second enable signal generating module, and the corresponding second delay module. Among them, the indication signal is used to indicate whether the corresponding second clock source is in place, and the reset signal is used to indicate whether the corresponding second clock source needs to be reset. The first logic module is used to output a first logic signal according to the indication signal and the reset signal. The second enable signal generating module and the second delay module are both used to confirm whether to reset according to the first logic signal.
[0007] In some embodiments, the first logic module includes a first AND gate. Each of the first AND gates, each of the second clock sources, each of the second delay modules and each of the second enable signal generating modules corresponds to each other, the first input end of the first AND gate is connected to the indication signal of the corresponding second clock source, the second input end of the first AND gate is connected to the reset signal of the corresponding second clock source, and the output end of the first AND gate is respectively connected to the corresponding second enable signal generating module and the corresponding second delay module.
[0008] In some embodiments, the clock switching circuit further includes N second logic modules. Each second logic module, each second clock source, each second delay module, each second enable signal generating module and each second gating module correspond one to one, and the second logic module is respectively connected to the corresponding second clock source, the corresponding indication signal of the second clock source, the corresponding second enable signal generating module, the corresponding second delay module and the corresponding second gating module. The second logic module is used to confirm whether to output the second clock source to the second gating module and the second enable signal generating module according to the indication signal.
[0009] In some embodiments, the second logic module includes a second AND gate. Each of the second AND gates, each of the second clock sources, each of the second delay modules, each of the second enable signal generating modules and each of the second gating modules correspond to each other one by one, the first input end of the second AND gate is connected to the corresponding second clock source, the second input end of the second AND gate is connected to the indication signal of the corresponding second clock source, and the output end of the second AND gate is respectively connected to the corresponding second enable signal generating module, the corresponding second delay module and the corresponding second gating module.
[0010] In some embodiments, if N=1, the clock output logic module includes a third logic module, the first input end of the third logic module is connected to the first gating module, and the second input end of the third logic module is connected to the second gating module. If N is greater than 1, the clock output logic module includes N third logic modules, the first input end of the first third logic module is connected to the first gating module, the second input end of the first third logic module is connected to the first second gating module, the first input end of the nth third logic module is connected to the output end of the n-1th third logic module, and the second input end of the nth third logic module is connected to the nth second gating module, where n is an integer greater than 1 and less than N+1.
[0011] In some embodiments, the third logic module includes a first inverter, a second inverter and a NAND gate. The input end of the first inverter is the first input end of the third logic module, the input end of the second inverter is the second input end of the third logic module, the input end of the NAND gate is respectively connected to the output end of the first inverter and the output end of the second inverter, and the output end of the NAND gate is the output end of the third logic module.
[0012] In some embodiments, the first enable signal generating module includes a first NOR gate and a first synchronizer, and the first delay module includes a first trigger. The first NOR gate is respectively connected to the second delay module, the first clock selection signal, and the first synchronizer, the first synchronizer is also connected to the set signal of the first clock source, the first clock source, the first gating module, and the first trigger, and the first trigger is also connected to each of the second enable signal generating modules.
[0013] In some embodiments, the second enable signal generating module includes a second NOR gate and a second synchronizer, and the second delay module includes a second trigger. The second NOR gate is respectively connected to the second clock signal of the corresponding second clock source, the first delay module, the second triggers other than the second trigger corresponding to the second enable signal generating module in the clock switching circuit, and the corresponding second synchronizer, and the second synchronizer is also connected to the corresponding first logic module, the corresponding second logic module, the corresponding second gating module, and the corresponding second trigger.
[0014] In a second aspect, an embodiment of the present invention provides an electronic device, comprising a clock switching circuit as described in any one of the first aspects.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: Different from the prior art, the embodiment of the present invention provides a clock switching circuit, the clock switching circuit is used to switch a first clock source and N second clock sources, N is an integer greater than or equal to 1, and the clock switching circuit includes a first enable signal generating module, a first delay module, a first gating module, N second enable signal generating modules, N second delay modules, N second gating modules, and a clock output logic module. In the clock switching circuit, due to the effect of the gating module, the clock switching can be switched at a low level, thereby ensuring that the clock switching circuit can switch smoothly without glitches when switching the clock, and avoiding glitches in the clock signal output by the clock output logic module. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements / modules and steps with the same reference numerals in the drawings are represented as similar elements / modules and steps. Unless otherwise specified, the figures in the drawings do not constitute proportional limitations.
[0017] Figure 1 is a structural block diagram of a switching circuit provided by an embodiment of the present invention;
[0018] Figure 2 yes Figure 1 Corresponding working signal schematic diagram;
[0019] Figure 3 is a structural block diagram of another switching circuit provided by an embodiment of the present invention;
[0020] Figure 4 yes Figure 3 Corresponding working signal schematic diagram;
[0021] Figure 5 is a structural block diagram of another switching circuit provided by an embodiment of the present invention;
[0022] Figure 6 is a structural block diagram of a clock switching circuit provided by an embodiment of the present invention;
[0023] Figure 7 is a circuit structure diagram of a clock switching circuit provided by an embodiment of the present invention;
[0024] Figure 8 is a circuit structure diagram of another clock switching circuit provided by an embodiment of the present invention;
[0025] Fig. 9 is a circuit structure diagram of another clock switching circuit provided by an embodiment of the present invention;
[0026] Fig.10is a schematic diagram of a working signal provided by an embodiment of the present invention;
[0027] Fig.11 This is another schematic diagram of working signals provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0029] For the convenience of understanding the present invention, the present invention will be described in more detail below in conjunction with the accompanying drawings and specific embodiments. Unless otherwise defined, all technical and scientific terms used in this specification are identical with the meanings generally understood by those skilled in the art of the present invention. The terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used in this specification includes any and all combinations of one or more related listed items.
[0030] It should be noted that, if there is no conflict, the various features in the embodiments of the present invention can be combined with each other, and all are within the scope of protection of the present invention. In addition, although the functional module division is performed in the device schematic, in some cases, the module division can be different from that in the device. In addition, the words "first", "second", etc. used in this article do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.
[0031] At present, designing a circuit that can stably and reliably switch between different clock sources is crucial to ensure the normal operation of the chip. In traditional clock switching circuits, multiplexers are used to select and switch clocks, such as Figure 1 As shown, clock source 1 and clock source 2 are two asynchronous clock sources. The signal selected at the clock selection end of the multiplexer M1 is controlled by a specially designed clock enable logic circuit, see Figure 2 When the select signal at the clock selection end is at a low level (such as 0), the clock output end clkout of the multiplexer M1 is clock source 1, and when the select signal at the clock selection end is at a high level (such as 1), the clock output end clkout of the multiplexer M1 is clock source 2. Since the select signal at the clock selection end cannot be synchronized with both clock source 1 and clock source 2, when the multiplexer M1 is used to switch between the two clocks, the signal at the clock output end clkout of the multiplexer M1 may have glitches, and the safe and stable operation of the chip cannot be guaranteed.
[0032] In order to solve the burr phenomenon when switching clocks, the present application provides a clock switching circuit, such as Figure 3 As shown, the select signal at the clock selection end is used to select the switching clock output. When the select signal is 0, the clock source 1 output is selected, and when the select signal is 1, the clock source 2 output is selected. Figure 4 As shown. In this circuit, the select signal is inverted with the output of trigger A6 and then synchronized with trigger A3 and trigger A4 to generate signal clk_1_en; the signal select is inverted with the signal clk_1_en and then synchronized with trigger A5 and trigger A6 to generate signal clk_2_en, signal clk_1_en is ANDed with clock source 1, signal clk_2_en is ANDed with clock source clk2, and finally the output results of AND gate A8 and AND gate A9 are output through OR gate A10 to output the clock. In this circuit, when the clock is switched, two levels of synchronization are required before turning on the clock to be switched, and both the opening and closing are performed using AND gate logic when the clock is at a low level (signal clk_1_en and signal clk2_en are both generated at the falling edge of the clock), so the output signal clk_out can be prevented from having glitches during the clock switching stage. However, this circuit uses a special trigger triggered by the falling edge of the clock, which is not universal in actual chips and requires special processing. In addition, this structure can only switch two clock sources and cannot support switching of more clock sources. In addition, in this circuit, when one of the clock sources is turned off or lost, the system cannot switch the clock.
[0033] The present application provides a clock switching circuit, such as Figure 5As shown, the signals clk1_sel, clk2_sel and clk3_sel are used to select the output of clock source 1, clock source 2 and clock source 3 respectively. In this circuit, the signal clk1_sel, the output signal q23 of the flip-flop DFF23 and the output signal q33 of the flip-flop DFF33 or not are synchronized by the synchronizer 11 to generate the enable signal q12 of the integrated gated clock unit 14. The signal clk3_sel, the output signal q13 of the flip-flop DFF13 and the output signal q23 of the flip-flop DFF23 or not are synchronized by the synchronizer 12 to generate the enable signal q32 of the integrated gated clock unit 15. The signal clk2_sel, the output signal q13 of the flip-flop DFF13 and the output signal q33 of the flip-flop DFF33 or not are synchronized by the synchronizer 13 to generate the enable signal q22 of the integrated gated clock unit 16. The output signals of each integrated gated clock unit are output as clock signals after passing through corresponding logic gates. When the clock of this circuit switches, it turns on the clock to be switched after two-stage synchronization. Due to the existence of the integrated gated clock unit, the clock switching is smooth and glitch-free at a low level, so the output signal clk_out can be prevented from having glitches during the clock switching stage.
[0034] but, Figure 5 When one of the clock sources of the switching circuit shown is turned off or lost, the clock stays at a high level, and the system cannot switch the clock. For example, if the output of clock source 2 is currently selected, and clock source 2 is lost under certain circumstances during operation, when it stays at a high level, that is, the output signal clk2_icg of the integrated gated clock unit 16 is always 1, and the signal clk2_icg_inv obtained by the inverter of the signal clk2_icg is always 0, resulting in the signal clk_out being always 1 due to the output of the NAND gate, that is, when the clock source is turned off or lost, the output signal clk_out of the switching circuit stays at a high level, and the clock cannot be switched.
[0035] In order to improve the above technical problems, the present application also provides a clock switching circuit, see Figure 6The clock switching circuit 100 is used to switch the first clock source 210 and N second clock sources, where N is an integer greater than or equal to 1, and the N second clock sources include a first second clock source 2201, a second second clock source 2202...an Nth second clock source 220N. The clock switching circuit 100 includes a first enable signal generating module 110, a first delay module 120, a first gating module 130, N second enable signal generating modules, N second delay modules, N second gating modules, and a clock output logic module 170. The N second enable signal generating modules include a first second enable signal generating module 1401, a second second enable signal generating module 1402…an Nth second enable signal generating module 140N. The N second delay modules include a first second delay module 1501, a second second delay module 1502…an Nth second delay module 150N. The N second gating modules include a first second gating module 1601, a second second gating module 1602…an Nth second gating module 160N.
[0036] Each second clock source, each second enable signal generating module, each second delay module and each second gating module correspond one to one. The first enable signal generating module 110 is respectively connected to the first clock selection signal sel1 of the first clock source, each second delay module (1501, 1502...150N), the first delay module 120 and the first gating module 130, and the first gating module 130 is also connected to the first clock source 210 and the clock output logic module 170. The second enable signal generating module is respectively connected to the second clock selection signal of the corresponding second clock source, each second delay module (1501, 1502...150N), the first delay module 120, and the corresponding second gating module, and the second gating module is also connected to the corresponding second clock source and the clock output logic module 170. For example, for the first second enable signal generating module 1401, the first second enable signal generating module 1401 is respectively connected to the second clock selection signal sel21 of the corresponding first second clock source 2201, each second delay module (1501, 1502...150N), the first delay module 120 and the corresponding first first gating module 1601.
[0037] Among them, the first clock selection signal sel1 is used to indicate whether the first clock source 210 is the target clock source to be switched output, and the second clock selection signal (sel21, sel22...sel2N) is used to indicate whether the corresponding second clock source (2201, 2202...220N) is the target clock source.
[0038] The second enable signal generating module (1401, 1402...140N) is used to generate a second enable signal according to the corresponding second clock selection signal, the first delay signal q1 output by the first delay module 120, and the second delay signal output by other second delay modules in the clock switching circuit except the second delay module corresponding to the second enable signal generating module. The first enable signal generating module 110 is used to generate a first enable signal according to the first clock selection signal sel1 and the second delay signals (q21...q2N) output by each second delay module. The first delay signal is a signal after the first enable signal is delayed, and the second delay signal is a signal after the second enable signal is delayed generated by the second enable signal generating module corresponding to the second delay module. The first gating module 130 is used to output or stop outputting to the clock output logic module 170 when the first clock source 210 is at a low level according to the first enable signal. The second gating module is used to output or stop outputting to the clock output logic module 170 when the corresponding second clock source is at a low level according to the second enable signal. The clock output logic module 170 is used to output a target clock source through an output terminal of the clock output logic module 170 according to output signals of the first gating module 130 and the second gating module ( 1501 . . . 150N).
[0039] The first clock source may be a system default clock source in the circuit system, which refers to a system default clock signal generated by a default clock device in the system, and may be a square wave signal with a fixed period. The second clock source is a clock signal generated by other clock devices that is different from the clock signal of the first clock source, and may be a square wave signal with a fixed period different from that of the first clock source, which is used to meet the clock signal required by the system in different situations. The specific generation process of the first clock source and the second clock source may refer to the prior art and is not limited here.
[0040] The time for the first delay module 120 to delay the first enable signal generated by the first enable signal generating module 110 can be set according to actual needs, which is not limited here. The time for the second delay module to delay the second enable signal generated by the corresponding second enable signal generating module can also be set according to actual needs, which is not limited here.
[0041] In addition, in the clock switching circuit 100, if N=1, the clock switching circuit has only one second enable signal generating module, see Figure 7 ,, for the second enable signal generating module 1401 corresponding to the second clock source, it is only connected to the clock selection signal sel21 of the corresponding second clock source 2201 and the first delay signal q1 output by the first delay module 120. The second enable signal generating module only generates the second enable signal according to the corresponding second clock selection signal and the first delay signal q1 output by the first delay module 120.
[0042] If N is greater than 1, see Figure 6 For the first second enable signal generating module 1401, the first second enable signal generating module 1401 is respectively connected to the second clock selection signal sel21 of the corresponding second clock source, each second delay module (1501, 1502...150N), the first delay module 120 and the first second gating module 1601. The first second enable signal generating module 1401 generates a second enable signal according to the second clock selection signal sel21 of the first second clock source 2201, the first delay signal q1, and the second delay signal q22 output by the second second delay module 1502...the second delay signal q2N output by the Nth second delay module 150N. For the i-th second enable signal generating module 140n, the i-th second enable signal generating module 140i is respectively connected to the second clock selection signal sel2i of the corresponding second clock source, each second delay module (1501, 1502...150N), the first delay module 120 and the i-th second gating module 160i. The i-th second enable signal generating module 140i generates a second enable signal according to the second clock selection signal sel2i of the first second clock source 220i, the first delay signal q1, and the second delay signal q22 output by the second second delay module 1502...the second delay signal q2(i-1) output by the i-1th second delay module 150(i-1), the second delay signal q2(i+1) output by the i+1th second delay module 150(i+1)...the second delay signal q2N output by the Nth second delay module 150N. For the Nth second enable signal generating module 1401, the Nth second enable signal generating module 140N is respectively connected to the second clock selection signal sel2N of the corresponding second clock source, each second delay module (1501, 1502 ... 150N), the first delay module 120 and the Nth second gating module 160N, and the Nth second enable signal generating module 140N generates a second enable signal according to the second clock selection signal sel2N of the Nth second clock source 220N, the first delay signal q1, and the second delay signal q22 output by the second second delay module 1502 ... the second delay signal q2 (N-1) output by the N-1th second delay module 150N. Wherein, i is an integer greater than 1 and less than N.
[0043] The first clock selection signal sel1 indicates that the first clock source 210 is the target clock source to be switched output when the first clock selection signal sel1 is at a low level, and indicates that the first clock source 210 is not the target clock source to be switched when the first clock selection signal sel1 is at a high level. The second clock selection signal (sel21, sel22...sel2N) indicates that the corresponding second clock source (2201, 2202...220N) is the target clock source to be switched output when the second clock selection signal (sel21, sel22...sel2N) is at a high level, and indicates that the corresponding second clock source (2201, 2202...220N) is not the target clock source to be switched.
[0044] In the clock switching circuit, the first enable signal generating module 110 and each second enable signal generating module (1401...140N) respectively generate corresponding enable signals to the corresponding gating modules for the received clock selection signal and delay signal. Specifically, the first enable signal generating module 110 and each second enable signal generating module (1401...140N) generate a high level enable signal when the received signals are all low level, and generate a low level enable signal when the received signals are high level.
[0045] The first gating module 130 and each second gating module (1501, 1502, ... 150N) are all integrated gating clock units. When the integrated gating clock unit receives an enable signal of low level (such as 0), the integrated gating clock unit turns off the output when the input clock source is a low level signal, so that the corresponding clock source cannot be output to the clock output logic module 170 through the integrated gating clock unit. When the received enable signal is high level (such as 1), the integrated gating clock unit turns on the clock output when the input clock source is low level, so that the corresponding clock source can be output to the clock output logic module 170 through the integrated gating clock unit. The specific circuit structure of the integrated gating clock unit can refer to the prior art and is not limited here.
[0046] It can be seen that by adjusting the clock selection signal corresponding to each clock source, under the cooperation of each enable signal generating module, delay module and gate control module, the target clock source can be output to the clock output logic module 170 through the corresponding gate control module at a low level, and other clock sources cannot be output to the clock output logic module 170 through the corresponding gate control module at a low level, so that the clock output logic module 170 can output the target clock source and complete the clock switching. In this switching circuit, due to the effect of the gate control module, the clock switching can be switched at a low level, thereby ensuring that the clock switching circuit can switch smoothly without burrs when switching the clock, and avoiding the clock signal output by the clock output logic module 170 from generating burrs.
[0047] In some of these embodiments, see Figures 7 to 9 The first enable signal generating module 110 includes a first NOR gate U1 and a first synchronizer 111, and the first delay module 120 includes a first trigger U2. The first NOR gate U1 is respectively connected to the second delay module 1501, the first clock selection signal sel1, and the first synchronizer 111, the set end of the first synchronizer 111 and the set end of the first trigger U2 are both connected to the set signal clk0_rst_n of the first clock source 210, the clock input end of the first synchronizer 111 and the clock input end of the first trigger U2 are both connected to the first clock source 210, the output end of the first synchronizer 111 is respectively connected to the enable end of the first gating module 130 and the input end of the first trigger U2, and the output end of the first trigger U2 is also connected to each second enable signal generating module.
[0048] The first NOR gate U1 is used to output a high level when all input signals are at a low level, and to output a low level when only one input signal is at a high level.
[0049] The first synchronizer 111 may be composed of two triggers connected in series, which can be used to reduce the risk of metastable state. The first trigger U2 may adopt a rising edge triggered D trigger. The specific structures of the first synchronizer 111 and the first trigger U2 may refer to the prior art and are not limited here.
[0050] When the set signal clk0_rst_n of the first clock source 210 is at a high level, the first synchronizer 111 and the first trigger U2 output a high level. In this way, when the system is initially powered on or when other clock sources fail, the first gating module 130 can be controlled to output the first clock source 210, so that the clock switching circuit switches to the first clock source output.
[0051] In the clock switching circuit, the first NOR gate U1 can be used to output a high level to the first synchronizer 111 when the input signals are all low levels, so that the first synchronizer 111 outputs a high level to the first gating module 130, and to output a low level to the first synchronizer 111 when the input signals are all high levels, so that the first synchronizer 111 outputs a low level to the first gating module 130.
[0052] In some embodiments, the second enable signal generating module includes a second NOR gate and a second synchronizer, and the second delay module includes a second trigger. The second NOR gate is respectively connected to the second clock signal of the corresponding second clock source, the first delay module 120, other second triggers in the clock switching circuit except the second trigger corresponding to the second enable signal generating module, and the corresponding second synchronizer, and the second synchronizer is also connected to the corresponding first logic module, the corresponding second logic module, the corresponding second gating module and the corresponding second trigger.
[0053] For example, in Figure 7In the illustrated embodiment, the second enable signal generating module 1401 includes a second NOR gate U11 and a second synchronizer 14011, and the second delay module 1501 includes a second trigger U21, wherein the first input end of the second NOR gate U11 is connected to the clock selection signal sel21 of the second clock source 2201, the second input end is connected to the delay signal q1 of the first delay module 120, and the output end is connected to the second synchronizer 14011, the clock input end of the second synchronizer 14011 and the clock input end of the second trigger U21 are both connected to the second clock source 2201, the output end of the second synchronizer 14011 is respectively connected to the enable end of the second gating module 1601 and the input end of the second trigger U21, and the output end of the second trigger U21 is also connected to the input end of the first NOR gate U1.
[0054] For example, in Figure 8 In the illustrated embodiment, the first second enable signal generating module 1401 includes a second NOR gate U11 and a second synchronizer 14011, and the second delay module 1501 includes a second trigger U21, wherein the first input end of the second NOR gate U11 is connected to the clock selection signal sel21 of the first second clock source 2201, the second input end is connected to the output end of the first trigger U2, the third input end is connected to the output end of the second trigger U22, and the output end is connected to the second synchronizer 14011, the clock input end of the second synchronizer 14011 and the clock input end of the second trigger U21 are both connected to the second clock source 2201, the output end of the second synchronizer 14011 is respectively connected to the enable end of the second gating module 1601 and the input end of the second trigger U21, and the output end of the second trigger U21 is also connected to the input end of the first NOR gate U1 and the input end of the second NOR gate U12. The second second enable signal generating module 1402 includes a second NOR gate U12 and a second synchronizer 14012, and the second delay module 1502 includes a second trigger U22, wherein the first input end of the second NOR gate U12 is connected to the clock selection signal sel22 of the second second clock source 2202, the second input end is connected to the output end of the first trigger U2, the third input end is connected to the output end of the first trigger U21, and the output end is connected to the second synchronizer 14012, the clock input end of the second synchronizer 14012 and the clock input end of the second trigger U22 are both connected to the second clock source 2202, the output end of the second synchronizer 14012 is respectively connected to the enable end of the second gating module 1602 and the input end of the second trigger U22, and the output end of the second trigger U22 is also connected to the input end of the first NOR gate U1 and the input end of the second NOR gate U11.
[0055] The second synchronizer can be composed of two triggers connected in series, which can be used to reduce the risk of metastable state. The second trigger can adopt a rising edge triggered D trigger. The specific structure of the second synchronizer and the second trigger can refer to the existing technology and is not limited here.
[0056] In the clock switching circuit, the second NOR gate can be used to output a high level to the corresponding second synchronizer when the input signals are all low levels, thereby causing the second synchronizer to output a high level to the corresponding second gating module, and to output a low level to the corresponding second synchronizer when the input signal is at a high level, thereby causing the second synchronizer to output a low level to the corresponding first gating module.
[0057] In some embodiments, the clock switching circuit also includes N first logic modules. Each first logic module, each second clock source, each second delay module corresponds to each second enable signal generating module one by one, and the first logic module is respectively connected to the indication signal of the corresponding second clock source, the reset signal of the corresponding second clock source, the corresponding second enable signal generating module, and the corresponding second delay module. Among them, the indication signal is used to indicate whether the corresponding second clock source is in place, and the reset signal is used to indicate whether the corresponding second clock source needs to be reset. The first logic module is used to output the first logic signal according to the indication signal and the reset signal. The second enable signal generating module and the second delay module are both used to confirm whether to reset according to the first logic signal.
[0058] In the embodiment where N=1, see Figure 7 , the N first logic modules include a first logic module 1801, a first input terminal of the first logic module 1801 is connected to the indication signal clk21_lock corresponding to the second clock source, a second input terminal is connected to the reset signal clk21_rst_n corresponding to the second clock source, and an output terminal is respectively connected to the reset terminal of the second synchronizer 14011 and the reset terminal of the second trigger U21. In the embodiment where N=2, refer to Figure 8 The N first logic modules include a first logic module 1801 and a first logic module 1802, the first input end of the first logic module 1801 is connected to the indication signal clk21_lock corresponding to the second clock source, the second input end is connected to the reset signal clk21_rst_n corresponding to the second clock source, and the output end is respectively connected to the reset end of the second synchronizer 14011 and the reset end of the second trigger U21, the first input end of the first logic module 1802 is connected to the indication signal clk22_lock corresponding to the second clock source, the second input end is connected to the reset signal clk22_rst_n corresponding to the second clock source, and the output end is respectively connected to the reset end of the second synchronizer 14012 and the reset end of the second trigger U22.
[0059] In the clock switching circuit, when the reset signal is at a low level, it indicates that the corresponding second clock source needs to be reset, and when it is at a high level, it indicates that the corresponding second clock source does not need to be reset. When the indication signal is at a low level, it indicates that the corresponding second clock source has no clock, and when it is at a high level, it indicates that the corresponding second clock source has a clock. The reset signal and the indication signal are logically judged by the first logic module, and the first logic signal is output to control the operation of the second enable signal generating module and the second delay module, so as to ensure that the system can reset the corresponding second enable signal generating module and the second delay module when a certain clock source is lost, so that the delay signal output by the system is at a low level, so that other clock switching is not affected when the clock source fails.
[0060] In some of these embodiments, see Figures 7 to 9 The first logic module includes a first AND gate. Each first AND gate, each second clock source, each second delay module and each second enable signal generating module correspond to each other one by one. The first input end of the first AND gate is connected to the indication signal of the corresponding second clock source, the second input end of the first AND gate is connected to the reset signal of the corresponding second clock source, and the output end of the first AND gate is respectively connected to the corresponding second enable signal generating module and the corresponding second delay module.
[0061] As in Figure 7 In the illustrated embodiment, the first input end of the first AND gate U41 is connected to the indication signal of the first second clock source 2201, the second input end of the first AND gate U41 is connected to the reset signal of the first second clock source 2201, and the output end of the first AND gate U41 is connected to the reset end of the second synchronizer 14011 and the reset end of the second flip-flop U21, respectively. In this way, when the first second clock source 2201 is lost or fails, the AND gate can output a low-level signal to the reset end of the second synchronizer 14011 and the reset end of the second flip-flop U21, so that the second synchronizer 14011 and the second flip-flop U21 are reset, and the second delay signal output by the second flip-flop U21 is low-level, which can not affect the clock switching circuit to switch other clock sources.
[0062] In some embodiments, the clock switching circuit further includes N second logic modules. Each second logic module, each second clock source, each second delay module, each second enable signal generating module corresponds to each second gating module one by one, and the second logic module is respectively connected to the corresponding second clock source, the corresponding indication signal of the second clock source, the corresponding second enable signal generating module, the corresponding second delay module and the corresponding second gating module. The second logic module is used to confirm whether to output the second clock source to the second gating module and the second enable signal generating module according to the indication signal.
[0063] In the embodiment where N=1, see Figure 7, the N second logic modules include a second logic module 1901, a first input end of the second logic module 1801 is connected to the second clock source 2201, a second input end is connected to the indication signal clk21_lock corresponding to the second clock source, and an output end is respectively connected to the clock input end of the second synchronizer 14011, the clock input end of the second trigger U21 and the first second gating module 1601. In the embodiment where N=2, refer to Figure 8 The N second logic modules include a second logic module 1801 and a second logic module 1802, wherein the first input end of the second logic module 1801 is connected to the second clock source 2201, the second input end is connected to the indication signal clk21_lock corresponding to the second clock source, and the output end is respectively connected to the clock input end of the second synchronizer 14011, the clock input end of the second trigger U21 and the first second gating module 1601; the first input end of the second logic module 1802 is connected to the second clock source 2202, the second input end is connected to the indication signal clk22_lock corresponding to the second clock source, and the output end is respectively connected to the clock input end of the second synchronizer 14012, the clock input end of the second trigger U22 and the second second gating module 1602.
[0064] In the clock switching circuit, the second logic module performs corresponding logic judgment on the input clock source and then outputs it to the subsequent circuit, which can improve the reliability of the circuit operation.
[0065] In some embodiments, the second logic module includes a second AND gate. Each second AND gate, each second clock source, each second delay module, each second enable signal generating module corresponds to each second gating module one by one, the first input end of the second AND gate is connected to the corresponding second clock source, the second input end of the second AND gate is connected to the indication signal of the corresponding second clock source, and the output end of the second AND gate is respectively connected to the corresponding second enable signal generating module, the corresponding second delay module and the corresponding second gating module.
[0066] As in Figure 8 In the illustrated embodiment, the first input end of the second AND gate U31 is connected to the first second clock source 2201, the second input end of the second AND gate U31 is connected to the indication signal of the first second clock source 2201, and the output end of the second AND gate U31 is respectively connected to the clock input end of the second synchronizer 14011, the clock input end of the second trigger U21 and the first gating module 1601. In this way, a high level can be output to the first gating module only when the indication signal of the second clock source 2201 and the second clock source 2201 are both at a high level, thereby improving the reliability of the circuit operation.
[0067] In some embodiments, if N=1, see Figure 7, the clock output logic module 170 includes a third logic module 1701 , a first input end of the third logic module 1701 is connected to the first gating module 130 , and a second input end of the third logic module 1701 is connected to the second gating module 1601 .
[0068] If N is greater than 1, see Figure 8 or Fig. 9 , the clock output logic module 170 includes N third logic modules, the first input end of the first third logic module is connected to the first gating module 130, the second input end of the first third logic module is connected to the first second gating module 1601, the first input end of the nth third logic module is connected to the output end of the n-1th third logic module, and the second input end of the nth third logic module is connected to the nth second gating module, where n is an integer greater than 1 and less than N+1.
[0069] like Figure 8 In the illustrated embodiment, N=2, which includes two third logic modules, namely a third logic module 1701 and a third logic module 1702. The first input end of the first third logic module 1701 is connected to the first gating module 130, the second input end of the first third logic module 1701 is connected to the first second gating module 1601, the first input end of the second third logic module 1702 is connected to the output end of the first third logic module 1701, and the second input end of the second third logic module 1702 is connected to the second second gating module 1602.
[0070] In this embodiment, by providing a plurality of third logic modules, the target clock source can be output through the last output port.
[0071] In some embodiments, the third logic module includes a first inverter, a second inverter and a NAND gate. The input end of the first inverter is the first input end of the third logic module, the input end of the second inverter is the second input end of the third logic module, the input end of the NAND gate is connected to the output end of the first inverter and the output end of the second inverter respectively, and the output end of the NAND gate is the output end of the third logic module.
[0072] In the embodiment where N=2, see Figure 8 The third logic module 1701 includes a first inverter U51, a second inverter U51 and a NAND gate U71, and the third logic module 1702 includes a first inverter U51, a second inverter U62 and a NAND gate U72. Under the operation of the above logic gates, the target clock source can be output through the final output port.
[0073] Combine the following Figure 8 The illustrated embodiment describes in detail the specific working process of the clock switching circuit provided by the present invention.
[0074] like Fig.10 As shown, it is a schematic diagram of working signals in which the first clock source 210, the second clock source 2201, and the second clock source 2202 are all stable. When the clock selection signal sel1 of the first clock source 210, the clock selection signal sel2 of the second clock source 2201, and the clock selection signal sel3 of the second clock source 2202 are 0, 1, and 1 respectively, the output terminal clk_out of the clock output logic module 170 is the output of the first clock source 210. When the clock selection signal sel1 of the first clock source 210, the clock selection signal sel2 of the second clock source 2201, and the clock selection signal sel3 of the second clock source 2202 are switched from 0, 1, and 1 to 1, 0, and 1 respectively, the output terminal clk_out of the clock output logic module 170 switches from the first clock source 210 to the second clock source 2201. When the clock selection signal sel1 of the first clock source 210, the clock selection signal sel2 of the second clock source 2201 and the clock selection signal sel3 of the second clock source 2202 are switched from 1, 0, 1 to 1, 1, 0 respectively, the output terminal clk_out output of the clock output logic module 170 switches from the second clock source 2201 to the second clock source 2202.
[0075] It can be seen that due to the existence of the gating module (integrated gating clock unit), the clock switching is smoothly switched without burrs at a low level, so the signal output by the output terminal clk_out can be prevented from generating burrs during the clock switching stage.
[0076] like Fig.11As shown, it is a schematic diagram of the working signal when the first clock source and the second clock source 2202 exist stably and the second clock source 2201 fails to stay at a high level during operation. When the clock selection signal sel1 of the first clock source 210, the clock selection signal sel2 of the second clock source 2201, and the clock selection signal sel3 of the second clock source 2202 are 0, 1, and 1 respectively, the output terminal clk_out of the clock output logic module 170 selects the first clock source 210 for output. When the clock selection signal sel1 of the first clock source 210, the clock selection signal sel2 of the second clock source 2201, and the clock selection signal sel3 of the second clock source 2202 are switched from 0, 1, and 1 to 1, 0, and 1 respectively, the output terminal clk_out of the clock output logic module 170 switches from the first clock source 210 to the second clock source 2201. If the second clock source 2201 stays at a high level due to a fault during operation, the indication signal clk21_lock of the second clock source 2201 changes from 1 to 0, and the AND gate U41 outputs 0 to the second synchronizer 14011 and the second trigger U21, both of which are reset, and the output signals of the enable signal e21 and the delay signal q21 are both 0, the output of the second gating module 1601 is 0, and the output of the corresponding inverter U61 is 1, which does not affect the output of the output terminal clk_out. Thereafter, when the clock selection signal sel1 of the first clock source 210, the clock selection signal sel2 of the second clock source 2201, and the clock selection signal sel3 of the second clock source 2202 are switched from 1, 0, 1 to 1, 1, 0 respectively, after 3 beats, i.e. after being sampled by the three triggers of the second synchronizer 14011 and the second trigger U21, the output signal d22 of the second NOR gate U12, the output signal e22 of the second synchronizer 14012, and the output signal q22 of the second trigger U22 all become 1, and finally the output terminal clk_out outputs the second clock source 2202. It can be seen that when a clock source of the switching circuit stays at a high level due to a fault during operation, the system can still perform clock switching. Compared to Figure 5 The circuit shown in the present application provides a clock switching circuit that can still perform clock switching when a certain clock is lost.
[0077] In summary, the clock switching circuit provided by the present invention can be used for safe and smooth switching of multiple clock sources without glitches, and when the clock source fails and the clock disappears, causing the clock to stay at a low level or a high level, the clock output can still be switched to other stable clock sources. Application in modern digital chips can greatly improve the robustness and stability of the chip, ensure that the system can still operate safely under extreme fault conditions, enhance the reliability of the chip, and have great engineering practical value.
[0078] In a second aspect, an embodiment of the present application provides an electronic device, the electronic device comprising a clock switching circuit as described in any one of the embodiments of the first aspect. In this embodiment, the clock switching circuit has the same structure and function as the clock switching circuit as described in any one of the first aspect, which will not be described in detail here. The electronic device can be an electronic chip, an electrical device, etc.
[0079] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0080] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A clock switching circuit, characterized in that: The clock switching circuit is used to switch the first clock source and N second clock sources, N is an integer greater than or equal to 1, and the clock switching circuit includes a first enable signal generating module, a first delay module, a first gating module, N second enable signal generating modules, N second delay modules, N second gating modules, and a clock output logic module; Each of the second clock sources, each of the second enable signal generating modules, each of the second delay modules and each of the second gating modules corresponds one to one; The first enable signal generating module is respectively connected to the first clock selection signal of the first clock source, each of the second delay modules, the first delay module and the first gating module, the first gating module is also connected to the first clock source and the clock output logic module, the second enable signal generating module is respectively connected to the second clock selection signal of the corresponding second clock source, each of the second delay modules, the first delay module, the corresponding second gating module, the second gating module is also connected to the corresponding second clock source and the clock output logic module; The first clock selection signal is used to indicate whether the first clock source is the target clock source to be switched and output, and the second clock selection signal is used to indicate whether the corresponding second clock source is the target clock source; The second enable signal generating module is used to generate a second enable signal according to the corresponding second clock selection signal, the first delay signal output by the first delay module, and the second delay signal output by other second delay modules in the clock switching circuit except the second delay module corresponding to the second enable signal generating module; The first enable signal generating module is used for generating a first enable signal according to the first clock selection signal and the second delay signals output by each of the second delay modules; The first delayed signal is a signal after the first enable signal is delayed, and the second delayed signal is a signal after the second enable signal is delayed generated by the second enable signal generating module corresponding to the second delay module; The first gating module is used for outputting or stopping outputting to the clock output logic module when the first clock source is at a low level according to the first enable signal; The second gating module is used for outputting or stopping outputting to the clock output logic module when the corresponding second clock source is at a low level according to the second enable signal; The clock output logic module is used to output the target clock source through the output end of the clock output logic module according to the output signals of the first gating module and the second gating module.
2. The clock switching circuit according to claim 1, characterized in that: The clock switching circuit also includes N first logic modules; Each of the first logic modules, each of the second clock sources, each of the second delay modules and each of the second enable signal generating modules corresponds one to one, and the first logic module is respectively connected to the indication signal of the corresponding second clock source, the reset signal of the corresponding second clock source, the corresponding second enable signal generating module, and the corresponding second delay module; The indication signal is used to indicate whether the corresponding second clock source is in place, and the reset signal is used to indicate whether the corresponding second clock source needs to be reset; The first logic module is used to output a first logic signal according to the indication signal and the reset signal; The second enable signal generating module and the second delay module are both used to confirm whether to reset according to the first logic signal.
3. The clock switching circuit according to claim 2, characterized in that: The first logic module includes a first AND gate; Each of the first AND gates, each of the second clock sources, each of the second delay modules and each of the second enable signal generating modules correspond one to one, the first input end of the first AND gate is connected to the indication signal of the corresponding second clock source, the second input end of the first AND gate is connected to the reset signal of the corresponding second clock source, and the output ends of the first AND gate are respectively connected to the corresponding second enable signal generating module and the corresponding second delay module.
4. The clock switching circuit according to claim 2 or 3, characterized in that: The clock switching circuit also includes N second logic modules; Each of the second logic modules, each of the second clock sources, each of the second delay modules, each of the second enable signal generating modules and each of the second gating modules correspond one to one, and the second logic modules are respectively connected to the corresponding second clock source, the corresponding indication signal of the second clock source, the corresponding second enable signal generating module, the corresponding second delay module and the corresponding second gating module; The second logic module is used to determine whether to output the second clock source to the second gating module and the second enable signal generating module according to the indication signal.
5. The clock switching circuit according to claim 4, characterized in that: The second logic module includes a second AND gate; Each of the second AND gates, each of the second clock sources, each of the second delay modules, and each of the second enable signal generating modules corresponds one-to-one to each of the second gating modules, the first input end of the second AND gate is connected to the corresponding second clock source, the second input end of the second AND gate is connected to the indication signal of the corresponding second clock source, and the output ends of the second AND gate are respectively connected to the corresponding second enable signal generating module, the corresponding second delay module, and the corresponding second gating module.
6. The clock switching circuit according to claim 4, characterized in that: If N=1, the clock output logic module includes a third logic module, a first input end of the third logic module is connected to the first gating module, and a second input end of the third logic module is connected to the second gating module; If N is greater than 1, the clock output logic module includes N third logic modules, the first input end of the first third logic module is connected to the first gating module, the second input end of the first third logic module is connected to the first second gating module, the first input end of the nth third logic module is connected to the output end of the n-1th third logic module, and the second input end of the nth third logic module is connected to the nth second gating module, where n is an integer greater than 1 and less than N+1.
7. The clock switching circuit according to claim 6, characterized in that: The third logic module includes a first inverter, a second inverter and a NAND gate; The input end of the first inverter is the first input end of the third logic module, the input end of the second inverter is the second input end of the third logic module, the input end of the NAND gate is respectively connected to the output end of the first inverter and the output end of the second inverter, and the output end of the NAND gate is the output end of the third logic module.
8. The clock switching circuit according to claim 4, characterized in that: The first enable signal generating module includes a first NOR gate and a first synchronizer, and the first delay module includes a first trigger; The first NOR gate is respectively connected to the second delay module, the first clock selection signal, and the first synchronizer. The first synchronizer is also connected to the set signal of the first clock source, the first clock source, the first gating module and the first trigger. The first trigger is also connected to each of the second enable signal generating modules.
9. The clock switching circuit according to claim 8, characterized in that: The second enable signal generating module includes a second NOR gate and a second synchronizer, and the second delay module includes a second trigger; The second NOR gate is respectively connected to the second clock signal of the corresponding second clock source, the first delay module, the other second triggers in the clock switching circuit except the second trigger corresponding to the second enable signal generating module, and the corresponding second synchronizer. The second synchronizer is also connected to the corresponding first logic module, the corresponding second logic module, the corresponding second gating module and the corresponding second trigger.
10. An electronic device, characterized in that: Comprising a clock switching circuit as described in any one of claims 1-9.
