Clock-Domain Crossing
Async Set Sync-Clear Flag — L2 Upgrade
Asynchronous set, synchronous clear flag with credit-based flow control for pulse transfer across clock domains.
About this block
Simulate it in the Verilog IDE
Async Set Sync-Clear Flag — L2 Upgrade is a Verilog reference block in the Clock-Domain Crossing catalog. Clock-domain crossing FIFOs, synchronizers, and handshake bridges. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
This OpenIP implements an asynchronous set, synchronous clear flag with credit-based flow control. The module captures a pulse from an external domain and asserts an output pulse in the destination clock domain. It uses a two-stage synchronizer to mitigate metastability for the input pulse. The design includes a credit return mechanism to prevent backpressure issues in high-throughput systems.
This IP provides a robust method for transferring single-cycle pulses across clock domains with flow control.
The credit return mechanism ensures that the source is not overwhelmed by the destination.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Async Set Sync-Clear Flag — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: Asynchronous set, synchronous clear flag with credit-based flow control for pulse transfer across clock domains.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- 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
- Metastability Protection: Two-stage synchronizer for
pulse_in. - Credit-Based Flow Control: Ensures the source is not overwhelmed by the destination.
- Simple FSM: Three-state machine (IDLE, PENDING, TRANSMITTED) for robust state management.
- Asynchronous Input: Handles pulses from any clock domain.
Architecture
The module operates using a simple three-state finite state machine (FSM). The states are IDLE, PENDING, and TRANSMITTED.
- IDLE: The module is ready to accept a new pulse.
ready_outis high. - PENDING: A pulse has been captured and synchronized to the destination clock domain.
pulse_outis asserted.ready_outis low. - TRANSMITTED: The pulse is being held until a credit is received from the consumer.
pulse_outremains asserted.ready_outis low.
### Synchronization
The synchronizer consists of two flip-flops driven by clk_dst. It samples the pulse_in signal to create a stable internal flag (sync_d2).
### Flow Control Logic
- Capture: When
sync_d2is detected in IDLE, the FSM transitions to PENDING. - Transmission: When
ready_inis asserted, the FSM transitions to TRANSMITTED. This indicates the consumer is ready to process the pulse. - Credit Return: When
ready_inis asserted again (or held high, depending on implementation details), the FSM transitions back to IDLE. This completes the credit return cycle, allowingready_outto go high.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk_dst | Input | 1 | Destination clock domain |
rst_n_dst | Input | 1 | Active-low reset for destination domain |
pulse_in | Input | 1 | Asynchronous pulse input |
ready_in | Input | 1 | Credit signal from destination consumer. Asserted when consumer is ready to accept the pulse. |
pulse_out | Output | 1 | Synchronized pulse output. Asserted high during PENDING and TRANSMITTED states. |
ready_out | Output | 1 | Ready signal indicating credit availability. High when in IDLE state. |
Verification
The testbench validates the basic functionality and credit return mechanism. It checks the initial reset state of the outputs. It verifies that a pulse is correctly synchronized and propagated. It ensures that ready_out goes low when a pulse is pending. It confirms that pulse_out clears and ready_out goes high upon credit return. It tests the behavior when credit is withheld to ensure proper backpressure signaling. All test cases passed successfully in the simulation log.
More in Clock-Domain Crossing
- 1-Bit Handshake CDC Bridge
- 3-Stage Asynchronous Reset Synchronizer
- 4-Bit Bus Synchronizer (2-FF per bit)
- 4-Bit Gray Bus Synchronizer — L2 Upgrade
- Async Handshake Pulse Bridge
- Asynchronous Reset Synchronizer for FIFO Gray Pointer Crossings
- Dual-Clock Pulse with Credit Return
- Enable Level Synchronizer — L1 Upgrade
- Four-Phase Req/Ack CDC Payload 16-bit
- Handshake CDC with 8-Bit Payload
- Multi-Bit Bus Synchronizer (2-FF)
- Multi-Bit Mux-Select Synchronizer — L2 Upgrade
- Pulse-Ack Round-Trip Across 2 Clocks
- Req/Ack Payload Hold 8-bit
- Single-Cycle Pulse Synchronizer (2-FF + Edge Detector)
- Slow-Enable Fast Sample-Hold