Synchronous Rising Edge Detector
Protocol logic often reacts to an edge, not a level: a chip select going active, a start bit arriving. An edge detector turns a level change into a one-cycle pulse.
This module monitors a continuous input signal and generates a single-cycle active-high pulse exactly when the input transitions from low to high. If the input remains high for multiple cycles, the output remains low after the initial pulse.
Timing and Reset Rules:
- Clock edge:
posedge clk - Reset type: asynchronous, active-low (
rst_n) - Output on reset:
pulseevaluates to 0 - The
pulseoutput must be combinational, evaluating to 1 in the exact same cycle thatdinis high but was low in the previous cycle.
Worked Trace:
Cycle 1: rst_n=0 → internal state=0, pulse=0
Cycle 2: rst_n=1, din=0 → internal state=0, pulse=0
Cycle 3: din=1 → internal state=0, pulse=1
Cycle 4: din=1 → internal state=1, pulse=0
Cycle 5: din=0 → internal state=1, pulse=0
Cycle 6: din=0 → internal state=0, pulse=0
Cycle 7: din=1 → internal state=0, pulse=1
Port Table:
| Signal | Direction | Width | Description |
|---|---|---|---|
clk |
input | 1 | Positive-edge triggered clock |
rst_n |
input | 1 | Asynchronous active-low reset; internal state goes to 0 |
din |
input | 1 | Synchronous input signal to be monitored |
pulse |
output | 1 | Combinational active-high output asserting when din transitions to 1 |
Constraints
- Clock edge is
posedge clk. - Reset is asynchronous, active-low (
negedge rst_n). - The
pulseoutput must be combinational, asserting in the exact same cycle thatdintransitions to 1. - Do not use
dinin the sensitivity list of anyalwaysblock. - On reset, the internal state must be cleared to 0.
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.