TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

Low-Power FIFO Design: Clock Gating and Bank Gating Without Losing Throughput (FIFO Series, Part 28)

The Semiconductor Hub
by
0
Share Facebook X LinkedIn WhatsApp Email
Hand-drawn cover card for FIFO Series Part 28, Low-Power FIFO, with a sketch of entries moving from push to pop.

Most FIFOs spend most of their time nearly empty. A response queue sized for the worst burst may hold one or two entries on a normal day, yet every flop in it is clocked every cycle and every bit of its SRAM leaks whether it holds data or not. On a chip with hundreds of FIFOs, that idle cost adds up, and in battery-powered or thermally limited designs it is often worth real effort to remove.

This part builds a low-power FIFO in two layers. The first is clock gating: nothing toggles unless a push or a pop needs it to. The second is bank gating: the storage is split into banks, and banks that hold no data are switched off and woken just before the write pointer needs them, so throughput does not suffer.

Key takeaways

  • Clock gating comes almost for free in a well-written FIFO: write only the addressed entry, load the read register only on a pop, and let synthesis turn those enables into clock gates.
  • Bank gating saves leakage by switching off empty banks. Only empty banks can be switched off, because their contents are lost.
  • Keep two banks awake: the one the write pointer is in and the next one. With wake latency below the bank size, a push every cycle never stalls.
  • With only two banks, both are always needed, so nothing ever sleeps. Bank gating needs three or more banks.
  • Add hysteresis. A bank should stay off long enough to pay back the energy of switching it off and on.

In this part

What problem it solves

A FIFO burns power in three ways. Clock power is the clock tree and the flop clock pins toggling every cycle, whether or not data moves. Switching power is data toggling through the write path, the read mux and the output register. Leakage is the static current of every transistor, and for a deep FIFO it is dominated by the storage.

Clock and switching power fall when the FIFO is idle only if the design lets them. Leakage does not fall at all unless part of the storage is actually switched off. A low-power FIFO attacks all three without changing what the producer and consumer see, apart from a short stall in rare cases.

The interface

Hand-drawn block diagram of a low-power FIFO with storage split into four banks, two of them powered off, a bank controller driving bank_on signals to power switches, and clock gates on the write and read paths.

The read side is unchanged: pop, rdata and empty. On the write side, full is replaced by wready, which is low when the FIFO is full or when the bank the next push would go to is not yet awake. A producer that already obeys a ready signal needs no change.

The FIFO also drives bank_on, one bit per bank, to the power switches or to the power controller. In a real design the switch returns an acknowledge when the bank is safe to use; the sketch below models that with a fixed wake time, WAKE cycles.

Micro-architecture

Clock gating. In the Part 1 FIFO, every storage entry has a write enable and the read register has a load enable. Synthesis maps those enables to integrated clock-gating cells, so an entry is clocked only when it is written. Two habits keep it that way: do not reset the storage array, and do not load rdata on cycles with no pop. A coarse gate on the whole FIFO, enabled by push, pop or any pending state change, saves the remaining clock-tree power when the FIFO is idle.

Bank gating. Split DEPTH entries into NB banks of BS entries. The write pointer moves through the banks in order, so we always know which bank the next push lands in, and which bank comes after it. Each bank has a three-state controller:

Hand-drawn state diagram of a bank controller with states OFF, WAKING and ON: a needed bank starts waking, becomes ON after the wake time, and returns to OFF after staying empty and unneeded for IDLE cycles.
  • OFF to WAKING when the bank is needed: it is the write bank or the next one.
  • WAKING to ON after the wake time.
  • ON to OFF after the bank has held no data and not been needed for IDLE cycles in a row. Any data or need resets the count.

Whether a bank holds data comes from a valid bit per entry, set on push and cleared on pop. A bank that holds data is never switched off, so the reader can never land in a dead bank. The write bank is always needed, so a push can never land in one either.

Why wake the next bank early? A push every cycle crosses a bank in BS cycles. If the next bank starts waking as soon as the write pointer enters the current one, it has BS cycles to come up. The model confirms the exact rule for this controller: with WAKE at most BS minus 1, a steady push every cycle never stalls; at WAKE equal to BS, it starts to stall.

