Welcome, Architect. Crossing a single-cycle pulse from a fast clock domain to a slow clock domain is a classic CDC challenge. If the destination clock is slower than the source clock, a standard 2-flop synchronizer will often miss the pulse entirely because it doesn't stay asserted long enough for the slow clock edge to sample it.
The solution? An Open-Loop Pulse Stretcher (or toggle synchronizer).
The fundamental idea is to convert a transient event (a pulse) into a persistent state (a level change) in the source domain. We then synchronize that level change into the destination domain. Once safely in the destination domain, we edge-detect the level change to recreate the pulse.
tx_toggle <= tx_pulse ^ tx_toggle; (Source Domain)rx_sync <= tx_toggle; (CDC via 2-flop sync)rx_pulse <= rx_sync[1] ^ rx_sync[2]; (Destination Edge Detection)
Below is the synthesizable RTL for a robust open-loop pulse synchronizer.
module pulse_sync (
input wire clk_tx,
input wire rst_tx_n,
input wire tx_pulse,
input wire clk_rx,
input wire rst_rx_n,
output wire rx_pulse
);
// --- TX Domain ---
reg tx_toggle;
always @(posedge clk_tx or negedge rst_tx_n) begin
if (!rst_tx_n) begin
tx_toggle <= 1'b0;
end else if (tx_pulse) begin
tx_toggle <= ~tx_toggle; // Convert pulse to level change
end
end
// --- RX Domain ---
reg [2:0] rx_sync; // 2 stages for CDC, 1 stage for edge detection
always @(posedge clk_rx or negedge rst_rx_n) begin
if (!rst_rx_n) begin
rx_sync <= 3'b000;
end else begin
// Shift register: rx_sync[0] is the first CDC stage
rx_sync <= {rx_sync[1:0], tx_toggle};
end
end
// Edge detection: XOR the output of the two synchronizer flops
// rx_sync[1] is the safe synchronized signal.
// rx_sync[2] is the delayed version of it.
assign rx_pulse = rx_sync[1] ^ rx_sync[2];
endmodule
| Cycle | tx_pulse | tx_toggle | rx_sync[0] | rx_sync[1] | rx_sync[2] | rx_pulse |
|---|---|---|---|---|---|---|
| T0 | 0 | 0 | 0 | 0 | 0 | 0 |
| T1 | 1 | 1 | 0 | 0 | 0 | 0 |
| T2 | 0 | 1 | 1 (meta?) | 0 | 0 | 0 |
| T3 | 0 | 1 | 1 | 1 | 0 | 1 (Pulse!) |
| T4 | 0 | 1 | 1 | 1 | 1 | 0 |
Step through the pulse synchronizer. Click "Send Pulse" to toggle the fast domain flop, then step the slow clock to propagate it through the synchronizer chain.
System Idle.
tx_pulse events arrive back-to-back (or close together) before the first toggle level has safely propagated through the slow domain's 3-flop chain, the tx_toggle flop will flip back to its original state. The slow clock will sample the same level twice, and the second pulse is lost silently.tx_pulse minimum spacing must be at least 3 destination clock cycles. If your pulses can be bursty, you must use an asynchronous FIFO or a closed-loop handshake synchronizer.
module tb_pulse_sync;
reg clk_fast = 0;
reg clk_slow = 0;
reg rst_n = 0;
reg tx_pulse = 0;
wire rx_pulse;
// Fast clock: 2ns period (500MHz)
always #1 clk_fast = ~clk_fast;
// Slow clock: 10ns period (100MHz)
always #5 clk_slow = ~clk_slow;
pulse_sync dut (
.clk_tx(clk_fast),
.rst_tx_n(rst_n),
.tx_pulse(tx_pulse),
.clk_rx(clk_slow),
.rst_rx_n(rst_n),
.rx_pulse(rx_pulse)
);
initial begin
#20 rst_n = 1;
// Send a single pulse
@(posedge clk_fast);
tx_pulse = 1;
@(posedge clk_fast);
tx_pulse = 0;
// Wait for it to propagate
#100;
$finish;
end
endmodule