1.计数器的优秀编程思路
always@(posedge clk or negedge rst_n)begin if(rst_n == 1'b0) cnt <= MAX; else(cnt == MAX && flage == 1'b1) cnt <= cnt + 1'b1; else cnt <= cnt; end
2.检测信号的下降沿
always@(posedge sclk)begin rx_r1 <= rs232_rx ; rx_r2 <= rx_r1 ; rx_r3 <= rx_r2 ; end assign rx_neg = ~ rx_r2 & rx_r3 ;