Rising Edge Detector

AMD
Intel
Qualcomm

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

  • in stays high for multiple cycles — pulse fires only on the first cycle, stays low after

  • in already high when rst deasserts — in_delayed is 0 after reset, so pulse fires on the very next cycle if in is still high

  • in toggles every cycle — pulse fires every other cycle, alternating with the falling edge

  • rst asserted while in is high — in_delayed clears to 0, pulse fires again after rst deasserts if in still high

  • in and rst both deassert simultaneously — pulse fires because in_delayed is 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.

Output

Output goes here...