打印

等精度测频

[复制链接]
1333|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
snailchen|  楼主 | 2010-1-4 13:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
以下是一种等精度测频的代码,可以使用。


module mesureFreq (fx,fbase,fgate,comp,rclk,load,fbaseout,fxout);
input fx;
input fbase;
input fgate;
input rclk;
input load;
output comp;
output fbaseout;
output fxout;

reg   startCnt;
reg   comp;

reg[31:0] fbaseCntTemp,fxCntTemp;
reg[31:0] fbaseCnt,fxCnt;

reg[4:0] count;
reg fbaseout_buf,fxout_buf;

/*-------测频部分------*/
always @ (posedge fbase)
begin
if(startCnt)
begin
fbaseCntTemp <= fbaseCntTemp + 1'b1; //* base count
end
else
begin
fbaseCntTemp <= 32'h00000000;
end
end

always @ (posedge fx)
begin
if(startCnt)
fxCntTemp <= fxCntTemp + 1'b1; //* fx count
else
fxCntTemp <= 32'h00000000;
end

//synchronous fgate
always @ (posedge fx)
begin
if(fgate)
begin
startCnt <= 1'b1;
comp <= 1'b0;
    end
else
    begin
startCnt <= 1'b0;
comp <= 1'b1;
end
end

always @ (negedge startCnt)
begin
fxCnt <= fxCntTemp;
fbaseCnt <= fbaseCntTemp;
end

/*-------数据传输部分------*/
always @ (posedge rclk)
begin
if(load)
begin
count <= 0;
end
else
begin
fbaseout_buf <= fbaseCnt[31-count];
fxout_buf <= fxCnt[31-count];
count <= count+1'b1;
end
end

assign fbaseout = fbaseout_buf;
assign fxout = fxout_buf;

endmodule  

我用的是EPM570,在实际使用中发现测频不是很稳定,跳动比较厉害,有时还会出现极大值和极小值,但是如果我测CPLD分频出来的时钟是很稳的,不知道是不是没有做时序约束的原因,在综合的时候有以下警告:
1、Warning: Found pins functioning as undefined clocks and/or memory enables
2、Warning: Found 4 node(s) in clock paths which may be acting as ripple and/or gated clocks -- node(s) analyzed as buffer(s) resulting in clock skew
3、Warning: Circuit may not operate. Detected 32 non-operational path(s) clocked by clock "fx" with clock skew larger than data delay. See Compilation Report for details.

请问各位大虾,能否给点建议改进一下,谢谢~!

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

7

帖子

0

粉丝