搜索
bottom↓
回复: 11

等精度测频

[复制链接]

出0入0汤圆

发表于 2010-1-4 13:42:27 | 显示全部楼层 |阅读模式
以下是一种等精度测频的代码,可以使用。


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.

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

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

发表于 2010-1-7 17:00:52 | 显示全部楼层
我也要做这个最近 可是我用的是vhdl....帮顶了

出0入0汤圆

发表于 2011-2-27 22:42:09 | 显示全部楼层
mark

出0入0汤圆

发表于 2011-8-4 16:34:02 | 显示全部楼层
mark

出0入0汤圆

发表于 2011-8-4 17:46:44 | 显示全部楼层
信号调整电路产生的干扰和信号自身的噪声影响不容忽视!

出0入0汤圆

发表于 2011-8-6 13:29:02 | 显示全部楼层
mark

出0入0汤圆

发表于 2011-8-7 15:01:11 | 显示全部楼层
mark

出0入0汤圆

发表于 2013-5-15 11:38:33 | 显示全部楼层
mark

出0入0汤圆

发表于 2013-5-15 12:57:17 | 显示全部楼层
没有注释,看的好艰难

出0入0汤圆

发表于 2013-5-16 07:31:09 来自手机 | 显示全部楼层
xiaohe669 发表于 2011-8-4 17:46
信号调整电路产生的干扰和信号自身的噪声影响不容忽视!

能不能传授点经验?谢谢!

出0入0汤圆

发表于 2013-5-16 07:38:04 | 显示全部楼层
输入管脚设置成施密特类型没有?

出0入0汤圆

发表于 2013-5-16 12:47:24 | 显示全部楼层
oped001 发表于 2013-5-16 07:31
能不能传授点经验?谢谢!

加个斯密特触发器就行
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 07:13

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表