Register Slices: Timing Closure in the Interconnect
Your interconnect is correct, and it is too slow for the clock. One row of flip-flops can repair that, if you put it in the right wires.
You Will Be Able To
- Trace the forward path and the backward path of a channel, and say why a long one fails timing.
- Show what a forward slice does to a run of beats, and what it costs.
- Explain why ready cannot be cut with a flip-flop alone, and what the spare register is for.
- Lesson
- S4.7
- Time
- 27 min
- Runs on
- Your browser
- Check
- 5 questions
The timing report names one path as too long. It starts at a manager, crosses a decoder, an arbiter and a multiplexer, and ends in a memory. A colleague adds a flip-flop on the ready wire. The path is shorter, and the memory now holds one word twice.
Before You Start
You need the handshake from S0.3: a transfer happens at a clock edge with both wires high. You need the decoder, the arbiter and the grant from Many Managers.
You need the beat from Bursts, Locks and the Waiting Request. AXI in one picture names the AXI channels, which this page mentions once.
| Question | |
|---|---|
| 1 | Which two paths does every channel have, and where do they start and end? |
| 2 | Why does a path through several hops fail timing? |
| 3 | What does a forward slice change for the beats, and what does it leave alone? |
| 4 | Why does a flip-flop on ready alone lose and repeat beats? |
| 5 | What does the spare register of a backward slice hold, and when? |
The Idea: Cut a Long Path with Flip-Flops
A channel is a group of wires that carries beats one way. The sender drives valid and the payload, which is everything the beat carries. The receiver drives ready. A beat moves at a clock edge that sees valid and ready at 1.
So a channel has two paths. The forward path carries valid and the payload from sender to receiver. The backward path carries ready from receiver to sender.
Inside an interconnect, both paths cross logic. Each decoder, arbiter and multiplexer on the way is one hop. A signal must cross every hop between two flip-flops within one clock period. With enough hops it arrives too late. The path then fails timing.
The cure is a register slice: a row of flip-flops placed in the channel. It cuts one long path into two short ones. Each beat now takes one more clock cycle to arrive. Getting every path under the clock period is called timing closure.
Cutting the forward path is easy. Cutting the backward path is the hard part, and the reason this page exists.
New Words
| Word | Meaning |
|---|---|
| Valid | The wire of the sender. At 1 it says: this beat is real. |
| Ready | The wire of the receiver. At 1 it says: I take a beat at this edge. |
| Payload | Everything a beat carries beside valid: address, data, control bits. |
| Forward path | The path of valid and the payload, from sender to receiver. |
| Backward path | The path of ready, from receiver to sender. |
| Timing path | The logic between one flip-flop and the next. Its delay must fit in one clock period. |
| Register slice | Flip-flops placed in a channel to cut a timing path. A slice for short. |
| Forward slice | A slice with flip-flops on valid and the payload. Ready passes through as logic. |
| Backward slice | A slice whose ready comes from a flip-flop. It has a spare register for one beat. |
| Skid buffer | The engineers' name for that spare register, and often for the whole backward slice. |
Latency on this page is the number of clock edges from the sender handing a beat over to the receiver taking it.
One Picture: Two Paths and a Cut
- Processor
- Bus
- Control / FSM
- Memory
- The forward path
Valid and the payload leave a flip-flop at the sender. They cross both hops as logic and reach a flip-flop at the receiver.
- The backward path
Ready travels the other way. It crosses the same hops, and must reach the sender before the same clock edge.
- A forward slice
Flip-flops on valid and the payload. The forward path is now two short paths. Ready still crosses the slice as logic.
- A backward slice
A flip-flop drives ready to the sender. The slice needs one spare register, for the beat that is already under way.
Read the diagram as text
- Sender: a flip-flop drives valid and the payload
- Hop 1: a decoder, an arbiter and a multiplexer: pure logic
- Register slice: flip-flops placed in the channel
- Hop 2: the same three pieces again
- Receiver: a flip-flop takes the beat, and logic drives ready
- Sender → Hop 1: valid, payload
- Hop 1 → Register slice: valid, payload
- Register slice → Hop 2: valid, payload
- Hop 2 → Receiver: valid, payload
- Receiver → Hop 2: ready
- Hop 2 → Register slice: ready
- Register slice → Hop 1: ready
- Hop 1 → Sender: ready
Each arrow stands for a group of wires. Without the slice, both paths cross two hops between flip-flops.
Notice the directions. The forward path runs left to right, and the backward path runs right to left. A slice can cut one of them, or both.
The Smallest Example, Worked by Hand: A Forward Slice
A forward slice is one register with a rule: load a new beat whenever the register is empty or is being emptied. The sender has four beats, a1 to a4. The receiver is ready at every edge but the third.
| Edge | Sender offers | Register shows | Receiver ready | What the edge does |
|---|---|---|---|---|
| 1 | a1 | nothing | yes | the register loads a1 |
| 2 | a2 | a1 | yes | the receiver takes a1; the register loads a2 |
| 3 | a3 | a2 | no | nothing moves: the register is full and not being emptied |
| 4 | a3 | a2 | yes | the receiver takes a2; the register loads a3 |
| 5 | a4 | a3 | yes | the receiver takes a3; the register loads a4 |
| 6 | nothing | a4 | yes | the receiver takes a4 |
Every beat arrives, in order, one edge later than it was handed over. With wires in place of the slice, the last beat would be taken at edge 5. Here it is edge 6.
Look at edge 3 again. The sender must know, in that same cycle, that nothing can be loaded. So "receiver not ready" still travels back through the slice as logic. The forward path is cut. The backward path is not.
The Rules
Rule 1: A slice may change when a beat arrives, and nothing else.
Every beat that is handed over is taken once, in the same order.
Rule 2: Valid and the payload are registered together.
They pass the same number of flip-flops. A valid that arrives ahead of its payload marks the wrong data.
Rule 3: Each slice in a channel adds one cycle of latency.
Two slices in a row add two cycles.
Rule 4: A ready that comes from a flip-flop is one cycle old.
When the receiver stops, the sender learns it one cycle later. It may hand over one more beat first.
Rule 5: So a backward slice keeps one spare register.
It catches that one beat. While the spare register is full, the slice tells the sender to wait.
Rule 6: A slice does not make a hop shorter.
It stops the delays of hops from adding up. Put it between hops.
Sources for These Rules
Arm AMBA AXI Protocol Specification, document IHI 0022, issue L, section A2.5. A register stage may be placed in any channel, at the cost of a cycle of latency. Valid must pass the same number of stages as its payload. Section A2.1.1 forbids logic paths from the inputs of an interface to its outputs.
The forward slice, the backward slice, the spare register and the name "skid buffer" are common practice. The specification does not describe how a slice is built.
The RTL track builds the same spare register inside a pipeline stage, in Stalls, Backpressure and the Skid Buffer.
Now Run It
The lab at the end of this page is the hand example as a circuit. Test code plays the sender and the receiver, and prints what each side sees at every clock edge.
e1 up: valid=1 data=a1 ready=1 | down: valid=0 data=xx ready=1 | handed over a1, taken --
e2 up: valid=1 data=a2 ready=1 | down: valid=1 data=a1 ready=1 | handed over a2, taken a1
e3 up: valid=1 data=a3 ready=0 | down: valid=1 data=a2 ready=0 | handed over --, taken --
e4 up: valid=1 data=a3 ready=1 | down: valid=1 data=a2 ready=1 | handed over a3, taken a2
e5 up: valid=1 data=a4 ready=1 | down: valid=1 data=a3 ready=1 | handed over a4, taken a3
e6 up: valid=0 data=a5 ready=1 | down: valid=1 data=a4 ready=1 | handed over --, taken a4
e7 up: valid=0 data=a5 ready=1 | down: valid=0 data=a5 ready=1 | handed over --, taken --
handed over 4, taken 4: a1 a2 a3 a4
last beat taken at e6Rule 3 at work: a1 is handed over at e1 and taken at e2. Rule 1 at work: the last line lists four beats, in order.
- Cycle 0
The sender hands over a1. The register is still empty, so the receiver sees no valid beat.
- Cycle 1
The register shows a1 and the receiver takes it. At the same edge the register loads a2.
- Cycle 2
The receiver is not ready. Ready passes through the slice as logic, so the sender sees 0 in the same cycle.
- Cycle 3
The receiver is ready again. It takes a2, and the register loads a3.
- Cycle 4
The receiver takes a3. The sender hands over its last beat, a4.
- Cycle 5
The receiver takes a4, one edge after the sender gave it.
Recorded from the lab. Each column is what one rising clock edge sees. The register is empty at the first edge; the figure draws its data as 0 there.
Now the backward slice, with the same sender and the same receiver.
e1 up: valid=1 data=a1 ready=1 | down: valid=1 data=a1 ready=1 | handed over a1, taken a1
e2 up: valid=1 data=a2 ready=1 | down: valid=1 data=a2 ready=1 | handed over a2, taken a2
e3 up: valid=1 data=a3 ready=1 | down: valid=1 data=a3 ready=0 | handed over a3, taken --
e4 up: valid=1 data=a4 ready=0 | down: valid=1 data=a3 ready=1 | handed over --, taken a3
e5 up: valid=1 data=a4 ready=1 | down: valid=1 data=a4 ready=1 | handed over a4, taken a4
e6 up: valid=0 data=a5 ready=1 | down: valid=0 data=a5 ready=1 | handed over --, taken --
e7 up: valid=0 data=a5 ready=1 | down: valid=0 data=a5 ready=1 | handed over --, taken --
handed over 4, taken 4: a1 a2 a3 a4
last beat taken at e5Rule 4 at work: at e3 the receiver is not ready. The sender still sees ready at 1 and hands over a3. Rule 5 at work: the spare register keeps a3. At e4 the sender sees ready at 0, and the receiver takes a3 from the spare register.
This slice adds no latency while the receiver keeps up: the last beat is taken at e5, as with wires. Valid and the payload pass straight through it.
How much shorter do the paths get? The lab channel has no hops, so it cannot say. A second design can: a path of two hops between flip-flops, built by a synthesis tool. The tool reports the longest path in logic levels. One level is one gate, so a path of 15 levels crosses 15 gates in a row.
| Between the two hops | Longest path, in logic levels |
|---|---|
| nothing | 15 |
| a forward slice | 9 |
| a backward slice | 19 |
Measured with Yosys 0.70+290, generic gates. The numbers belong to this small design and this tool.
The forward slice does its job: 15 levels become 9. The backward slice alone makes the longest path longer, 19 levels. That is not a mistake in the measurement.
In this design the longest path is the forward one, and the backward slice does not cut it. Worse, each hop works out ready from its grant, and the grant from valid. So the input of the spare register sits at the end of a path that starts on the forward side.
The lesson of the table is rule 6 with a warning. Find the path that is too long before you choose a slice. A cut in the other path costs flip-flops and buys nothing.
The Hop of the Measured Design
// One hop of an interconnect, for one channel: decode, arbitrate, select.
module hop #(parameter logic [7:0] BASE = 8'h10) (
input logic [3:0] valid, // four senders
input logic [3:0][15:0] addr,
input logic [3:0][7:0] data,
output logic [3:0] ready,
output logic out_valid,
output logic [15:0] out_addr,
output logic [7:0] out_data,
input logic out_ready
);
logic [3:0] want, grant;
always_comb begin
for (int i = 0; i < 4; i++) want[i] = valid[i] && (addr[i][15:8] == BASE); // the decoder
grant = want & (~want + 4'd1); // the arbiter: lowest number first
out_valid = |want;
out_addr = '0; out_data = '0;
for (int i = 0; i < 4; i++) if (grant[i]) begin out_addr = addr[i]; out_data = data[i]; end // the multiplexer
ready = grant & {4{out_ready}}; // ready goes back to the winner
end
endmodule
These labs leave things out. The lab channel is eight bits wide and has one sender. Logic levels ignore the length of the wires, which on a real chip is often the larger part of the delay.
Why It Is Built This Way
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| Cut the path with a slice | Slow the clock for the whole chip | Only the beats of this channel pay, with one cycle each. The slice costs flip-flops. |
| A forward slice where the forward path is long | A slice on both paths everywhere | One register per payload bit. Ready still crosses as logic, so the backward path stays whole. |
| A spare register behind a registered ready | Tell the receiver to announce a stop one cycle early | Any sender and any receiver can be joined. The spare register costs as much as the main one. |
A handshake makes all of this possible. Neither side counts cycles. Each only watches valid and ready, so a slice in the middle changes nothing that either side relies on.
The Trap: A Flip-Flop on Ready, and Nothing Else
Back to the colleague from the top of the page. The ready path was too long, so they put one flip-flop in it. Here is that circuit in the lab, with the same sender and receiver.
e1 up: valid=1 data=a1 ready=0 | down: valid=1 data=a1 ready=1 | handed over --, taken a1
e2 up: valid=1 data=a1 ready=1 | down: valid=1 data=a1 ready=1 | handed over a1, taken a1
e3 up: valid=1 data=a2 ready=1 | down: valid=1 data=a2 ready=0 | handed over a2, taken --
e4 up: valid=1 data=a3 ready=0 | down: valid=1 data=a3 ready=1 | handed over --, taken a3
e5 up: valid=1 data=a3 ready=1 | down: valid=1 data=a3 ready=1 | handed over a3, taken a3
e6 up: valid=1 data=a4 ready=1 | down: valid=1 data=a4 ready=1 | handed over a4, taken a4
e7 up: valid=0 data=a5 ready=1 | down: valid=0 data=a5 ready=1 | handed over --, taken --
handed over 4, taken 5: a1 a1 a3 a3 a4
last beat taken at e6Read e3. The receiver is not ready. The sender sees the ready of one cycle ago, which was 1, and hands over a2. Nobody takes it, and nothing keeps it. The beat a2 is lost.
Read e4. Now the sender sees ready at 0 and holds a3. The receiver is ready and takes a3. At e5 the sender hands over a3, and the receiver takes it again. The beat a3 arrives twice.
The first two edges show the same fault. The flip-flop starts at 0, so the sender holds a1 while the receiver takes it. Then a1 is taken again.
The last line shows the damage: four beats handed over, five taken, and one of the four missing. No protocol rule was broken on either side. Each side saw a legal handshake. The count of beats is what gives the fault away, so compare the two counts first.
At Scale
This section looks ahead. One slice in one channel is easy to follow. A large interconnect has hundreds of channels, and only some of them are slow.
Five channels, five choices
An AXI port has five channels. Each can have its own number of slices, because no channel depends on the cycle count of another.
Both paths at once
A slice that cuts both paths is called a full slice. The Full Slice builds one and counts what it costs.
Wires, not gates
On a large chip the delay of a bus path is mostly wire. A slice half-way along a long wire is common, even with no logic near it.
The same idea in a pipeline
The Protocols track counts the cycles of staged handshakes in its lesson on pipelining.
Try It
Run the lab. For each beat, find the edge that hands it over and the edge that takes it.
Change fwd_slice to bwd_slice in the line that places the piece. Find the edge where the spare register is full.
Change it to late_ready. Compare the two counts in the last line but one.
With bwd_slice, make the receiver stop for two edges in a row. Say how many beats the spare register must hold.
e1 up: valid=1 data=a1 ready=1 | down: valid=0 data=xx ready=1 | handed over a1, taken -- e2 up: valid=1 data=a2 ready=1 | down: valid=1 data=a1 ready=1 | handed over a2, taken a1 e3 up: valid=1 data=a3 ready=0 | down: valid=1 data=a2 ready=0 | handed over --, taken -- e4 up: valid=1 data=a3 ready=1 | down: valid=1 data=a2 ready=1 | handed over a3, taken a2 e5 up: valid=1 data=a4 ready=1 | down: valid=1 data=a3 ready=1 | handed over a4, taken a3 e6 up: valid=0 data=a5 ready=1 | down: valid=1 data=a4 ready=1 | handed over --, taken a4 e7 up: valid=0 data=a5 ready=1 | down: valid=0 data=a5 ready=1 | handed over --, taken -- handed over 4, taken 4: a1 a2 a3 a4 last beat taken at e6Check Yourself
Common Mistakes
Wrong Put a flip-flop on ready and leave the rest of the channel alone.
The sender then acts on a ready that is one cycle old.
Fix Add the spare register, and tell the sender to wait while it is full.
Wrong Register the payload and let valid pass through.
Valid then marks the payload of the cycle before.
Fix Give valid and the payload the same number of flip-flops.
Wrong Add a slice wherever the timing report shows a bus signal.
A slice in the other path does not shorten the failing one.
Fix Read which path fails, forward or backward, and cut that one.
Remember
- A channel has a forward path (valid, payload) and a backward path (ready). Each crosses every hop.
- A register slice cuts a long path in two, and adds one cycle of latency.
- A forward slice registers valid and the payload together. Ready still passes through it.
- A registered ready is one cycle old, so a backward slice keeps a spare register for one beat.
- A slice cannot shorten a hop. Find the long path first, then cut that one.