搜索
bottom↓
回复: 2

求大神指点,SIN3 数字滤波器的构建

[复制链接]

出0入0汤圆

发表于 2013-5-22 17:04:33 | 显示全部楼层 |阅读模式
本帖最后由 yuanbao502 于 2013-5-22 22:38 编辑

在项目中用到了Σ-Δ型ADC,输入到FPGA的是1bit的数字流。
根据Σ-Δ型ADC的原理,输入的电压和输出的比特流中的高电平的密度成正比。
以下代码是将输入的一位比特流 解析成16BIT的 一个ADC 数字输出。
但是我输出后发现,我的ADC 的数字一直在跳动。
比如现在输入是5V,结果是我得到的数字是3.02V到5.5V 之间的跳动。
但是我如果把ADC芯片的两个输入脚短路的话,输入就正常的显示基本为零,跳动很小。

用示波器看了一下输入的电压,根本没有大的变化。
我肯定是我的 下面的代码的问题。
但是我用modelsim 模拟的话 又很正常,因为modelsim 不涉及到时序约束等问题,理论下一切正常。
已经找了半个月的问题,实在是找不到,求大神指点啊!!!
原理图如下:

// VERSION:
// MODULE: sin3Filter_module
// ============================================================
// File Name: sin3Filter_module.v
// data:
// ============================================================
// ************************************************************
/*Data is read on negative clk_edge*/       
module sin3Filter_module (
                                                        mclk1,
                                                        reset,
                                                        mdata1,
                                                        DATA,
                                                        dat_sig
                                                 );
/**************************************************************/       
        input        mclk1;//used to clk filter
        input        reset;//used to reset filter
        input        mdata1;//ip data to be filtered
        output        [15:0]        DATA;//filtered op
        output        dat_sig;
       
        //integer location;
        //integer info_file;
       
        reg        [24:0]                ip_data1;
        reg        [24:0]                acc1;
        reg        [24:0]                acc2;
        reg        [24:0]                acc3;
        //reg        [24:0]                acc3_d1;
        reg        [24:0]                acc3_d2;
        reg        [24:0]                diff1;
        reg        [24:0]                diff2;
        reg        [24:0]                diff3;
        reg        [24:0]                diff1_d;
        reg        [24:0]                diff2_d;
        //reg        [15:0]                DATA;
        reg        [7:0]                word_count;
        reg        word_clk;
        //reg init;
       
/**************************************************************/       
//perform the sinc action
always@(posedge mclk1)
        if(mdata1==0)//change from a 0 to a -1 for 2's comp
                ip_data1 <= 25'd0;
        else
                ip_data1 <= 25'd1;
/**************************************************************/
/*accumulator(integrator)
perform the accumulation (IIR) at the speed of the modulator.
Z=one sample delay
MCLKOOUT = modulators conversion bit rate
*/
always@(posedge mclk1 or negedge reset)
        if(!reset)
                begin//initialize acc registers on reset
                        acc1<=0;
                        acc2<=0;
                        acc3<=0;
                end
        else
                begin//perform accumulation process
                        acc1<=acc1+ip_data1;
                        acc2<=acc2+acc1;
                        acc3<=acc3+acc2;
                end
/**************************************************************/
//decimation stage (mclkout/word_clk)
always@(negedge mclk1 or negedge reset)
        if(!reset)
                word_count<=0;
        else
                word_count<=word_count+1;
always@(posedge mclk1)       
                word_clk<=word_count[7];
/**************************************************************/
/*differentiatior(including decimation stage)
perform the differentiation stage(FIR) at a lower speed
Z=one sample delay
WORD_CLK=out word rate
*/
always@(posedge word_clk or negedge reset)
        if(!reset)
                begin
                        acc3_d2<=0;
                        diff1_d<=0;
                        diff2_d<=0;
                        diff1<=0;
                        diff2<=0;
                        diff3<=0;
                end
        else
                begin
                        diff1<=acc3-acc3_d2;
                        diff2<=diff1-diff1_d;
                        diff3<=diff2-diff2_d;
                        acc3_d2<=acc3;
                        diff1_d<=diff1;
                        diff2_d<=diff2;
                end
/**************************************************************/
reg [1:0] i;
reg [15:0] temp_data;
reg temp_sig;
/*clock the sinc output into an output register
WORD_CLK =output word rate
*/
always@(posedge word_clk or negedge reset)
        if(!reset)
                begin
                        i<=2'd0;
                        temp_data<=16'd0;
                        temp_sig<=1'b0;
                end
        else
                case(i)
                        2'd0:
                                        begin
                                                if(diff3[24]==1)        begin temp_data<=16'hffff; end
                                                else
                                                        begin
                                                                temp_data[15] <= diff3[23];
                                                                temp_data[14] <= diff3[22];
                                                                temp_data[13] <= diff3[21];
                                                                temp_data[12] <= diff3[20];
                                                                temp_data[11] <= diff3[19];
                                                                temp_data[10] <= diff3[18];
                                                                temp_data[9] <= diff3[17];
                                                                temp_data[8] <= diff3[16];
                                                                temp_data[7] <= diff3[15];
                                                                temp_data[6] <= diff3[14];
                                                                temp_data[5] <= diff3[13];
                                                                temp_data[4] <= diff3[12];
                                                                temp_data[3] <= diff3[11];
                                                                temp_data[2] <= diff3[10];
                                                                temp_data[1] <= diff3[9];
                                                                temp_data[0] <= diff3[8];
                                                        end
                                                       
                                                i<=2'd1;
                                        end
                        2'd1:
                                begin
                                        temp_sig<=1'b1;
                                        i<=2'd2;
                                end       
                        2'd2:
                                begin
                                        temp_sig<=1'b0;
                                        i<=2'd0;
                                end               
                endcase
       
/**************************************************************/
assign DATA=temp_data;//
assign dat_sig=temp_sig;//
/**************************************************************/
endmodule

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

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

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

出0入0汤圆

 楼主| 发表于 2013-5-22 22:37:54 | 显示全部楼层
请教高手能否上传一点关于SIN3的三阶数字滤波器 的资料啊??这个查了很多资料,看了很多还是不太懂,积分微分看了头都大了。

出0入0汤圆

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

本版积分规则

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

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

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

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