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
  • Bus and Interface Protocol Puzzles25
    • Valid/Ready Handshake Puzzles
    • APB Protocol Puzzles
      • Setup, Access and Completed Transfers
      • Two Wait States: Total Cycles and Write Moment
      • When Is PSLVERR Real?
      • Can Two Transfers Fit in Three Cycles?
      • Write Data Changes in a Wait State
      • Sampling PRDATA One Cycle Too Early
    • AXI Protocol Puzzles
    • FIFO, Arbitration and Credit Puzzles
    • Bus and Interface Protocol Puzzles: Tricky Q&A
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←APB Protocol Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Bus and Interface Protocol Puzzles
  4. APB Protocol Puzzles
  5. Setup, Access and Completed Transfers
On this page

    VLSI DV Interview PuzzlesAll levels

    Setup, Access and Completed Transfers

    AMBA APB (APB3/APB4). A trace of PSEL, PENABLE and PREADY over 8 cycles is below (the slave also drives PREADY high in some setup cycles). Classify every cycle and say how many transfers complete and in which cycles.

    Puzzle

    Difficulty: Easy · Puzzle 1 of 6 · Topic: APB Protocol Puzzles

    AMBA APB (APB3/APB4). A trace of PSEL, PENABLE and PREADY over 8 cycles is below (the slave also drives PREADY high in some setup cycles). Classify every cycle and say how many transfers complete and in which cycles.

    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
    `timescale 1ns/1ns
    module tb;
      localparam int N = 8;
      //                         cycle: 01234567
      localparam bit [0:N-1] PSEL    = 8'b01111100;
      localparam bit [0:N-1] PENABLE = 8'b00101100;
      localparam bit [0:N-1] PREADY  = 8'b01110100;   // slave drives PREADY high in some setup cycles too
      bit clk = 0;
      int cyc = 0, done = 0;
      always #5 clk = ~clk;
      wire psel = PSEL[cyc], penable = PENABLE[cyc], pready = PREADY[cyc];
      always @(posedge clk) begin
        string ph;
        if (!psel)                    ph = "IDLE";
        else if (!penable)            ph = "SETUP";
        else if (!pready)             ph = "ACCESS (wait)";
        else begin ph = "ACCESS (complete)"; done++; end
        $display("cycle %0d: %s", cyc, ph);
        if (cyc == N-1) $display("completed transfers = %0d", done);
        cyc <= cyc + 1;
      end
      initial #(10*N) $finish;
    endmodule

    Hint

    A transfer completes in a cycle where PSEL, PENABLE and PREADY are all high.

    Step-by-step solution

    Diagram
    1) Cycle 0: PSEL=0 -> IDLE.
    2) Cycle 1: PSEL=1, PENABLE=0 -> SETUP. PREADY=1 is ignored in setup.
    3) Cycle 2: PSEL=1, PENABLE=1, PREADY=1 -> ACCESS completes transfer 1.
    4) Cycle 3: PSEL=1, PENABLE=0 -> SETUP of transfer 2 (back-to-back, PSEL stays high; PREADY=1 is again ignored).
    5) Cycle 4: ACCESS with PREADY=0 -> wait state. Cycle 5: ACCESS with PREADY=1 -> transfer 2 completes. Cycles 6-7: idle.

    Answer

    Answer: Two transfers complete: one in cycle 2 and one in cycle 5 (after one wait state in cycle 4).

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. Phase decoding from PSEL/PENABLE/PREADY: PREADY high in setup cycles 1 and 3 completes nothing.

    Why candidates get it wrong

    PREADY is only meaningful in the access phase. Counting PSEL && PREADY would give four 'transfers' (cycles 1, 2, 3, 5): the slave tying PREADY high does not complete anything in a setup cycle.

    Interviewer follow-up

    A slave ties PREADY permanently high. How many clocks does each APB transfer take, and what is the peak rate? Model answer: Exactly two clocks (one SETUP, one ACCESS), so the peak is one transfer every two clocks, i.e. 50% of the clock rate.

    Related topics

    • Back to APB Protocol Puzzles

    • Bus and Interface Protocol Puzzles section

    Previous

    267 / 293

    Next: Two Wait States: Total Cycles and Write Moment

    Up next

    Up nextTwo Wait States: Total Cycles and Write Moment

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • When Is PSLVERR Real?
    • Can Two Transfers Fit in Three Cycles?
    • Write Data Changes in a Wait State