How would one go about making a shift register which only shifts when an enable line is high? The obvious answer is to pass the clock and enable through an AND gate, but that breaks the "don't gate clocks" rule. Another possibility might be using a mux to select the input of each flip-flop to either be the previous flip-flop's output, or to feed its own output back to the input. That would work for the shift register, but is there a better way? How are similar effects achieved in complex designs, where portions of the functionality can be temporarily stopped to save power?


3 Answers 3


Depends on the flip-flop used in the shift register. Effectively, negate the enable line or assert the disable line :-), but you know that.

I'd ask, "Why not gate clocks, provided that you gate them 'properly'?"

A hazard is that if you asynchronously gate a clock you may (~= 50% chance for a symmetric clock) produce an additional clock transition at disable or re-enable time. ie DO NOT DO THIS

enter image description here

BUT if you gate synchronously so that eg when gate off the clock continues to its next high/low transition, then stays low while still gated off, then when gated on resumes on the next clock low/high edge.
As described that may allow a very narrow spike at either edge if gating signal just precedes a clock low/ high transition but a bit of common sense in implementation stops that.

Effectively if delay is acceptable between provided and utilised clock signal (and usually one clock cycle is indistinguishable from the next) then having a toggling FF in the clock line and disabling it will implement the above (possibly with the described spike hazard present.)

In this circuit from - FPGA Design tips

They say

  • The following figure shows a synchronous alternative to the gated clock using a data path. The flip-flop is clocked at every clock cycle and the data path is controlled by an enable. When the enable is Low, the multiplexer feeds the output of the register back on itself. When the enable is High, new data is fed to the flip-flop and the register changes its state. This circuit guarantees a minimum clock pulse width and it does not add skew to the clock. The XC4000, Spartan-II, and Virtex families' flip-flops have a built-in clock-enable (CE).

enter image description here

Partially answering my "why not" question above - the gated clock will be delayed by the toggle propogation delay of the gating flip-flop. In some cases this does not matter, in others it's clearly ubbacceptable. The 3rd, worst case, is where it seems OK but sometimes just may not be, on an intermittent basis. So, use with care.

On this page Roadie Roger warns

  • Actually gating clocks is relatively evil. Having a gated clock that transitions less often does save power. Every signal edge is a power waster in the face of capacitance. Gated clocks create other problems. Your clocks are no longer exactly lined up. Many chips have a global clock that goes everywhere. Breaking it into pieces isn't a good thing. You want to enable data rather than gate clocks. Call the Enable 'E'. This looks something like:

And Robert usefully counters

  • Depends on your target technology. The above may hold for FPGA's, but for standard-cell based ASIC technologies, gated clocks are an elegant (in my opinion) and clean methodology for low-power design.

    In this case, you will most likely be using a clock tree generator anyway, and all of the clock tree generators I know easily handle clock gates. They will automatically align the clocks AFTER any possible gates, i.e. at the leaf nodes (clock inputs of registers). In this case, generating a low-skew clock tree is far easier for gated clocks than for derived clocks (i.e. divided clocks).

    Modern synthesis tools also can insert clock gates automatically by replacing register enables (as shown in the post above) by gated clocks. This can be handy, but it has the drawback of reducing your control over clock gates (names, hierarchy).

    Inserting clock gates in a VHDL design is easy. Just decide what gating style you want/need (and/or based, with/without latch, with test bypass, observability, ...).

    My choice is to then explicitly instantiate a clock gating element where needed. This has the disadvantage of requiring one to "route" different clock signals through the design, but it gives you full control over clock gating elements for use in later stages of the design (clock tree generation, physical optimization, ...).

    Information about "clean" clock gating can be found in books or also in synthesis tool manuals (where automatic clock gate insertion is described). Probably you'll also find resources on the web.

  • \$\begingroup\$ Interesting. I hadn't realized that there were such different design rules between FPGAs and ASICs. \$\endgroup\$
    – Theran
    Sep 28, 2011 at 4:10

Depending upon what you can guarantee about the timing of the enable line relative to clock, the easiest approach may be to gate the clock. If the enable is guaranteed not to change near a clock edge, you could use a flip flop with ClockIn and /Reset tied to the clock input, and Data tied to the enable input. Provided that the flip flop doesn't mind having clock and /Reset both change at the same time, that approach will give nice full-width clock pulses no matter what the enable does, provided the enable pulse doesn't violate the sample/hold times of the flip flop.

If the flip flop doesn't guarantee that a simultaneous rising edge on clock and /reset will cause the flip flop to clock in data, it may be necessary to use two flip flops and some xor gates to generate a really nice gated clock.

A two-flip-flop approach may be found here.

Provided that the sample/hold times for the flip flops are not violated, every clock pulse will either be passed through at its full width, or not passed through at all.


Most systems solve this by double-latching.

A positive-edge D flip-flop on each output of the shift register will take a snap-shot of each of the bits of the shift register when the enable line transitions from low to high. It doesn't matter what shifting happens when the enable line is high, only what is left in there when it transitions from low to high.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.