Skip to content

AryaD-ece/systemverilog-valid-ready-pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ SystemVerilog Valid-Ready Pipeline Verification

Backpressure-aware, lossless 1-stage streaming pipeline
(Elastic Buffer / AXI-Stream Register Slice Equivalent)


โšก Executive Summary

Aspect Detail
Problem Reliable data transfer under backpressure
Solution 1-stage valid-ready pipeline (elastic buffer)
Guarantee No data loss, no overwrite, in-order delivery
Latency 1 cycle
Throughput 1 txn / cycle (no stalls)
Result PASS 20 / 20

๐Ÿงฉ Problem Statement

In synchronous digital systems, producer and consumer operate at independent rates. Without proper flow control:

  • โŒ Data loss under backpressure
  • โŒ Overwrite of unconsumed data
  • โŒ Ordering violations
  • โŒ Non-deterministic throughput

๐ŸŽฏ Objective

Design and verify a pipeline stage that:

  • โœ” Guarantees lossless transfer
  • โœ” Handles arbitrary backpressure
  • โœ” Preserves strict ordering
  • โœ” Ensures cycle-accurate deterministic behavior

๐Ÿ”— Protocol Definition

A transaction occurs iff:

valid && ready

๐Ÿง  Architecture

flowchart LR

    %% =========================
    %% DATA PATH
    %% =========================
    P[Producer] -->|data| B[Pipeline Register]
    B -->|data| C[Consumer]

    %% =========================
    %% CONTROL SIGNALS
    %% =========================
    P -->|valid| B
    C -->|ready| B

    %% =========================
    %% STATE MACHINE (TIED TO PIPELINE)
    %% =========================
    E[EMPTY slot_full=0] -->|valid| F[FULL slot_full=1]
    F -->|ready| E

    F -.holds data.-> B

    %% =========================
    %% CORE BEHAVIOR (MATCHES TIMING)
    %% =========================
    B -->|valid & ready โ†’ transfer| C
    B -->|valid & !ready โ†’ hold| B

    %% =========================
    %% INVARIANTS (MATCHES SVA)
    %% =========================
    I1[Transfer iff valid AND ready]
    I2[Data stable when valid AND NOT ready]

    I1 --> B
    I2 --> B
Loading

Equivalent to a 1-depth elastic buffer / AXI-Stream register slice


๐Ÿ—๏ธ Design Summary

Component Role
data_reg Holds current transaction
slot_full Indicates valid data present
txn_count Counts completed transfers

Behavior

Condition Action
full + ready consume
empty + valid load
full + !ready stall (hold data)

๐Ÿงช Verification Strategy

Architecture

  • Generator
  • Driver
  • Monitor
  • Scoreboard (mailbox-based)

Stimulus

  • Random data
  • Random delay (1โ€“5 cycles)
  • Random backpressure (0โ€“8 cycles)

๐Ÿงท Assertions (SVA)

// Transfer occurs only on handshake
property handshake_transfer;
  @(posedge clk) (valid && ready) |-> ##1 txn_count == $past(txn_count) + 1;
endproperty
assert property (handshake_transfer);

// Data must remain stable under backpressure
property data_stable_on_stall;
  @(posedge clk) (valid && !ready) |-> $stable(data_reg);
endproperty
assert property (data_stable_on_stall);

// No overwrite before consumption
property no_overwrite;
  @(posedge clk) (slot_full && !ready) |-> $stable(data_reg);
endproperty
assert property (no_overwrite);

๐Ÿ“Š Functional Coverage

covergroup handshake_cg @(posedge clk);
  coverpoint valid;
  coverpoint ready;
  cross valid, ready;
endgroup

โฑ๏ธ Timing Behavior

Clock      โ”€โ”_โ”Œโ”€โ”_โ”Œโ”€โ”_โ”Œโ”€โ”_โ”Œโ”€โ”_โ”Œโ”€โ”_โ”Œโ”€โ”_โ”Œโ”€โ”

valid      โ”€โ”€โ– โ– โ– โ– โ– โ– โ– โ– โ”€โ”€โ”€โ”€โ– โ– โ– โ– โ– โ– โ– โ– โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ready      โ”€โ”€โ”€โ”€โ”€โ– โ– โ– โ– โ– โ– โ– โ– โ”€โ”€โ”€โ”€โ”€โ”€โ– โ– โ– โ– โ– โ– โ”€โ”€โ”€โ”€
data       === A === B === B === C === D ===

handshake     โ†‘     โ†‘        โ†‘     โ†‘
              A     B        C     D

txn_count     0 โ†’ 1 โ†’ 2 โ†’ 2 โ†’ 3 โ†’ 4

Interpretation

  • โœ” Transfer only when valid && ready
  • โœ” Data stable during stall
  • โœ” No overwrite
  • โœ” Count increments only on handshake

๐Ÿ“ˆ Waveform Evidence

โœ” Handshake correctness โœ” Backpressure handling โœ” Stable data โœ” In-order execution


๐Ÿ“Œ Verification Results

Metric Status
Transactions 20
PASS 20
FAIL 0
Assertions PASS
Data Integrity Verified

โš™๏ธ Performance

Metric Value
Latency 1 cycle
Throughput 1 txn/cycle
Backpressure Lossless

โ–ถ๏ธ How to Run

xvlog src/pipeline_dut.sv sim/transaction.sv sim/tb_pipeline.sv
xelab tb_pipeline -s tb_pipeline_sim
xsim tb_pipeline_sim -run all

๐Ÿ“ Repository Structure

src/
 โ””โ”€โ”€ pipeline_dut.sv

sim/
 โ”œโ”€โ”€ tb_pipeline.sv
 โ””โ”€โ”€ transaction.sv

waveform.png
README.md
.gitignore

๐Ÿญ Industry Relevance

  • AXI-Stream pipelines
  • Network-on-Chip routers
  • DSP streaming systems
  • FIFO front-end buffering

๐Ÿ”ฎ Extensions

  • Multi-stage FIFO
  • Skid buffer design
  • AXI-Stream wrapper
  • UVM verification environment
  • Coverage closure metrics

๐Ÿง  Design Invariants

1. Transfer โ‡” valid && ready
2. Data stable when valid && !ready
3. No overwrite before consumption
4. txn_count increments only on handshake

๐Ÿ‘ค Author

Arya Dinesh
B.Tech Electronics & Communication Engineering

๐Ÿ“ซ Letโ€™s connect: www.linkedin.com/in/aryadinesh2005


โญ If you found this project interesting, feel free to star this repository!
๐Ÿง  Open for collaboration or discussion on FPGA, digital design, and embedded systems.


About

Backpressure-safe 1-stage valid-ready pipeline in SystemVerilog with constrained-random verification, assertions (SVA), and waveform validation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors