数字集成电路设计实验——FIR滤波器

1.      课程信息

实验地点:清水河校区KB239

  • ■     实验时间:2021.04.16
  • ■     实验时长:3小时(4节课)

2.      实验要求 

1. The fir filter input sampling rate is 100kHz, the filter passband single-sideband bandwidth is 20kHz, the out-of-band suppression is 90dB, and the in-band ripple is 1dB.

    2. The filter coefficient needs to be fixed-point, and the effective number of ADCs is 24bit. The filter coefficient bit width is self-defined.

思考(加分项):

1. The relationship between filter passband, stopband, out-of-band rejection and filter order

2. How to choose the appropriate filter coefficient bit width

3. Design test vector set, write testbench for verification test and simulate on the hardware

3.      设计与实现

3.1实验步骤

  1. 1.      创建项目
  2. 2.      填充代码
  3. 3.      综合代码并完成debug
  4. 4.      进行仿真
  5. 5.      下板实践

3.2电路功能说明

1、使用matlab设计一个FIR滤波器

2、使用matlab生成信号

%【参数】

fs=100000; %采样率

N=100000; %整个图由N个样点构成

t=0:1/fs:(N-1)/fs;%生成坐标点

f1=10000;%生成信号频率,f1与f3应有一个在通带内一个在阻带内,以便后续验证滤波器

f3=30000;

%【生成正弦信号】

y=sin(2*pi*f1*t)+sin(2*pi*f3*t);%生成时域点集

%时域信号【画图】

figure(1);

plot(t,y);

title(‘正弦信号’);

y=fi(y, 1, 24, 23);%由浮点数变为24bit定点有符号数,小数长度为23。

%转为频谱信号并【画图】

yy=abs(fftshift(fft(double(y),N)));

figure(2);

plot(fs*linspace(-0.5,0.5,length(yy)),yy);

title(‘正弦信号’);

out=1;%手动改为1时,输出波形数据到文件input.txt

if out==1

    %生成输入信号文件

    fid1=fopen(‘./input.txt’,’wt’);

    for i = 1:1:N

     data = hex(y(i));%按照vivado输入格式需求,需要转换为十六进制格式

     fprintf(fid1,’%s\n’,data);

    end

end

3、使用VIVADO FIR IP

4、testbnech

`timescale 1us / 1ps

//////////////////////////////////////////////////////////////////////////////////

// Company:

// Engineer:

//

// Create Date: 2021/03/22 10:30:12

// Design Name:

// Module Name: testbench

// Project Name:

// Target Devices:

// Tool Versions:

// Description:

//

// Dependencies:

//

// Revision:

// Revision 0.01 – File Created

// Revision 0.02 – Add Comment

// Additional Comments:

//

//////////////////////////////////////////////////////////////////////////////////

module testbench(

    );

    reg aresetn;    // Reset signal

    reg aclk;       // Clock signal

    reg s_axis_data_tvalid;

    wire s_axis_data_tready;

    reg [23:0]s_axis_data_tdata;

    wire  m_axis_data_tvalid;

    wire [40:0]m_axis_data_tdata;

    reg [23:0] mem [99999:0];   //Memory of input data

    reg [31:0] n;               //index of data

fir_compiler_0 fir1 (

  .aresetn(aresetn),                        // input wire aresetn

  .aclk(aclk),                              // input wire aclk

  .s_axis_data_tvalid(s_axis_data_tvalid),  // input wire s_axis_data_tvalid

  .s_axis_data_tready(s_axis_data_tready),  // output wire s_axis_data_tready

  .s_axis_data_tdata(s_axis_data_tdata),    // input wire [23 : 0] s_axis_data_tdata

  .m_axis_data_tvalid(m_axis_data_tvalid),  // output wire m_axis_data_tvalid

  .m_axis_data_tdata(m_axis_data_tdata)    // output wire [41 : 0] m_axis_data_tdata

   );

integer Out;

initial

begin

    Out=$fopen(“./output.txt”,”w”);//Remember to edit to your path. Use “/” rather than “\” as the path symbol

    $readmemh(“./input.txt”,mem);//Remember to edit to your path. Use “/” rather than “\” as the path symbol

    aclk = 0;

    aresetn = 0;

    #50

    aresetn = 1;

end

always #5 aclk = ~aclk; //set clock signal

//When you need to save output register, use

//$fdisplay(Out,”%x”,m_axis_data_tdata);

//to save this register data to output.txt.

/*

*/

//Your code here

always @(posedge aclk or negedge aresetn)

begin

if (~aresetn) begin

    s_axis_data_tvalid <= 0;

    s_axis_data_tdata <= 0;

    n <= 0;

end else begin

if (s_axis_data_tready) begin

s_axis_data_tvalid <= 1;

s_axis_data_tdata <= mem[n];

n <= n + 1;

end

if (m_axis_data_tvalid) begin

$fdisplay(Out,”%x”,m_axis_data_tdata);

end

end

end

endmodule

4.实验结果

5.实验中遇到的问题及解决方法

    当采样信号持续时间较短时,即持续时间远小于1秒时,经过FIR滤波器的信号恢复出来后,会出现很多毛刺,而适当增加信号持续时间则能很好减少毛刺现象。同时,当信号持续时间较短时,滤波后的信号生成.txt文件会有很多xxxxxxx变量,而此变量不能被read.m文件的函数处理,会导致报错,需要增加时长,或者删除output.txt文件中的xxxxxx信息。

6.实验感想和建议

通过Matlab生成信号并输出为.txt文件,以及调用Matlab滤波器设计工具来设计一个FIR滤波器,同时在Vivado中调用此滤波器,编写tb文件,将滤波后的信号输出为.txt文件,在Matlab中观察输出信号的波形。 实验体验了FPGA做信号处理的一般流程,进一步了解FPGA的应用。

The end

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