Algorithm Search⌘K

Techniquecore

Clock gating

Also called gated clocks.

Stops the clock of a register bank when an enable condition shows its value will not change, removing the clock and register power of idle cycles.

Clock gating stops the clock of a register when a condition shows that the register would load the value it already holds. The clock is the busiest net of a synchronous chip: in the notation P=αCV2fP = \alpha C V^2 f of dynamic power, with α\alpha the number of rising transitions per cycle, every clock pin has α=1\alpha = 1, while most data nets have α\alpha well below 1. A register that holds its value still burns the power of its clock pin, of its internal clock buffers and of the clock wires to it. Clock gating puts a gate on the clock of a register bank, controlled by an enable, so that in the cycles when the enable is off the gated clock does not rise and its whole subtree is quiet. The enable comes either from a load-enable that the design already has, or from the self-loops of a finite-state machine, as in Benini and De Micheli (1996). The gate must not make glitches on the clock, so it is built with a latch. Done right, it keeps the behavior of the circuit cycle for cycle.

In plain words

Every flip-flop gets a clock tick in every cycle, even when it has nothing new to store. Each tick costs energy.

Clock gating asks, for each group of flip-flops: will they store anything new in this cycle? If the answer is no, it holds back their clock tick. The flip-flops keep their old value, which is what they would have stored anyway, and the energy of the tick is saved. The work is in finding a cheap and safe way to know the answer one cycle ahead, and in building the switch so that it never makes a false tick.

When it applies

  • A register bank often holds its value: it has a load-enable, which in the netlist shows as a multiplexer that feeds the output back to the input, D=EN ? new:QD = EN \,?\, \mathit{new} : Q.
  • A finite-state machine often stays in its state: its state transition graph has self-loops that are taken in many cycles, such as a wait state.
  • The bank is wide enough that the gating cell, which itself has a clock pin that switches in every cycle, costs less than it saves. Banks of one or two flip-flops rarely pay off.
  • The enable is known early enough in the cycle to meet the setup time of the gating latch, as checked by static timing analysis.

The template

An integrated clock gate is a latch LL that is transparent while CLK = 0, with the enable EE at its input, followed by an AND gate: GCLK=CLK∧L\mathrm{GCLK} = \mathrm{CLK} \land L. The register bank is clocked by GCLK on its rising edge.

  1. CLOCK-GATE(design)
  2. 1for each register bank R with D = EN ? new : Q do
  3. 2remove the feedback multiplexer, so that D = new
  4. 3insert an integrated clock gate with enable E = EN, or E = EN or TE for scan test
  5. 4clock R with GCLK of the gate
  6. 5for each finite-state machine with state register S, next state δ(x, s) and inputs x do
  7. 6choose an activation function F_a with F_a(x, s) = 1 only if δ(x, s) = s
  8. 7clock S with an integrated clock gate with enable E = not F_a(x, s)

The holes are the choice of the banks in line L1, the activation function in line L6, which can be any subset of the self-loops, small enough to be cheap logic, and the grain: one gate per bank, or a gate high in the clock tree for a whole block.

Why the latch. In cycle kk, the logic that makes EE is clocked by CLK, so EE may change while CLK = 1. A plain AND gate, CLK∧E\mathrm{CLK} \land E, would then cut the high phase short or add a pulse, and a short pulse can clock some flip-flops and not others. With the latch, LL follows EE only while CLK = 0, and it is frozen while CLK = 1. So during each high phase GCLK is CLK AND a constant: either the full pulse or nothing, with no glitch. At the rising edge that ends cycle kk, LL holds the value of EE that settled during the low phase, so GCLK rises exactly when EE is 1 at the end of the cycle. This needs EE to meet the setup time of the latch before the rising edge, which STA checks as a clock gating check.

Claim 1 (line L1 to L4 keep the behavior). With the latch gate, the register R loads new\mathit{new} at the end of cycle kk if ENk=1EN_k = 1 and keeps QQ otherwise, which is what the multiplexer did. Proof. If ENk=1EN_k = 1, GCLK rises and R loads D=newD = \mathit{new}. If ENk=0EN_k = 0, GCLK stays low and R keeps QQ, which the multiplexer would have loaded. □\square

Claim 2 (gating the self-loops keeps the behavior). Take a synchronous machine with inputs xkx_k, state sks_k, next state sk+1=δ(xk,sk)s_{k+1} = \delta(x_k, s_k) and output λ(xk,sk)\lambda(x_k, s_k), a Mealy machine, with a Moore machine as the case where λ\lambda does not depend on xx. Let the gated machine load its state register only when Fa(xk,sk′)=0F_a(x_k, s'_k) = 0, where Fa(x,s)=1F_a(x, s) = 1 implies δ(x,s)=s\delta(x, s) = s. Then from the same initial state and for every input sequence, the gated machine has the same state sequence and the same output sequence.

Proof. By induction on kk, sk′=sks'_k = s_k. It holds for k=0k = 0. Assume sk′=sks'_k = s_k. If Fa(xk,sk)=0F_a(x_k, s_k) = 0, the gated register loads δ(xk,sk)=sk+1\delta(x_k, s_k) = s_{k+1}. If Fa(xk,sk)=1F_a(x_k, s_k) = 1, it keeps sks_k, and δ(xk,sk)=sk\delta(x_k, s_k) = s_k by the condition on FaF_a, so again sk+1′=sk+1s'_{k+1} = s_{k+1}. The outputs λ(xk,sk′)=λ(xk,sk)\lambda(x_k, s'_k) = \lambda(x_k, s_k) agree because the states and inputs agree. □\square

