Rising Edge Detector

Easy · Sequential Logic

Design a synchronous rising-edge detector. The output pulse must be high for exactly one clock cycle each time the input din changes from 0 to 1.

Ports

PortDirWidthMeaning
clkinput1Clock. Everything happens on the rising edge.
rstinput1Synchronous, active-high reset (sampled on the rising edge of clk; it takes effect only at that edge).
dininput1Input signal, sampled on every rising edge of clk.
pulseoutput1Registered output: high for one cycle after a 0→1 transition of din.

Behavior

Call d[k] the value of din sampled at rising edge k. At every rising edge k with rst = 0, the detector updates pulse to

pulse = d[k] & ~d[k-1]

so pulse changes only right after a rising edge (it is the output of a flip-flop, not a combinational function of din). If din rises before edge k, pulse is 1 during the clock cycle that follows edge k, and 0 again after edge k+1 (unless another rising edge of din was sampled at edge k+1, which is impossible for a 1-bit signal that was already 1).

Reset

At a rising edge where rst = 1, pulse becomes 0, and the detector forgets the input history: it behaves as if the previous sample had been 1. Consequently, the first rising edge with rst = 0 never produces a pulse, even if din = 1 there. A pulse after reset requires the detector to sample din = 0 at least once and then din = 1.

Example

edge k0 (rst=1)1234567
din sampled11011010
pulse after the edge00010010

Sign up free to solve Rising Edge Detector in your browser.

More Sequential Logic problems