?? lin.v
字號:
module lin(clock,pwm);
input clock;
output pwm; //接到LED上
reg pwm;
reg[7:0] base; //對比的基數
reg[7:0] count; //對時鐘記數,將時間長河分為若干個8位時間段
reg[23:0] count1; //主要得到肉眼可分辨的時間,這里為1秒
reg[8:0] count2; //進行奇偶數秒控制
always@(negedge clock )
begin
count=count+1;
if(count==8'b11111111)
begin
count=8'b00000000;
count1=count1+1;
end
if(count>base)
pwm=1'b1;
else
pwm=1'b0;
if(count1==16'b1001100100101111) //也就是達到了1秒左右
begin
count2=count2+1;
count1=1'b0;
if((count2%2)==1'b1)
base=8'b11100000; //變換基準
else
base=8'b00000000;
if(count2==8'b11111111)
count2=8'b00000001;
end
end
endmodule
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -