|
楼主 |
发表于 2011-12-22 10:38:29
|
显示全部楼层
本帖最后由 cococenstar 于 2011-12-22 11:22 编辑
回复 2# qlengyu
如果我的GLB足够的话,我肯定用一个10mhz的就轻松解决问题了,但是现在就是因为GLB不够了,所以才想着怎么能够减少GLB的使用,我贴出我写的代码,综合通过了,但是我在用波形仿真时,提示:WARNING 26567:CLK pluse width for signal D^A5_CLK violation found at 20.200ns类似这样的警告。我的程序如下:
module xc(mclk,clk,reset,sele_frq,sele_wid,clk_div);
input mclk,reset,clk;
input [3:0] sele_frq;
input [2:0] sele_wid;
output clk_div;
reg clk_div;
reg[13:0] divcount;
reg [13:0] counter1;
reg[13:0] counter2;
reg[13:0] widcount;
reg flag;
always @(sele_frq or reset) //选频
if(!reset)
divcount<=0;
else
case(sele_frq) /* synthesis full_case */
1:divcount<=1;
2:divcount<=2;
3:divcount<=10;
4:divcount<=20;
5:divcount<=100;
6:divcount<=200;
7:divcount<=1000;
8:divcount<=2000;
9:divcount<=10000;
endcase
always @(sele_wid or reset) //选脉宽
if(!reset)
widcount<=0;
else
case(sele_wid) /* synthesis full_case */
1: widcount<=5;
2:widcount<=10;
3:widcount<=50;
4:widcount<=100;
5:widcount<=500;
6:widcount<=1000;
7:widcount<=5000;
8:widcount<=10000;
endcase
always @(posedge mclk or negedge reset) //一周期高电平持续时间(脉宽)
if(!reset)
begin
counter2 <= 0;
clk_div<=1;
end
else
begin
if(counter2<widcount)
begin
counter2<=counter2+1;
clk_div<=1;
end
else
begin
clk_div<=0;
if(flag)
begin
clk_div<=1;
counter2<=0;
end
end
end
always @(posedge clk or negedge reset) //选频,一周期的持续时间
if(!reset)
counter1 <= 0;
else
begin
if(counter1<divcount-1)
begin
counter1<=counter1+1;
flag<=0;
end
else
begin
counter1<=0;
flag<=1;
end
end
endmodule
这个问题,还望您在百忙之余帮帮忙!在此先谢谢了! |
|