Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
    • Reset Puzzles
    • Clock Gating & Clock Mux Puzzles
    • CDC Basics Puzzles
      • MTBF Of Two Flops Versus Three
      • Back-to-Back Events Through a Toggle Synchroniser
      • Why Gray Code Across Clock Domains
      • A Four-Phase Handshake For a Bus
      • Full or Not in a Gray-Coded FIFO
      • Valid Crossed, Data Did Not
    • Verifying CDC & Reset Puzzles
    • Clock, Reset & CDC Puzzles: Tricky Q&A
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←CDC Basics Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Clock, Reset & CDC Puzzles
  4. CDC Basics Puzzles
  5. A Four-Phase Handshake For a Bus
On this page

    VLSI DV Interview PuzzlesAll levels

    A Four-Phase Handshake For a Bus

    An 8-bit word crosses from a 10 ns clock to a 14 ns clock with a req/ack four-phase handshake: data and req change together, req is double-synchronised into the destination, the destination captures data and raises ack, ack is double-synchronised back, the source then drops req and the destination drops ack. What does the destination capture, and when is the earliest safe moment for the source to change data?

    Puzzle

    Difficulty: Hard · Puzzle 4 of 6 · Topic: CDC Basics Puzzles

    An 8-bit word crosses from a 10 ns clock to a 14 ns clock with a req/ack four-phase handshake: data and req change together, req is double-synchronised into the destination, the destination captures data and raises ack, ack is double-synchronised back, the source then drops req and the destination drops ack. What does the destination capture, and when is the earliest safe moment for the source to change data?

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    `timescale 1ns/1ns
    module tb;
      reg clks = 0, clkd = 0;
      always #5 clks = ~clks;                     // source period 10
      always #7 clkd = ~clkd;                     // destination period 14
      reg [7:0] data = 0;
      reg req = 0, ack = 0;
      reg r1 = 0, r2 = 0;                         // req synchroniser (destination clock)
      reg a1 = 0, a2 = 0;                         // ack synchroniser (source clock)
      always @(posedge clkd) begin r1 <= req; r2 <= r1; end
      always @(posedge clks) begin a1 <= ack; a2 <= a1; end
      always @(posedge clkd) begin
        if (r2 && !ack) begin ack <= 1; $display("t=%0d dst captures data=%h", $time, data); end
        else if (!r2) ack <= 0;
      end
      task send(input [7:0] v);
        begin
          data <= v; req <= 1;                    // data and req change together; data then stays put
          @(posedge clks); while (!a2) @(posedge clks);
          req <= 0;                               // ack seen: now data may change again
          @(posedge clks); while (a2) @(posedge clks);
        end
      endtask
      initial begin
        @(posedge clks);
        send(8'hA5); send(8'h3C); send(8'hFF);
        $display("t=%0d three transfers complete", $time);
        #1 $finish;
      end
    endmodule

    Hint

    The destination captures when it sees req; why is the data stable at that moment?

    Step-by-step solution

    Diagram
    1) The source changes data and req on the same edge. Data is not synchronised: it is only used after req has passed through the two destination flops.
    2) By the time the destination sees req (two destination edges later, at least) the data bits have been stable for more than one full destination period, so all bits are captured consistently.
    3) The destination captures at that moment and raises ack. The source sees ack after another two source edges, then drops req.
    4) The destination drops ack once it sees req low, and the source waits until it sees ack low before the next word, so the three words are captured in order: a5, 3c, ff.
    5) The earliest safe moment to change data is after the source has seen ack high (the destination has certainly captured). Changing it earlier would break the capture; changing it only when ack drops again, as the code does, is the conservative choice.

    Answer

    Answer: The destination captures A5 at t=35, 3C at t=175 and FF at t=315, in order, so each word takes 140 ns. The source may change data only after it has seen ack high: the destination has captured by then. The design is safe because data is stable for at least the whole req and ack round trip.

    How this was checked

    Checked by running the code in Icarus Verilog 13; the printed output supports the answer above. Icarus: all three words are captured intact and in order.

    Why candidates get it wrong

    Synchronising the data bits too, or changing data when req drops without waiting for ack. The data is never synchronised: it is held stable and sampled when the synchronised req arrives. The cost is latency: a transfer takes several clock cycles of both domains, so the throughput is low.

    Interviewer follow-up

    How many source cycles does one word take, and what would you use for higher throughput? Model answer: about 14 source cycles (140 ns) per word in this example, because req and ack each cross a two-flop synchroniser twice (up and down); for throughput use an asynchronous FIFO or a pulse-based handshake with data held in a register.

    Related topics

    • Back to CDC Basics Puzzles

    • Clock, Reset & CDC Puzzles section

    Previous

    251 / 293

    Next: Full or Not in a Gray-Coded FIFO

    Up next

    Up nextFull or Not in a Gray-Coded FIFO

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • MTBF Of Two Flops Versus Three
    • Back-to-Back Events Through a Toggle Synchroniser
    • Valid Crossed, Data Did Not