1、上升沿检测电路
题目:对于8位向量中的每个位,检测输入信号何时从一个时钟周期的0变为下一个时钟周期的1(类似于上升沿检测)。应在从0到1的跳变发生后的周期内设置输出位。
以下为例子, 为了清楚起见,分别显示了in [1]和pedge [1]。
module top_module(
input clk,
input [7:0] in,
output reg [7:0] pedge);
reg [7:0] d_last;
always @(posedge clk) begin
d_last <= in;
pedge <= in & ~d_last; // A positive edge occurred if input was 0 and is now 1.
end
endmodule
第九行 d_last <= in; 是记录信号in上一个cycle的状态;
第十行 pedge <= in & ~d_last; 检测上升沿,简答来说就是检测input由0变1。
2、双边沿检测电路
题目:对于8位向量中的每