Codiode

Parameterized Pipeline Delay Line

EasyVerilog / SystemVerilogBuild1 solved

Lining up two paths with different latencies needs a delay of exactly N cycles. A parameter lets one module serve every N.

The module captures an incoming data vector and delays it by a configurable number of clock cycles specified by the parameter DEPTH. Data advances through the pipeline only when the enable signal is asserted. When the enable signal is de-asserted, all stages in the pipeline hold their current values.

The circuit must be driven by a positive-edge triggered clock clk. An asynchronous, active-low reset rst_n clears all pipeline stages to zero immediately when asserted. The output data_out reflects the value of the final pipeline stage.

Worked trace for a pipeline with DEPTH=3:

  • Cycle 1: rst_n=0, en=1, data_in=8'hAA, pipeline=[0, 0, 0], data_out=0
  • Cycle 2: rst_n=1, en=1, data_in=8'hAA, (posedge clk) pipeline=[8'hAA, 0, 0], data_out=0
  • Cycle 3: rst_n=1, en=1, data_in=8'hBB, (posedge clk) pipeline=[8'hBB, 8'hAA, 0], data_out=0
  • Cycle 4: rst_n=1, en=1, data_in=8'hCC, (posedge clk) pipeline=[8'hCC, 8'hBB, 8'hAA], data_out updates to 8'hAA
  • Cycle 5: rst_n=1, en=0, data_in=8'hDD, (posedge clk) pipeline holds, data_out remains 8'hAA
  • Cycle 6: rst_n=1, en=1, data_in=8'hDD, (posedge clk) pipeline=[8'hDD, 8'hCC, 8'hBB], data_out updates to 8'hBB
Signal Direction Width Description
clk input 1 Positive-edge triggered clock
rst_n input 1 Asynchronous active-low reset; clears all stages to 0
en input 1 Clock enable; pipeline advances on posedge clk when 1
data_in input WIDTH Input data vector to be delayed
data_out output WIDTH Delayed data vector from the final pipeline stage

Constraints

  • The parameter WIDTH defaults to 8 and is guaranteed to be >= 1.
  • The parameter DEPTH defaults to 4 and is guaranteed to be >= 1.
  • The output data_out must be registered and update synchronously on the positive edge of clk.
  • When en is 0, all internal stages must perfectly hold their previous state.

Topics

Shift RegisterPipeliningParametersGenerate Blocks

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 Pipelining

Problem 9 of 20 in the Pipelining track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.