Draft preview. Lessons are being written and reviewed.

Digital Design / Module 8: Arithmetic and datapaths

48. Retiming and area-speed trade-offs

Decide between parallel and shared hardware.

Lecture coming soon

See it move

Retiming

Retiming moves registers through combinational logic without changing what the circuit computes. It evens out path delays. If one stage takes 5.5 ns and the next 1.5 ns, moving some logic across the register can give a more balanced result. Move the register in the animation above and watch the worst stage change.

The value of each output stays the same, cycle by cycle. The clock simply runs faster, since the longest path is now shorter. Synthesis tools can do this automatically, provided the design doesn't need specific register positions.

Parallel or shared hardware

Given a task, you can trade area against time:

  • Parallel: two multipliers process two streams, for double the and double the area.
  • Shared: one multiplier alternates between streams, for half the area and half the throughput, plus muxes and control logic.
// One multiplier shared between two streams on alternate cycles
always_ff @(posedge clk) sel <= ~sel;
assign x = sel ? a2 : a1;
assign y = sel ? b2 : b1;
always_ff @(posedge clk) begin
  p <= x * y;
  if (sel) p1 <= p; else p2 <= p;   // p holds last cycle's stream
end

How to choose

First ask what is required: throughput, , area, power. Then work out:

  • Required rate: results per second.
  • Clock: what the process allows.
  • Copies: the required rate divided by the clock rate, rounded up.

If a block must deliver 2 billion results per second on a 1 GHz clock, you need two copies, and if it must deliver just 100 million, then ten streams can share one copy.

The power angle

Two slower copies can use less energy than one fast copy, because lower frequency allows lower voltage, and power falls with voltage squared. This is one reason chips have moved to many cores and wide accelerators.

Common mistake

Sharing hardware because it looks elegant, then finding that the muxes and control logic have used up the savings. Sharing small blocks, such as an adder, rarely helps. Share large ones, such as multipliers and memories.

Key ideas

  • Retiming moves registers without changing behaviour.
  • Parallel hardware boosts throughput; sharing saves area.
  • Check latency requirements first.

Your exercise

Share one multiplier between two streams.

Interview questions

coreWhat is resource sharing's cost?

basicWhat does retiming change, and what does it keep the same?

basicA block must deliver 750 million results per second, and each copy produces one result per cycle at 400 MHz. How many copies do you need?

coreA chain of logic blocks has delays of 1.5, 4, 2, 3.5 and 1 ns, with one register to place between blocks (flop overhead ignored). Where should it go?

coreOne multiplier is shared between two streams on alternate cycles. A designer 'cleans up' the output demux so that sel = 1 means stream 2, and now the streams' results are swapped. Why?

always @(posedge clk) sel <= rst ? 1'b0 : ~sel;
assign x = sel ? a2 : a1;
assign y = sel ? b2 : b1;
always @(posedge clk) begin
  p <= x * y;
  if (sel) q2 <= p; else q1 <= p;  // 'cleaned up'
end

coreWhen does sharing one hardware block between two streams fail to save area?

coreWhen a tool moves a register backward through logic during retiming, what can go wrong with its reset value?

advancedOne multiplier runs at 1 GHz and 1.0 V. Alternatively, two copies run at 500 MHz, which allows 0.8 V. Compare the dynamic power, assuming each copy has the same switched capacitance.

advancedCan retiming speed up a feedback loop, such as an accumulator, whose loop delay exceeds one clock period?

Practise these 9 questions with animations