Latch-Based Timing and Time Borrowing
Time a pipeline of latches on two non-overlapping clocks, and let a slow stage borrow time from the next one.
You Will Be Able To
- Describe two-phase non-overlapping clocks and a latch pipeline.
- Explain how a transparent latch lets a slow stage borrow time.
- Compute the limit on borrowing from the latch setup time.
- Find the time the next stage has left after a borrow.
- Lesson
- G5.10
- Time
- 25 min
- Runs on
- Your browser
- Check
- 5 questions
A datapath had one stage slightly slower than half a cycle and the next stage much faster. With flip-flops it failed setup. With latches on two clock phases it worked, because the slow stage borrowed time while its latch was still open.
- Cycle 1
Latch 1 is open on phi1 and passes the new data at 1 ns. Stage A begins.
- Cycle 5
Latch 2 opens at 10 ns. Stage A is not done yet.
- Cycle 7
Stage A arrives at 14 ns, 4 ns after latch 2 opened. The open latch passes it on at once.
- Cycle 10
Stage B has only 4 ns of logic. Its result reaches latch 3 at 19 ns, before latch 3 opens at 20 ns.
Measured: the arrival times the lab prints (14 ns and 19 ns), drawn at 2 ns per column.
Two Phases and a Latch Pipeline
A latch pipeline alternates latches on two clocks, phi1 and phi2. They are non-overlapping: never high at the same time, with a small gap between them. So no path can race through two latches in one phase.
- Storage
- Datapath
- Data
- Half a cycle each
Nominally each stage gets half a cycle: from one phase to the other.
- Borrowing
If stage A runs late, latch 2 is still open and passes the data on. Stage B starts later and must be quick.
Read the diagram as text
- Latch 1: open on phi1
- Stage A: logic
- Latch 2: open on phi2
- Stage B: logic
- Latch 3: open on the next phi1
- Latch 1 → Stage A
- Stage A → Latch 2
- Latch 2 → Stage B
- Stage B → Latch 3
Two latches on opposite phases make one flip-flop (G5.6). Here logic sits between them.
Time Borrowing
A flip-flop takes its data at one edge, so each stage must finish by that edge. A latch is open for a whole phase. Data that arrives after the latch opens passes straight through, D to Q later. The late stage has borrowed time from the next stage.
The borrowing has a limit. The data must still meet the latch's setup time before it closes. So the most a stage can borrow is the open phase minus the setup time.
| Lab case | Stage A arrives | Latch 2 open | Result |
|---|---|---|---|
| Stage A = 13 ns | 14 ns | 10 to 19 ns | borrows 4 ns; latch 3 gets its data at 19 ns |
| Stage A = 21 ns | 22 ns | 10 to 19 ns | too late: latch 2 takes it only in the next phi2 |
Measured in the lab. The lab latches have no setup time, so the limit there is the closing edge itself.
The Budget over a Whole Cycle
Borrowing moves time between neighbouring stages; it does not create any. Over a full cycle, stage A, stage B and the two D-to-Q delays must still fit in one period.
Asked in interviews
What is time borrowing?
In a latch-based design, a stage that is slow may finish after the next latch opens. The transparent latch passes the data on, and the next stage starts late. The slow stage has borrowed time from the next one.
What limits time borrowing?
The data must meet the latch setup time before the latch closes. So a stage may borrow up to the open phase minus setup. The sum over a cycle still has to fit in one period.
Why use non-overlapping two-phase clocks?
If both latches were open together, data could race through two stages in one phase. A gap between the phases closes one latch before the next opens, like the master and slave of a flip-flop.
STA tools report borrowing on latch paths: see T2.2 for reading a timing report.
Try It
With stage A at 13 ns, the data reaches latch 2 at 14 ns, 4 ns after it opened. Latch 2 passes it on, and stage B still delivers to latch 3 before latch 3 opens.
With stage A at 21 ns, the data arrives at 22 ns, after latch 2 closed at 19 ns. Latch 2 takes it only when phi2 opens again at 30 ns, and latch 3 has not seen it by 40 ns.
Try stage A = 17 ns and stage B = 4 ns. Does latch 3 still get the data?
DA=13: stage A arrives at 14 ns; latch 2 is open from 10 to 19: borrowed 4 ns DA=13: stage B arrives at 19 ns; latch 3 opens at 20: q3=1 at 40 ns DA=21: stage A arrives at 22 ns; latch 2 closed at 19: q2=1 q3=x at 40 nsRead included file: tb.sv
// tb.sv: one pipeline whose stage A fits by borrowing, one whose stage A is too slow (read-only).
`timescale 1ns/1ns
module tb;
logic phi1 = 0, phi2 = 0, din = 0;
wire q1f, q2f, q3f, xaf, xbf, q1s, q2s, q3s, xas, xbs;
latch_pipe #(.DA(13), .DB(4)) fits (.phi1(phi1), .phi2(phi2), .din(din), .q1(q1f), .q2(q2f), .q3(q3f), .xa(xaf), .xb(xbf));
latch_pipe #(.DA(21), .DB(4)) toolong (.phi1(phi1), .phi2(phi2), .din(din), .q1(q1s), .q2(q2s), .q3(q3s), .xa(xas), .xb(xbs));
always begin phi1 = 1; #9 phi1 = 0; #1 phi2 = 1; #9 phi2 = 0; #1; end // 20 ns cycle, 1 ns gaps
time ta_f, tb_f, ta_s;
always @(xaf) ta_f = $time;
always @(xbf) tb_f = $time;
always @(xas) ta_s = $time;
initial begin
din = 1; // new data before latch 1 opens at 0
#40;
$display("DA=13: stage A arrives at %0d ns; latch 2 is open from 10 to 19: borrowed %0d ns", ta_f, ta_f - 10);
$display("DA=13: stage B arrives at %0d ns; latch 3 opens at 20: q3=%b at 40 ns", tb_f, q3f);
$display("DA=21: stage A arrives at %0d ns; latch 2 closed at 19: q2=%b q3=%b at 40 ns", ta_s, q2s, q3s);
$finish;
end
endmodule
Check Yourself
Common Mistakes
Wrong Let a stage borrow up to the next opening of the latch.
Once the latch has closed, late data waits a whole cycle. In the lab, data that arrived at 22 ns missed a latch that closed at 19 ns.
Fix Borrow at most up to the setup time before the latch closes.
Wrong Forget that borrowed time is taken from the next stage.
Data leaves the latch only when it arrives, plus D to Q. The next stage starts that much later.
Fix Start the next stage's budget at the borrowed arrival, not at the opening edge.
Wrong Overlap the two clock phases.
If both latches are open at once, a fast path races through both in one phase, as in a single wide latch.
Fix Keep a gap between the phases: two-phase clocks are non-overlapping.
Wrong Treat a latch pipeline like a flip-flop pipeline in timing reports.
A flop path must fit its cycle; a latch path may borrow. STA tools report the borrowed time separately.
Fix Read the time-borrowing lines of a latch path in the timing report.
Remember
- Two-phase latch pipelines use non-overlapping clocks so no path races through two latches.
- A late stage borrows time: its latch is still open and passes the data on.
- Borrowing stops at the latch setup time before the closing edge.
- Borrowed time comes out of the next stage; the whole cycle must still fit.