EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
网上搜了一下,结合自己总结的。首先介绍一下基本的原理。 脉冲边沿的特性:两侧电平发生了变化 思路:设计两个或多个一位的寄存器,用来接收被检测的信号,系统时钟来一次记一次输入信号,如果用了两个寄存器直接异或就可以了。 9 o; r5 a8 O r
- 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;
4 ]/ d) j, w2 }4 V- 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
; K) x% q* v* i5 ^' h7 i% }; y7 l
; `* F7 x6 _ l$ Y& S! n, e
5 T+ W" Y! q4 z ?/ _
' I1 l- g7 B, n3 X$ ]: K$ ? 4 }% o4 Y9 z G+ u
|