Edge Detector: An Overview
Edge detectors play a crucial role in synchronous systems to generate a short pulse when a transition of a signal occurs from low to high or high to low. These short pulses are used to trigger an event or generate an interrupt.
There are three types of edge detectors, and they are as follows:
- Rising edge detector: detects a signal transition from low to high.
- Falling edge detector: detects a signal transition from high to low.
- Dual edge detector: detects both rising and falling edges of a signal.
Verilog Code
module edge_detect(/*AUTOARG*/
// Outputs
posEdge, negEdge, dualEdge,
// Inputs
clk, rst, din
);
input clk;
input rst;
input din;
output posEdge;
output negEdge;
output dualEdge;
/*AUTOREG*/
/*AUTOWIRE*/
reg din_reg;
always@(posedge clk)
begin
if(!rst)
din_reg <= 'h0;
else
din_reg <= din;
end
// Posedge detection
assign posEdge = (~din_reg) & din;
// Negedge detection
assign negEdge = din_reg & (~din);
// Dualedge detection
assign dualEdge = posEdge || negEdge;
endmodule