大家帮忙比较下面两种边沿信号的检测程序那个好,优势何在
reg [1:0] SCKr; //内部寄存器
always @(posedge clk)
SCKr <= {SCKr[1], SCK}; //内部寄存器对SCK计数
wire SCK_risingedge = (SCKr[1:0]==2'b01); //检测出SCK的上升沿
wire SCK_fallingedge = (SCKr[1:0]==2'b10); //检测出SCK的下降沿
还有下面这种方法
reg [2:0] SCKr; //内部寄存器
always @(posedge clk)
SCKr <= {SCKr[2:1], SCK}; //内部寄存器对SCK计数
wire SCK_risingedge = (SCKr[2:1]==2'b01); //检测出SCK的上升沿
//wire SCK_fallingedge = (SCKr[2:1]==2'b10); //检测出SCK的下降沿 |