求大神指点,SIN3 数字滤波器的构建
本帖最后由 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 DATA;//filtered op
output dat_sig;
//integer location;
//integer info_file;
reg ip_data1;
reg acc1;
reg acc2;
reg acc3;
//reg acc3_d1;
reg acc3_d2;
reg diff1;
reg diff2;
reg diff3;
reg diff1_d;
reg diff2_d;
//reg DATA;
reg 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;
/**************************************************************/
/*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 i;
reg 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==1) begin temp_data<=16'hffff; end
else
begin
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
temp_data <= diff3;
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 请教高手能否上传一点关于SIN3的三阶数字滤波器 的资料啊??这个查了很多资料,看了很多还是不太懂,积分微分看了头都大了。 SIN3 的三阶 数字滤波器有人做过吗??谢谢指点一下
页:
[1]