Verifying credentials...

Access Denied

You don't have an active subscription for the Advanced CDC course.

Return to Dashboard
CDC Course / Module 8: Advanced CDC FIFO Architectures
Lesson 8.1

1-Deep / 2-Register FIFO Synchronizer

An advanced, low-latency alternative to the standard deep asynchronous FIFO, specifically optimized for infrequent multi-bit control passing and configuration registers.

1

When to Use It

When passing multi-bit data across clock domains, a standard 2-flop synchronizer will fail because individual bits can arrive at different clock edges (due to routing delays). The traditional solution is an Asynchronous FIFO or a Multi-Cycle Path (MCP) with a handshake.

However, when dealing with infrequent control packets, configuration registers, or status words where high throughput is not required, a full Async FIFO is overkill (too much area, latency, and complexity). A standard MCP handshake can be slow. The 2-Register FIFO (or Ping-Pong Synchronizer) solves this by offering zero-latency writing in the Tx domain and robust, stable reading in the Rx domain.

2

Architecture & Signal Flow

The architecture consists of two data registers (Ping and Pong) and a single-bit toggle flag.

  1. Sender (Tx): Writes multi-bit data into one register (e.g., Reg A) and flips the wr_toggle flag. The next write will go to Reg B.
  2. Synchronizer: The wr_toggle flag is passed through a 2-flop synchronizer into the Rx clock domain to become rx_toggle_sync.
  3. Receiver (Rx): Edge-detects the synchronized toggle flag. When it changes, the Rx logic knows new data is ready. Since the sender is now pointing to the other register for its next write, the current register is guaranteed stable and safe to read.
TX CLOCK DOMAIN RX CLOCK DOMAIN tx_data Reg A Reg B wr_toggle MUX FF1 FF2 Edge Det rx_data
3

Interactive Lab

Simulate the ping-pong mechanism. Click Write Tx to store data and flip the flag. Then click Clock Rx repeatedly to see the flag propagate through the synchronizer and update the read MUX.

Tx Domain
Reg A: [empty]
Reg B: [empty]
wr_ptr: 0 (Reg A)
wr_toggle: 0
Rx Domain
Currently Reading:
Reg A
rx_sync1: 0
rx_sync2: 0
rx_sync3 (prev): 0
rx_valid_pulse: 0
4

Verilog Implementation

filename.v
module two_reg_fifo_sync #(
    parameter DWIDTH = 32
)(
    // Tx Domain
    input  wire              tx_clk,
    input  wire              tx_rst_n,
    input  wire              tx_en,
    input  wire [DWIDTH-1:0] tx_data,
    output wire              tx_ready, // 0 means waiting for Rx to catch up
    
    // Rx Domain
    input  wire              rx_clk,
    input  wire              rx_rst_n,
    output reg  [DWIDTH-1:0] rx_data,
    output wire              rx_valid
);

    //---------------------------------------------------------
    // TX Domain Logic
    //---------------------------------------------------------
    reg [DWIDTH-1:0] reg_a;
    reg [DWIDTH-1:0] reg_b;
    reg              tx_ptr;       // 0=A, 1=B
    reg              tx_toggle;

    // Optional: Synchronize rx_toggle back to Tx for backpressure
    reg [2:0] rx_toggle_sync_tx;
    always @(posedge tx_clk or negedge tx_rst_n) begin
        if (!tx_rst_n) rx_toggle_sync_tx <= 3'b0;
        else           rx_toggle_sync_tx <= {rx_toggle_sync_tx[1:0], rx_toggle_sync};
    end
    
    // Ready if we haven't overwritten the register Rx is currently reading
    // (In strict ping-pong without backpressure, you assume tx is slow)
    assign tx_ready = 1'b1; // Simplified for basic configuration passing

    always @(posedge tx_clk or negedge tx_rst_n) begin
        if (!tx_rst_n) begin
            tx_ptr    <= 1'b0;
            tx_toggle <= 1'b0;
            reg_a     <= {DWIDTH{1'b0}};
            reg_b     <= {DWIDTH{1'b0}};
        end else if (tx_en && tx_ready) begin
            if (tx_ptr == 1'b0) reg_a <= tx_data;
            else                reg_b <= tx_data;
            
            tx_ptr    <= ~tx_ptr;
            tx_toggle <= ~tx_toggle;
        end
    end

    //---------------------------------------------------------
    // RX Domain Logic
    //---------------------------------------------------------
    reg [2:0] tx_toggle_sync;
    
    // 3-stage synchronizer + edge detect pipeline
    always @(posedge rx_clk or negedge rx_rst_n) begin
        if (!rx_rst_n) tx_toggle_sync <= 3'b0;
        else           tx_toggle_sync <= {tx_toggle_sync[1:0], tx_toggle};
    end

    // Edge detect on the synchronized toggle flag
    wire toggle_edge = (tx_toggle_sync[1] ^ tx_toggle_sync[2]);
    assign rx_valid  = toggle_edge;

    // Read MUX
    always @(*) begin
        // If sync[1] is 0, Tx last wrote to A, so we read A.
        if (tx_toggle_sync[1] == 1'b1) rx_data = reg_b;
        else                           rx_data = reg_a;
    end
endmodule

Rate Matching is Critical

This synchronizer inherently assumes the Sender (Tx) will not write faster than the Receiver (Rx) can process. If Tx writes to Reg A, then Reg B, and loops back to Reg A before Rx has sampled the toggle flag, data corruption will occur. If the Tx rate can exceed the Rx rate, you must implement a reverse acknowledge path (backpressure) to stall Tx.

5

Comparison with other CDC Topologies

Trade-off Analysis

Metric 2-Register FIFO Deep Async FIFO MCP (Handshake)
Latency (Tx to Rx) Fast (~2-3 Rx cycles) Slow (Ptr sync delay + SRAM) Very Slow (Full round trip)
Throughput Low (Needs backpressure) High (1 word / cycle) Very Low
Area / Logic Size Small (Just 2 flops wide) Large (Gray counters, RAM) Small
Best Use Case CSRs, Config words, Slow state High-bandwidth data paths Single-shot command pulses
6

Latency Calculations

The time taken from the moment tx_en is asserted until rx_valid goes high depends heavily on the relative clock frequencies and phase alignment.

Worst-Case Forward Latency

Lmax = Ttx + Trx_phase + (N × Trx)

Where:

Key Takeaway

The 2-Register FIFO provides a lightweight, zero-latency write interface for passing multi-bit signals across clock domains. By using a ping-pong approach with a synchronized toggle bit, it guarantees data stability without the massive area footprint of a full asynchronous FIFO.

← Previous: Closed-Loop MCP with Acknowledge Next: Naming Conventions & Partitioning →
Advertisement