|
回复 8楼kdy 的帖子
谢谢!按照你的思路,程序已经修改过了。如下:
module allen(clk30m,pwm,out);
input clk30m,pwm;
output out;
reg [10:0]cnt_pulse;
always @(posedge clk30m or negedge pwm)
begin
if(!pwm)
cnt_pulse = 0;
else if (cnt_pulse[10]==1)
cnt_pulse = cnt_pulse;
else
cnt_pulse = cnt_pulse + 1;
end
wire pwm_ok = !(cnt_pulse[10]==1);
reg [9:0]cnt_095;
always @(posedge clk30m or posedge pwm_ok)
begin
if(pwm_ok)
cnt_095 = 0;
else
cnt_095= cnt_095 + 1;
end
wire pwm_095 = !(cnt_095>=955 && cnt_095<=1023);
assign out = pwm_ok ? pwm : pwm_095 ;
endmodule |
|