边沿检测电路

边沿检测电路,包括上升沿、下降沿、双沿检测电路。在检测到所需要的边沿后产生一个高电平的脉冲。

复制代码
module edge_detect
(
input clk,
input rst_n,
input data_in,
output raising_edge_detect,
output falling_edge_detect,
output double_edge_detect
);

reg data_in_d1;
reg data_in_d2;

always @ (posedge clk,negedge rst_n)
begin
if(!rst_n)
begin
data_in_d1
<= 1'b0;
data_in_d2 <= 1'b0;
end
else
begin
data_in_d1
<= data_in;
data_in_d2
<= data_in_d1;
end
end

assign raising_edge_detect = data_in_d1 & (~data_in_d2);
assign falling_edge_detect = ~data_in_d1 & data_in_d2;
assign double_edge_detect = data_in_d1 ^ data_in_d2;

endmodule
复制代码

posted on   齐威王  阅读(2880)  评论(0编辑  收藏  举报

< 2011年1月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示