The Request/Acknowledge Handshake
Gray-code synchronization requires numerical values to follow sequential increment patterns. Arbitrary multi-bit vectors, such as configuration registers, command words, or addresses, transition arbitrarily between random states. Because multiple bits toggle simultaneously, Gray code cannot protect arbitrary data vectors. Transferring multi-bit words across asynchronous clock boundaries requires a request/acknowledge handshake protocol.
Four-Phase Handshake Protocol
To transfer multi-bit data safely without multi-bit synchronizers, the transmitting domain must hold data lines stable during sampling.
The system synchronizes only single-bit control flags (req and ack):
The four-phase handshake proceeds through four sequential steps:
- Request Assert: The source asserts stable data and asserts
req. - Acknowledge Assert: The destination synchronizes
req, samples the stable data bus, and assertsack. - Request Deassert: The source synchronizes
ackand deassertsreq. - Acknowledge Deassert: The destination observes the deassertion of
reqand deassertsack, completing the transaction.
Because data lines remain completely stable throughout steps 1 and 2, destination flip-flops sample data without risk of metastability.
Source Domain Controller
`timescale 1ns / 1ps
`default_nettype none
module cdc_handshake_src #(parameter WIDTH = 16) (
input wire src_clk, src_rst_n,
input wire [WIDTH-1:0] data_in,
input wire send, // Strobe: initiate data transfer
output reg [WIDTH-1:0] data_held, // Stable output connected to destination
output reg req,
input wire ack_sync, // Synchronized into src_clk domain
output reg busy
);
localparam IDLE = 2'b00, WAIT_ACK = 2'b01, WAIT_ACK_LOW = 2'b10;
reg [1:0] state;
always @(posedge src_clk or negedge src_rst_n) begin
if (!src_rst_n) begin
state <= IDLE; req <= 1'b0; busy <= 1'b0; data_held <= {WIDTH{1'b0}};
end else begin
case (state)
IDLE: begin
busy <= 1'b0;
if (send) begin
data_held <= data_in; // Latch data and hold stable
req <= 1'b1;
busy <= 1'b1;
state <= WAIT_ACK;
end
end
WAIT_ACK: begin
if (ack_sync) begin
req <= 1'b0; // Acknowledge received; deassert request
state <= WAIT_ACK_LOW;
end
end
WAIT_ACK_LOW: begin
if (!ack_sync) begin // Wait for destination acknowledge deassertion
busy <= 1'b0;
state <= IDLE;
end
end
default: state <= IDLE;
endcase
end
end
endmodule
The source finite state machine (FSM) latches data_held exclusively during the IDLE state.
The data bus remains completely unchanged while waiting for handshake completion.
Destination Domain Controller
module cdc_handshake_dst #(parameter WIDTH = 16) (
input wire dst_clk, dst_rst_n,
input wire req_sync, // Synchronized into dst_clk domain
input wire [WIDTH-1:0] data_held, // Stable input: sampled without synchronizer
output reg ack,
output reg [WIDTH-1:0] data_out,
output reg data_valid
);
reg req_sync_d; // Edge detector register
always @(posedge dst_clk or negedge dst_rst_n) begin
if (!dst_rst_n) begin
ack <= 1'b0; data_out <= {WIDTH{1'b0}}; data_valid <= 1'b0; req_sync_d <= 1'b0;
end else begin
req_sync_d <= req_sync;
data_valid <= 1'b0;
if (req_sync && !req_sync_d) begin // Rising edge detected: data is stable
data_out <= data_held;
data_valid <= 1'b1;
ack <= 1'b1;
end else if (!req_sync && ack) begin // Source deasserted request
ack <= 1'b0;
end
end
end
endmodule
The destination uses an edge detector on req_sync.
When req_sync asserts, the controller loads data_held into data_out and asserts ack.
Throughput and Architecture Comparison
Four-phase handshakes require multiple synchronizer round-trips per transaction. This latency reduces throughput significantly compared to FIFO streaming:
| CDC Technique | Bandwidth and Throughput | Recommended Application |
|---|---|---|
| Two-flop synchronizer | High bandwidth (Single-bit, 2-cycle latency) | Single-bit control flags and interrupts |
| Asynchronous FIFO | High bandwidth (Continuous streaming) | High-speed data streams and packet buffers |
| Request/Acknowledge Handshake | Low bandwidth (Multi-cycle round trip) | Infrequent control words and configuration registers |
Use handshakes when updating configuration registers or operational parameters across clock domains. Use asynchronous FIFOs for continuous streaming data.
Verification Exercise
Explain why the source state machine must wait for ack_sync to deassert in the WAIT_ACK_LOW state before returning to IDLE.
View Solution
If the source returns to IDLE immediately upon detecting ack_sync = 1, it could initiate a subsequent transaction immediately.
The source could toggle req low and high before the destination observes the falling edge of req.
If the destination fails to detect the falling edge, its edge detector cannot recognize the next transaction.
Waiting for ack_sync = 0 guarantees that both domains complete the full handshake cycle before starting a new transfer.
Four-phase handshakes safely transfer arbitrary data words across asynchronous clock boundaries. The next article explores automated CDC linting tools and common design pitfalls.