功能:使呼吸灯达到流水的效果
描述:定义一个3位计数器,计前8次“呼”和“吸”过程的次数
每一个“呼”和“吸”的过程组合为一组,通过每一组”呼吸”使led达到移位的效果。
代码:
module liushui_breath_led(
input wire sclk ,
input wire rst_n ,
output reg [ 3:0] led
);
parameter max_us = 49 ;
parameter max_ms = 999 ;
parameter max_s = 999 ;
//cnt_us
reg [ 5:0] cnt_us ;
always@(posedge sclk or negedge rst_n)
if(!rst_n)
cnt_us <= 0 ;
else if(cnt_us==max_us)
cnt_us <= 0 ;
else
cnt_us <= cnt_us+1'b1 ;
//cnt_ms