The proof does not need FaF_a to cover all self-loops. A smaller FaF_a gates fewer cycles and saves less, but it stays correct. A larger one, which also covers some (x,s)(x, s) with δ(x,s)≠s\delta(x, s) \ne s, breaks the machine. What is proved is the behavior. The saving is measured or estimated, since it depends on how often the self-loops are taken.

What the saving is. With the bank clock capacitance CRC_R and the clock gate capacitance CgC_g on the free clock, the clock power falls from CRV2fC_R V^2 f to (Cg+p CR)V2f(C_g + p\, C_R) V^2 f, where pp is the fraction of cycles with E=1E = 1. The capacitances are extracted from the layout and the library, whose pin capacitances are fitted to circuit simulations of each cell, pp comes from simulation or from a probability model, and VV and ff are design values. The formula itself has no fitted parameter.

Example (a register). A 32-bit register loads in 20% of the cycles. Assume 3 fF of clock load per flip-flop, pin and wire, so CR=96C_R = 96 fF, and Cg=5C_g = 5 fF for the clock gate. At 1 V and 1 GHz the clock power of the bank falls from 96 μ96\ \muW to (5+0.2⋅96)=24.2 μ(5 + 0.2 \cdot 96) = 24.2\ \muW, a ratio of 0.25. The multiplexers of line L2 are gone as well. These capacitances are assumed numbers for the example.

Example (a machine). A controller has the states IDLE, RUN and DONE. In IDLE it stays while start = 0 and goes to RUN when start = 1. In RUN it stays while done = 0 and goes to DONE when done = 1. From DONE it goes to IDLE. Its output busy is 1 in RUN, and in IDLE when start = 1. The full self-loop function is Fa=(s=IDLE∧¬start)∨(s=RUN∧¬done)F_a = (s = \mathrm{IDLE} \land \lnot \mathit{start}) \lor (s = \mathrm{RUN} \land \lnot \mathit{done}). If start is 1 with probability 0.1 and done with probability 0.05, independently in each cycle, the state is a Markov chain with the stationary probabilities 10/3110/31, 20/3120/31 and 1/311/31, and the self-loops are taken in (10⋅0.9+20⋅0.95)/31=28/31≈90%(10 \cdot 0.9 + 20 \cdot 0.95)/31 = 28/31 \approx 90\% of the cycles. The state register then gets a clock in only 3/31≈9.7%3/31 \approx 9.7\% of the cycles. A simulation of 200 000 cycles with seed 7 gave the same states and outputs as the ungated machine, with the register loaded in 9.56% of the cycles. The output is a Mealy output, and it stays right while the clock is off because it is computed from the inputs and the held state.

Classic examples

  • Load-enable registers. Synthesis tools find the feedback multiplexers of line L1 and replace them with clock gates, often for all banks above a minimum width.
  • Gated-clock finite-state machines. Benini and De Micheli (1996) extract FaF_a from the state transition graph, simplify it to keep its logic small, and gate the state register, as in lines L5 to L7.
  • Pipelines with valid bits. A pipeline stage is clocked only when a valid item enters it.
  • Block-level gating. A gate near the root of the clock tree of a block turns off the whole subtree when the block is idle, which saves the power of the clock buffers too.
  • Processors. Units that are not used by the current instructions, such as a floating point unit, get no clock.

Variations

  • Data-driven gating. Compare DD with QQ by XOR gates and gate the clock when they agree. This needs no knowledge of the design, but the comparators cost power and the condition is late in the cycle.
  • Multi-level gating. Gates in series down the clock tree: a coarse gate for a block and fine gates for its banks.
  • OR-based gates. For registers on the falling edge, a latch transparent while CLK = 1 and an OR gate do the same job.
  • Gating with operand isolation. The same idle signal that stops the clock of the registers can also hold the inputs of the logic between them.
  • Power gating. For long idle periods, cut the supply too, which also removes the leakage that clock gating leaves.

Pitfalls

  • Glitches from a plain AND. Without the latch, an enable that changes while CLK = 1 makes a short clock pulse.
  • Clock skew. The gate adds delay to the clock of its bank, which the clock tree must balance against the other banks, and the hold checks must include it.
  • Late enables. The enable must meet the setup time of the gating latch. A complex FaF_a can be too slow, which is one reason to simplify it.
  • Too small banks. The gate and its latch switch in every cycle. For a narrow bank or one that is enabled most of the time, they can cost more than they save.
  • Test. In scan shift mode every flip-flop must get its clock, so each gate needs a test enable TE that forces it on, as in line L3.
  • A wrong activation function. Gating any cycle in which δ(x,s)≠s\delta(x, s) \ne s loses a state change. This is a design error, not a timing error, and only an equivalence check or Claim 2 catches it.
  • Supply noise. Turning on a large gated tree at once draws a step of current, which the power grid and its decaps must handle.

Exercises

  1. Draw the waveforms of CLK, EE, the latch output and GCLK when EE falls in the middle of a high phase of CLK, for the latch gate and for a plain AND gate.
  2. Show that Claim 2 fails if Fa(x,s)=1F_a(x, s) = 1 for one pair with δ(x,s)≠s\delta(x, s) \ne s: give a machine, a pair and an input sequence with a different output.
  3. For the controller of the example, compute the fraction of gated cycles when FaF_a covers only the self-loop of IDLE.
  4. A bank of nn flip-flops with clock load cc each is enabled in a fraction pp of the cycles, and the gate has the load CgC_g. For which nn does gating save power?

References

  1. Luca Benini and Giovanni De Micheli, Automatic synthesis of low-power gated-clock finite-state machines, IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 15(6), 630 to 643, 1996, the activation function from the self-loops of a finite-state machine, its simplification, and the latch-based gate that stops the clock of the state register

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • five exercises