RTL Studio Open IDE

Memory & FIFOs

Credit-Based Ready Flow Control (4)

A credit-based flow control module that manages ready/valid handshakes with a maximum of 4 credits.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

Credit-Based Ready Flow Control (4) is a Verilog reference block in the Memory & FIFOs catalog. SRAM models, FIFOs, register files, and memory-style storage. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.

This IP implements a credit-based flow control mechanism to manage data transfer between a sender and a receiver.

It supports a maximum of 4 concurrent outstanding transactions.

The module enforces backpressure by deasserting the ready signal when the credit count reaches zero, preventing sender overflow.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Credit-Based Ready Flow Control (4).
  2. Read the Verilog module in the editor. The catalog line for this block: A credit-based flow control module that manages ready/valid handshakes with a maximum of 4 credits.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Features

  • Bounded Buffering: Supports up to 4 concurrent outstanding transactions.
  • Backpressure: Automatically stops the sender when credits are exhausted.
  • Credit Management: Decrement on send, increment on receiver acceptance.
  • Monitoring: Exposes current credit count for system monitoring.
  • Synchronous Logic: Simple synchronous design with asynchronous reset.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
valid_iInput1Valid signal from the sender
ready_oOutput1Ready signal to the sender (high if credits > 0)
data_valid_iInput1Valid signal from the receiver side (data available)
data_ready_oOutput1Ready signal to the receiver (always 1)
credits_avail_oOutput4Current number of available credits (0-4)

Architecture

The module uses a 3-bit register (credit_cnt) to track the credit count. The counter initializes to 4 upon reset.

  • Decrement: Credits are decremented when the sender fires (valid_i && ready_o) AND the receiver does NOT accept data (!data_valid_i).
  • Increment: Credits are incremented when the receiver accepts data (data_valid_i && data_ready_o) AND the sender did NOT fire (!valid_i).
  • No Change: If both sender and receiver handshake simultaneously, the credit count remains unchanged.
  • Backpressure: ready_o is asserted high only when credit_cnt > 0.

Verification

The testbench verifies five key scenarios to ensure correct behavior:

  1. Reset State: Verifies initial credit count is 4.
  2. Credit Draining: Verifies credits decrease to 0 as data is sent.
  3. Backpressure: Verifies ready_o is deasserted when credits are 0.
  4. Credit Refill: Verifies credits increase when the receiver accepts data.
  5. Ready State: Verifies ready_o is asserted when credits are available.

### Test Results

Test CaseDescriptionResult
TC1Initial credits should be 4PASS
TC2Credits drained to 0PASS
TC3Backpressure active when credits=0PASS
TC4Credits refilled to 4PASS
TC5Ready active when credits > 0PASS

More in Memory & FIFOs

All Memory & FIFOs blocks