RTL sketch

module lp_fifo #(
  parameter int W     = 32,
  parameter int DEPTH = 32,                 // power of two
  parameter int NB    = 4,                  // banks, power of two, 3 or more useful
  parameter int WAKE  = 4,                  // cycles, keep WAKE <= DEPTH/NB - 1
  parameter int IDLE  = 16,                 // empty cycles before a bank sleeps
  localparam int AW = $clog2(DEPTH), BS = DEPTH / NB,
  localparam int BW = $clog2(NB),    SW = $clog2(BS)
) (
  input  logic          clk, rst_n,
  input  logic          push,
  input  logic [W-1:0]  wdata,
  output logic          wready,
  input  logic          pop,
  output logic [W-1:0]  rdata,
  output logic          empty,
  output logic [NB-1:0] bank_on             // to the power switches
);
  logic [W-1:0]     mem [DEPTH];
  logic [AW:0]      wptr, rptr;
  logic [DEPTH-1:0] valid;
  logic [NB-1:0]    on, need, busy;
  logic [$clog2(WAKE+1)-1:0] wcnt [NB];
  logic [$clog2(IDLE+1)-1:0] idle [NB];

  assign empty   = (wptr == rptr);
  wire   full    = (wptr[AW-1:0] == rptr[AW-1:0]) && (wptr[AW] != rptr[AW]);
  wire [BW-1:0] wb = wptr[AW-1:SW];         // bank of the next push
  wire [BW-1:0] nb = wb + 1'b1;             // the bank after it
  assign wready  = on[wb] && !full;
  assign bank_on = on;

  wire do_pop  = pop && !empty;
  wire do_push = push && on[wb] && (!full || do_pop);

  always_comb
    for (int b = 0; b < NB; b++) begin
      need[b] = (BW'(b) == wb) || (BW'(b) == nb);
      busy[b] = |valid[b*BS +: BS];
    end

  always_ff @(posedge clk or negedge rst_n)
    if (!rst_n) begin
      wptr <= '0;  rptr <= '0;  valid <= '0;  on <= '0;
      for (int b = 0; b < NB; b++) begin wcnt[b] <= '0; idle[b] <= '0; end
    end else begin
      if (do_push) wptr <= wptr + 1'b1;
      if (do_pop)  rptr <= rptr + 1'b1;
      if (do_pop)  valid[rptr[AW-1:0]] <= 1'b0;
      if (do_push) valid[wptr[AW-1:0]] <= 1'b1;   // wins at full with a pop
      for (int b = 0; b < NB; b++)
        if (!on[b]) begin                          // OFF or WAKING
          if (wcnt[b] != 0) begin
            wcnt[b] <= wcnt[b] - 1'b1;
            if (wcnt[b] == 1) on[b] <= 1'b1;
          end else if (need[b]) wcnt[b] <= WAKE;
        end else if (busy[b] || need[b]) idle[b] <= '0;
        else if (idle[b] == IDLE - 1) begin
          on[b] <= 1'b0;  idle[b] <= '0;
        end else idle[b] <= idle[b] + 1'b1;
    end

  always_ff @(posedge clk) begin                 // enables become clock gates
    if (do_push) mem[wptr[AW-1:0]] <= wdata;
    if (do_pop)  rdata <= mem[rptr[AW-1:0]];
  end
endmodule

A Python model of this sketch, in which a bank that is switched off loses its contents, ran 750,000 random cycles at five configurations with idle, trickle, busy and burst phases. It checked every popped value against a reference queue and asserted that no push or pop ever touched a bank that was off and no bank was switched off while holding data. All passed.

Corner cases

Hand-drawn timing diagram of a low-power FIFO: the write pointer moves into bank 1, bank 2 starts waking and is on before the write pointer reaches it, and bank 0 goes off after staying empty for the idle time.
  • Out of reset. All banks start off, so the first push waits for bank 0 to wake. If that delay matters, reset bank 0 and bank 1 to on instead.
  • Two banks. The write bank and the next bank are the whole FIFO, so neither can ever sleep. The model shows zero bank-off time at NB of 2, as expected.
  • A slow reader. The reader can sit in an old bank for a long time. That bank stays on because its valid bits are set. Only banks fully between the read and write pointers on the empty side can sleep.
  • Wake too slow. With WAKE of BS or more, a fast producer catches up with the waking bank and wready drops. That is safe, just slower. Fix it with larger banks or a lookahead of two banks.
  • Bursty traffic and thrashing. Without hysteresis, a bank could switch off one cycle and be needed the next. IDLE sets how long a bank must stay unused before it sleeps.
  • Push and pop at full. All banks hold data, all stay on, and the push lands in the entry the pop frees, as in Part 1.

Timing, area and power

  • Break-even time. Switching a bank off and on costs energy: the switch control, recharging the bank's internal nodes, and the controller itself. Sleeping pays only if the bank stays off longer than the break-even time for that library. Use it to set IDLE, rather than picking a round number.
  • Isolation. Outputs of an off bank float. Clamp them with isolation cells, or make sure the read mux never selects an off bank, which the valid-bit rule already guarantees.
  • Inrush. Waking a large bank draws a current spike. With a lookahead of one bank, at most one bank wakes at a time in steady state, which helps. Very large banks may need staged switches.
  • Area. The valid bits cost DEPTH flops. A cheaper alternative compares each bank's address range against the read and write pointers. The power switches and isolation cells add area per bank, so a few large banks are often better than many small ones.
  • SRAM modes. Many SRAM compilers offer light sleep with data retained and shutdown without. A FIFO can use light sleep on banks that hold data but are idle, and shutdown only on empty banks.
  • Timing. wready now depends on on[wb], a mux of a few flops. It is short, but it adds to the ready path the producer sees.

Verification checklist

  • A model in which an off bank loses its contents. Power-aware simulation from the power intent file does this for the real design; without it, a bug that reads a dead bank passes quietly.
  • Assertions:
    a_wr_on:   assert property (@(posedge clk) disable iff (!rst_n)
                 do_push |-> on[wb]);
    a_rd_on:   assert property (@(posedge clk) disable iff (!rst_n)
                 do_pop |-> on[rptr[AW-1:SW]]);
    a_off_mt:  assert property (@(posedge clk) disable iff (!rst_n)
                 !on[b] |-> !busy[b]);          // per bank, in a generate loop
  • A scoreboard on data order, as in Part 1. Bank gating must never change it.
  • Coverage: every bank going off and coming back, a stall caused by a waking bank, the lookahead wrapping from the last bank to bank 0, wake from reset, and a bank kept on by a slow reader.
  • A long streaming test with push and pop every cycle, to confirm there are no stalls at the chosen WAKE.

Interview questions

1. Your FIFO is idle most of the time. Where is the power going?

A strong answer separates clock, switching and leakage power, and maps each to a fix: clock gating on enables, no toggling of the read path, and switching off empty storage.

2. Which banks can you switch off, and which must stay on?

A strong answer keeps any bank holding data, plus the write bank and the next one, and explains that contents are lost in shutdown.

3. How early must you wake the next bank?

A strong answer relates the wake time to the time the producer needs to cross one bank at full rate, and proposes a deeper lookahead or larger banks if the wake time is longer.

4. How do you stop a bank from switching on and off every few cycles?

A strong answer adds hysteresis and ties the threshold to the break-even energy of a sleep and wake cycle.

5. How would you verify that no data is lost?

A strong answer uses power-aware simulation that corrupts off banks, assertions on writes, reads and switch-off, and an order-checking scoreboard.

Where it is used in real chips

Bank and clock gating show up in deep buffers that are rarely full: packet buffers in network interfaces and NoC routers, DMA staging buffers, accelerator input queues and display or camera line buffers. Clock gating on enables is close to universal in flop-based FIFOs. Bank power gating is more common in large SRAM-based FIFOs in mobile and other power-limited designs.

The rest of the series

Part 27 covered the ECC-protected FIFO, with SECDED correction at full throughput.

Part 29 gives one FIFO several readers: a multi-reader FIFO where each consumer has its own read pointer.

Share Facebook X LinkedIn WhatsApp Email

Post a Comment

0 Comments

Your comments will be moderated before it appears here.

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!