|
别人的verilong的呼吸灯程序,有些看不明白,请大家帮忙给解释下做"///////////"标识的地方的程序,谢谢大家。
module breathing_led(
input wire clk,
input wire rst_n,
output reg [3:0] LED
);
reg [26:0] counter;
reg [5:0] PWM_adjust;
reg [6:0] PWM_width;
always @ (posedge clk or negedge rst_n)
begin
if(!rst_n)
begin
counter <= 0;
LED[0] <= 0;
LED[1] <= 0;
LED[2] <= 0;
LED[3] <= 0;
end
else
begin
counter <= counter + 1; // 时钟上升沿到来就自加一
PWM_width <= PWM_width[5:0] + PWM_adjust; ///////////
if(counter[26]) ///////////
begin
PWM_adjust <= counter[25:20]; ///////////
end
else
begin
PWM_adjust <= ~counter[25:20]; ///////////
end
LED[0] <= PWM_width[6]; ///////////
LED[1] <= PWM_width[6];
LED[2] <= PWM_width[6];
LED[3] <= PWM_width[6];
end
end
endmodule
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|