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

  • Start Here5
    • Who This Course Is For
    • How the Lessons and Examples Work
    • Words You Will Meet
    • The Testbench Picture
    • The PacketFIFO Project
  • SystemVerilog Language Foundations28
  • Object-Oriented SystemVerilog for Verification30
  • Constraint Randomization — Interview-Critical Deep Dive39
  • SystemVerilog Assertions — Interview-Critical Deep Dive41
  • Functional Coverage in SystemVerilog25
  • Testbench Architecture in SystemVerilog24
  • Advanced Language & Integration26
  • Senior & Interview Preparation23
  • Principal-Level Verification34
Loading lesson

←Start Here
  1. Topics
  2. SystemVerilog
  3. Start Here
  4. The PacketFIFO Project
On this page

    Part 0/Start HereBeginner

    The PacketFIFO Project

    The design you verify through the course: a valid/ready FIFO that carries small packets as bytes, its first runnable test, and where it appears in each part.

    Ideas stick when they are used on one design that grows. PacketFIFO is small enough to understand in a minute and rich enough to need every technique in the course.

    After this lesson you can: describe the PacketFIFO ports and packet format, run version 0, and say what each part of the course adds to it.

    What you will verify

    PacketFIFO is a small first-in first-out buffer with a valid/ready port on each side. A producer pushes bytes in, a consumer pulls them out in the same order, and nothing may be lost, duplicated or reordered.

    The bytes form packets. Each packet is a header byte, then len payload bytes, then a check byte. A ninth bit, last, marks the check byte so the consumer knows where the packet ends.

    The FIFO only moves bytes. Packets are a meaning the testbench gives those bytes, which is why the same FIFO grows into the course capstone.

    Field

    Bits

    Meaning

    kind

    header[7:6]

    0 DATA, 1 CTRL, 2 ERR

    dest

    header[5:4]

    Destination port, 0 to 3

    len

    header[3:0]

    Payload bytes that follow: 1 to 8 are legal; 0 and 9 to 15 are illegal

    check byte

    8 bits

    XOR of the header and every payload byte

    The handshake rule is the one from RTL: a byte moves on a clock edge where valid and ready are both 1. While ready is 0 the producer must hold the same byte.

    Version 0: one packet through

    The first version needs nothing beyond Verilog. The bench sends one packet, fills the 4-entry FIFO exactly, reads the bytes back and checks order, the last bit and the check byte.

    packet_fifo.v
    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
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    // PacketFIFO v0: a valid/ready FIFO of 9-bit entries {last, byte}.
    module packet_fifo #(
      parameter WIDTH = 9,
      parameter DEPTH = 4,
      parameter AW    = 2
    ) (
      input  wire             clk,
      input  wire             rst_n,
      input  wire             in_valid,
      output wire             in_ready,
      input  wire [WIDTH-1:0] in_data,
      output wire             out_valid,
      input  wire             out_ready,
      output wire [WIDTH-1:0] out_data
    );
      reg [WIDTH-1:0] mem [0:DEPTH-1];
      reg [AW-1:0]    wptr, rptr;
      reg [AW:0]      count;
      wire push = in_valid && in_ready;
      wire pop  = out_valid && out_ready;
    
      assign in_ready  = (count != DEPTH);
      assign out_valid = (count != 0);
      assign out_data  = mem[rptr];
    
      always @(posedge clk or negedge rst_n)
        if (!rst_n) begin
          wptr  <= 0;
          rptr  <= 0;
          count <= 0;
        end else begin
          if (push) begin
            mem[wptr] <= in_data;
            wptr <= wptr + 1'b1;
          end
          if (pop) rptr <= rptr + 1'b1;
          case ({push, pop})
            2'b10:   count <= count + 1'b1;
            2'b01:   count <= count - 1'b1;
            default: count <= count;
          endcase
        end
    endmodule
    
    Terminal
    PASS: packet 22 a5 3c bb came out in order, last on the check byte, XOR 00
    Predict first The header is 8'h22, and the payload is A5 and 3C. What is the check byte?

    8'hBB. 22 XOR A5 is 87, and 87 XOR 3C is BB. XOR-ing all four bytes then gives 00, which is what the bench checks at the end.

    Terminal
    PASS: packet 22 a5 3c bb came out in order, last on the check byte, XOR 00

    Version 0 checks one packet, written by hand. The rest of the course replaces each hand-written piece with something that scales.

    Where PacketFIFO appears in the course

    Part

    What you add to PacketFIFO

    Where to find it

    1 · Foundations

    A packed struct and enum for the header, a queue as the expected-byte model, an interface for the two ports

    Project step boxes in Part 1

    2 · OOP

    A pkt_txn class with print, compare and copy; a generator and driver that pass packets through a mailbox

    Project step boxes in Part 2

    3 · Randomization

    Random legal packets, then deliberately illegal ones (length 0, bad check byte)

    Project step boxes in Part 3

    4 · Assertions

    Assertions for valid/ready stability (data and valid hold until ready) and for the packet rules: no overflow, no underflow, last only on the check byte

    PacketFIFO step boxes in Part 4

    5 · Coverage

    A covergroup for packet kind x length x dest, written as a bins model, including the illegal lengths

    PacketFIFO step boxes in Part 5

    6 · Advanced

    A bind checker attached to packet_fifo without editing the RTL, and plusargs for FIFO depth and seed

    PacketFIFO step boxes in Part 6

    7 · Testbench

    A monitor and a scoreboard for PacketFIFO, joined into a complete class testbench

    PacketFIFO step boxes in Part 7

    8 · Senior

    The capstone: plan, regression and sign-off, with a planted bug to find

    Capstone: Verify a Parameterized FIFO

    Each step is a short callout, a Project step or PacketFIFO step, near the end of the lesson it belongs to. It uses only ideas taught up to that lesson, and says whether it was run with the open simulators or is described but not run. The steps are optional: every lesson makes sense without them, and this table is the map.

    Check yourself Why does the FIFO store a last bit next to each byte instead of storing whole packets?

    It keeps the RTL a plain byte FIFO that knows nothing about packets. The packet format lives in the testbench, so the same FIFO can be checked with any format, and it grows into the course capstone unchanged.

    Check yourself The consumer drops out_ready for three cycles in the middle of a packet. What must the FIFO do?

    Keep out_valid high and keep the same byte on out_data until a cycle where out_ready is 1. Nothing is lost, and the byte is not repeated.

    • A byte moves on a clock edge where valid and ready are both 1.

    • A packet is a header (kind, dest, len), len payload bytes and a check byte marked last.

    • The check byte is the XOR of the bytes before it, so a whole packet XORs to 0.

    Rule of thumb: the FIFO moves bytes; the testbench gives them meaning.

    How this was checked

    Run with Icarus Verilog 13 (iverilog -g2012) and Verilator 5.048 (--binary --timing) on 2026-10-18; both printed the PASS line shown, with no warnings.

    Version 0 checks one hand-written packet that exactly fills a depth-4 FIFO. It does not test back-pressure, simultaneous push and pop, reset in the middle of traffic or illegal packets; later parts add those.

    Related topics

    • Next: Part 1 · Language Foundations

    • Valid/ready in the RTL course

    Previous

    5 / 275

    Next: SystemVerilog Language Foundations

    Up next

    Up nextSystemVerilog Language Foundations

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Who This Course Is For
    • How the Lessons and Examples Work
    • Words You Will Meet