本文主要是介绍边沿检测电路(二),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
边沿检测电路,包括上升沿、下降沿、双沿检测电路。在检测到所需要的边沿后产生一个高电平的脉冲。
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
转自: http://www.cnblogs.com/qiweiwang/archive/2011/01/02/1924098.html
这篇关于边沿检测电路(二)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!