用quartus写了一个pwm(用增减计数方式调制)程序,编译综合都通过了,RTL仿真也是对的,但是门极仿真出来的结果不对,想问一下为什么?麻烦大家帮忙看看
RTL仿真结果,注意红圈的地方没有毛刺
门极仿真结果,注意红圈的地方有毛刺
module CPLD6(CLK_150M,pwm1,pwm2)/*synthesis noprune*/;
input CLK_150M;
output pwm1,pwm2;
wire[10:0] C0,C1/*synthesis keep*/;
UD_Cnt UD0(CLK_150M,C0);
assign
pwm1 = (100 > C0) ? 1'b1:1'b0;
endmodule
module UD_Cnt(CLK_udcnt,UD_counter)/*synthesis noprune*/;
parameter CNT_ini = 11'D167,Dir_ini = 1'B0;
input CLK_udcnt;
output reg[10:0] UD_counter/*synthesis noprune*/;
reg Dir;
initial
begin
UD_counter = CNT_ini;
Dir = Dir_ini;
end
always[url=home.php?mod=space&uid=72445]@[/url] (posedge CLK_udcnt)
begin
if(Dir == 0)
UD_counter = UD_counter + 10'D1;
else
UD_counter = UD_counter - 10'D1;
end
always@ (posedge CLK_udcnt)
begin
if((UD_counter == 1001)&(Dir == 0))
Dir = 1;
else if((UD_counter == 1)&(Dir == 1))
Dir = 0;
end
endmodule
CPLD6.rar
(381.67 KB)
|