Phase Aligned Clock Domain Crossing
When both clocks come from the same PLL and one is an exact multiple of the other, their edges line up. A synchronizer is unnecessary there; a phase-enable signal tells the fast domain when the slow data is safe to sample.
The circuit transfers a 32-bit data payload and a valid signal from a slow clock domain to a fast clock domain. The module operates entirely on the fast clock (clk_fast). A phase enable signal (phase_en) is provided by the clock controller, which pulses high for exactly one fast clock cycle when the inputs from the slow domain are guaranteed to be stable.
The module must sample the input data and valid signal only when the phase enable is asserted. When valid data is sampled, the module must output the data and assert a valid output pulse for exactly one fast clock cycle. The output data must remain stable until the next valid data is sampled.
Clock edge: posedge clk_fast
Reset type: Asynchronous
Reset polarity: Active-low (rst_n)
Output values on reset: data_out goes to 0, valid_out goes to 0.
Latency: two registers. The edge where phase_en is high loads a capture register; on the next edge valid_out pulses and data_out takes the captured value.
Priority and timing rules:
valid_outmust be a single-cycle pulse onclk_fastimmediately following aphase_enpulse wherevalid_inwas high.data_outupdates whenphase_enis high andvalid_inis high. It strictly holds its value during all other cycles.
Cycle 1: rst_n=0 → data_out=0, valid_out=0
Cycle 2: rst_n=1, phase_en=0, valid_in=1, data_in=100 → data_out=0, valid_out=0
Cycle 3: phase_en=1, valid_in=1, data_in=100 → data_out=0, valid_out=0
Cycle 4: phase_en=0, valid_in=1, data_in=100 → data_out=100, valid_out=1
Cycle 5: phase_en=0, valid_in=1, data_in=100 → data_out=100, valid_out=0
Cycle 6: phase_en=1, valid_in=0, data_in=200 → data_out=100, valid_out=0
Cycle 7: phase_en=0, valid_in=0, data_in=200 → data_out=100, valid_out=0
| Signal | Direction | Width | Description |
|---|---|---|---|
clk_fast |
input | 1 | Fast domain clock, positive-edge triggered |
rst_n |
input | 1 | Asynchronous active-low reset |
data_in |
input | 32 | Data from slow clock domain |
valid_in |
input | 1 | Valid signal from slow clock domain |
phase_en |
input | 1 | Phase enable; pulses high for 1 cycle when slow inputs are stable |
data_out |
output | 32 | Registered data in fast clock domain |
valid_out |
output | 1 | Single-cycle valid pulse in fast clock domain |
Constraints
- Do not use multi-stage synchronizers (double flopping). The latency from
phase_entovalid_outmust be exactly 1clk_fastcycle. data_outmust only update whenvalid_inis 1 during aphase_enpulse.valid_outmust assert for exactly one clock cycle per valid transfer.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Clock Domain Crossing and Synchronization
Problem 30 of 36 in the Clock Domain Crossing and Synchronization track.
Related problems
Browse all problems · Clock domain crossing (CDC) problems · Verilog practice problems · Learning tracks