Codiode

Delaying a Wide Bus vs Control Signal

HardVerilog / SystemVerilogBuildFree1 solved

Delaying a 32-bit bus by 16 cycles with flip-flops costs 512 of them. Delaying only the 1-bit valid signal and keeping the data in a small memory costs far less.

The bus_delay_optimizer module receives a 32-bit data_in bus and a 1-bit valid_in signal. It must output valid_out and data_out exactly 16 clock cycles later. If valid_in is asserted at clock cycle T, valid_out must be asserted at clock cycle T+16, and data_out must exactly match the data_in sampled at cycle T. When valid_out is low, data_out must be driven to 0.

Signal Direction Width Description
clk input 1 Positive-edge triggered clock
rst_n input 1 Asynchronous active-low reset; all internal state and outputs go to 0
valid_in input 1 Indicates data_in is valid and must be captured
data_in input 32 Data bus to be delayed
valid_out output 1 Asserted exactly 16 cycles after valid_in was asserted
data_out output 32 Delayed data; must be 0 when valid_out is 0

Constraints

  • The module must delay valid data by exactly 16 clock cycles.
  • data_out must output exactly 32'h00000000 on any cycle where valid_out is 0.
  • The reset signal rst_n is asynchronous and active-low.
  • All outputs and internal tracking state must immediately reset to 0 when rst_n is asserted.

Topics

MemoryShift RegisterOptimizationPipelining

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.

Free to solve. A Codiode account keeps your progress.

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 Interview Circuit

Problem 3 of 10 in the Interview Circuit track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

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