Verilog 提取信号的上升沿或者下降沿
上升沿提取代码:
reg [1:0] F1;
always @(posedge clk)
begin
if(rst_n == 1\'b0) F1[1:0]<=2\'b00;
else F1[1:0]<={F1[0],start_i};
end
wire start_l2h = (F1[1:0]==2\'b01)?1\'b1:1\'b0;
下降沿提取代码:
reg [1:0] F1;
always @(posedge clk)
begin
if(rst_n == 1\'b0) F1[1:0]<=2\'b11;
else F1[1:0]<={F1[0],start_i};
end
wire start_h2l = (F1[1:0]==2\'b10)?1\'b0:1\'b1;