看见一个程序上关于两个按键控制pwm的占空比,没明白程序中那个count计数
count[13:4]和count[15]所代表的意义 请指教 谢谢
程序如下
module pwm(clk,key,led,count,pwm_count);
input clk;
input [1:0]key;
output led;
output count;
output pwm_count;
reg [32:0] count;
reg [9:0] pwm_count;
reg flag;
reg pwm_flag;
always @(posedge clk)
begin
count=count+1'b1;
if (count[13:4] < pwm_count)
pwm_flag=1;
else
pwm_flag=0;
if (count[15] == 1'b1)
begin
if (flag == 1'b1)
begin
flag= 1'b0;
if (key[0] == 1'b0)
pwm_count=(pwm_count+10'b0000000001);
else if (key[1] == 1'b0)
pwm_count=(pwm_count-10'b0000000001);
else pwm_count=pwm_count;
end
end
else
flag= 1'b1;
end
assign led=pwm_flag;
endmodule |