Global Pipeline Stall
A global stall freezes every pipeline stage at once, for example while a multi-cycle operation or a cache miss completes. Nothing moves and nothing is lost.
This module is a 3-stage pipeline that propagates an 8-bit data payload and a 1-bit valid flag. Under normal operation, data and valid signals advance to the next stage on every clock cycle, creating a 3-cycle latency from input to output. When the global stall signal is asserted, all three stages hold their current state. The inputs presented during a stalled cycle are ignored unless they are held until the stall is de-asserted.
The module uses a positive-edge triggered clock clk and a synchronous active-low reset rst_n. On reset, all valid bits and data registers (both internal and output) must clear to 0. The reset signal has the highest priority; if rst_n is 0, the pipeline clears regardless of the stall signal.
Cycle 1: rst_n=0, stall=0, v_in=1, d_in=255 → v_out=0, d_out=0 (Reset)
Cycle 2: rst_n=1, stall=0, v_in=1, d_in=170 → v_out=0, d_out=0 (Stage 1 loads 170)
Cycle 3: rst_n=1, stall=0, v_in=0, d_in=0 → v_out=0, d_out=0 (Stage 2 loads 170)
Cycle 4: rst_n=1, stall=1, v_in=0, d_in=0 → v_out=0, d_out=0 (Stall! Pipeline holds)
Cycle 5: rst_n=1, stall=0, v_in=0, d_in=0 → v_out=1, d_out=170 (Stage 3 loads 170)
Cycle 6: rst_n=1, stall=0, v_in=0, d_in=0 → v_out=0, d_out=0 (Pipeline clears)
| Signal | Direction | Width | Description |
|---|---|---|---|
clk |
input | 1 | Positive-edge triggered clock |
rst_n |
input | 1 | Synchronous active-low reset. Clears all internal valid and data registers to 0. |
stall |
input | 1 | Global stall. When 1, all pipeline stages hold their current state. |
v_in |
input | 1 | Valid bit for incoming data |
d_in |
input | 8 | Incoming data payload |
v_out |
output | 1 | Valid bit for outgoing data (Stage 3) |
d_out |
output | 8 | Outgoing data payload (Stage 3) |
Constraints
- Clock edge and reset:
clkis posedge,rst_nis synchronous active-low. - Reset values: All valid bits and data registers (both internal and output) must clear to 0 on reset.
- Pipeline depth: The module must implement exactly 3 stages of latency.
- Priority: Reset has the highest priority. If
rst_nis 0, the pipeline clears regardless of thestallsignal. - Stall behavior: When
stallis 1, no data advances. Inputs presented during a stalled cycle are ignored unless they are held until the stall is de-asserted.
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.
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 Pipelining
Problem 4 of 20 in the Pipelining track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks