Shift Register Based Delay Line Crossing
Source-synchronous interfaces send a clock alongside the data, and the receiver may need to delay one relative to the other. A tapped shift register gives a delay you can select at run time.
The module implements a tapped shift register that delays an incoming data signal by a selectable number of clock cycles. A programmable selection input determines which tap of the shift register drives the output. A delay selection of zero bypasses the flip-flops entirely, routing the input directly to the output.
The circuit operates on a positive-edge triggered clock (clk) and uses an asynchronous active-low reset (rst_n). On reset, all shift register stages are cleared to 0. The output data_out is combinational with respect to delay_sel and data_in (when bypass is selected). When delay_sel is greater than zero, the output reflects the state of the corresponding shift register stage.
Worked Trace:
Cycle 1: rst_n=0, data_in=1, delay_sel=1 → shift_reg=000, data_out=0
Cycle 2: rst_n=1, data_in=1, delay_sel=1 → shift_reg=000, data_out=0
Cycle 3: rst_n=1, data_in=0, delay_sel=1 → shift_reg=001, data_out=1
Cycle 4: rst_n=1, data_in=1, delay_sel=0 → shift_reg=010, data_out=1 (combinational bypass)
| Signal | Direction | Width | Description |
|---|---|---|---|
clk |
input | 1 | Positive-edge triggered clock |
rst_n |
input | 1 | Asynchronous active-low reset; clears all shift register stages to 0 |
data_in |
input | 1 | Serial data input |
delay_sel |
input | 2 | Selects the delay in clock cycles (0 to 3) |
data_out |
output | 1 | Delayed data output |
Constraints
- Positive-edge triggered clock and asynchronous active-low reset.
- All shift register stages must reset to
0. data_outmust immediately reflect changes todelay_selordata_in(whendelay_selis0) without waiting for a clock edge.- Maximum delay supported is 3 clock cycles.
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 35 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