Rising Edge Detector



Problem Description
Design a rising edge detector that monitors a 1-bit input signal in. When in transitions from 0 to 1, the output pulse must go high for exactly one clock cycle. pulse must return to 0 on the following cycle even if in remains high. pulse is combinational — it fires in the same cycle the transition is detected, not one cycle later. When rst is asserted, all registers clear to 0.
Interface Definition
Port | Direction | Width | Description |
|---|---|---|---|
clk | input | 1-bit | Positive-edge triggered clock |
rst | input | 1-bit | Active-high asynchronous reset — clears in_delayed to 0 |
in | input | 1-bit | Signal to monitor for 0→1 transition |
pulse | output | 1-bit | Combinational — goes high for exactly one cycle on rising edge of in |
Edge Cases
instays high for multiple cycles —pulsefires only on the first cycle, stays low afterinalready high whenrstdeasserts —in_delayedis 0 after reset, sopulsefires on the very next cycle ifinis still highintoggles every cycle —pulsefires every other cycle, alternating with the falling edgerstasserted whileinis high —in_delayedclears to 0, pulse fires again after rst deasserts if in still highinandrstboth deassert simultaneously —pulsefires becausein_delayedis still 0
All Scenarios
Scenario | in transition | in_delayed | pulse |
|---|---|---|---|
Rising edge | 0→1 | 0 | 1 ✓ fires |
in stays high | 1→1 | 1 | 0 ✗ |
Falling edge | 1→0 | 1 | 0 ✗ |
in stays low | 0→0 | 0 | 0 ✗ |
rst deasserts, in high | rst→in=1 | 0 | 1 ✓ fires |
in toggles every cycle | 0→1→0→1 | follows | 1→0→1→0 ✓ |
Worked Example — Cycle Trace
cycle │ in │ in_delayed │ Decision │ pulse
──────┼────┼────────────┼───────────────────────────────────┼──────
1 │ 0 │ 0 │ in=0, no edge │ 0
2 │ 0 │ 0 │ in=0, no edge │ 0
3 │ 1 │ 0 │ in=1 AND ~delayed=1 → RISING ✓ │ 1 ← FIRES
4 │ 1 │ 1 │ in=1 AND ~delayed=0 → already high│ 0
5 │ 1 │ 1 │ in=1 AND ~delayed=0 → still high │ 0
6 │ 0 │ 1 │ in=0, falling edge, no pulse │ 0
7 │ 0 │ 0 │ in=0, no edge │ 0
8 │ 1 │ 0 │ in=1 AND ~delayed=1 → RISING ✓ │ 1 ← FIRES AGAIN
Verilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
