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.

Stage A Borrows 4 Ns from Stage BOne column per 2 ns, from 0 to 28 ns. Lab pipeline with stage A = 13 ns and stage B = 4 ns.
01234567891011121314phi1phi2q1xa (latch 2 input)q2xb (latch 3 input)latch 2 opensdata arrives
Scroll horizontally ↔
  1. Cycle 1

    Latch 1 is open on phi1 and passes the new data at 1 ns. Stage A begins.

  2. Cycle 5

    Latch 2 opens at 10 ns. Stage A is not done yet.

  3. Cycle 7

    Stage A arrives at 14 ns, 4 ns after latch 2 opened. The open latch passes it on at once.

  4. 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.

A Two-Phase Latch PipelineArrows show data. Latches alternate between the two clock phases.
  • Storage
  • Datapath
  • Data
A two-phase latch pipelineArrows show data. Latches alternate between the two clock phases. storage Latch 1 open on phi1 datapath Stage A logic storage Latch 2 open on phi2 datapath Stage B logic storage Latch 3 open on the next phi1
  1. storage Latch 1open on phi1
    • Stage A
  2. datapath Stage Alogic
    • Latch 2
  3. storage Latch 2open on phi2
    • Stage B
  4. datapath Stage Blogic
    • Latch 3
  5. storage Latch 3open on the next phi1
  1. Half a cycle each

    Nominally each stage gets half a cycle: from one phase to the other.

  2. 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 caseStage A arrivesLatch 2 openResult
Stage A = 13 ns14 ns10 to 19 nsborrows 4 ns; latch 3 gets its data at 19 ns
Stage A = 21 ns22 ns10 to 19 nstoo 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
  1. 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.

  2. 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.

  3. 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?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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 ns
Read 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

ConceptWhy can a latch pipeline tolerate one stage longer than half a cycle when a flip-flop pipeline cannot?
ConceptStage A borrows 150 ps. What happens to stage B?
Read the waveformTwo clocks drive a latch pipeline. Which pair is safe?
Two candidate clock pairs
012345phi1 (pair A)phi2 (pair A)phi1 (pair B)phi2 (pair B)
Scroll horizontally ↔

One column per time step.

Conceptphi2 is high from 500 to 950 ps, the latch setup time is 40 ps, and stage A ends at latch 2. Its data leaves latch 1 at 70 ps. What is the largest stage A delay?
Predict the outputThe lab pipeline with stage A = 17 ns and stage B = 4 ns. Predict the line it prints.
`timescale 1ns/1ns
// latch_pipe: three latches on two non-overlapping clocks, with logic delays DA and DB between them.
// phi1 is high from 0 to 9 ns of each 20 ns cycle, phi2 from 10 to 19 ns.
module latch_pipe #(parameter int DA = 13, DB = 4) (
  input  logic phi1, phi2, din,
  output logic q1, q2, q3,
  output wire  xa, xb                  // the inputs of the second and third latch
);
  always_latch if (phi1) q1 <= #1 din; // latch 1, open while phi1 = 1 (D to Q: 1 ns)
  assign #(DA) xa = q1;                // stage A logic: DA ns
  always_latch if (phi2) q2 <= #1 xa;  // latch 2, open while phi2 = 1
  assign #(DB) xb = q2;                // stage B logic: DB ns
  always_latch if (phi1) q3 <= #1 xb;  // latch 3, open in the next phi1
endmodule
// 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(17), .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=17: stage B arrives at %0d ns; latch 3 opens at 20: q3=%b at 40 ns", tb_f, q3f);
        $finish;
  end
endmodule

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.

Practice

Report a problem with this page