实验二:FIR滤波器的设计及FPGA实现
作者: Saint
掘金:https://juejin.im/user/5aa1f89b6fb9a028bb18966a
微博:https://weibo.com/5458277467/profile?topnav=1&wvr=6&is_all=1
GitHub:github.com/saint-000
一、实验器材(设备、元器件):
计算机、FPGA 开发板、开发板数据手册。
二、实验内容:
编写 VHDL 代码、生成下载文件,下载设计到 FPGA 实现如下功
能:
输出:y[n]=0.5x[n]+0.31x[n-1]+0.63*x[n-2]。其中x[n],x[n-1],x[n-2]为3位二进制整数,计算结果用十进制数显示、保留一位小数。(设计一个FIR滤波器)
三、实验步骤:
(1)创建工程
1.打开 Xilinx ISE 10.1i。选择 File-New Project 新建工程,根据需要设定工程名称和工程路径。
2.点击下一步配置工程属性, Device Family 选择 Spartan2,Device 选择 XC2S50, Package 选择 TQ144, Speed Grade 选择-6。
3.直到完成工程的建立。
(2)建立和编写源文件
1.在 Sources in Project 中点右键,选择 New Source。在弹出的对话框中选择 VHDL Module,自己设定 File Name,一路下一步,建立一个新的源文件。
2.在新的源文件中录入设计,完成数字时钟的功能。
(3)设计的仿真
编写 test_bench,用 Modelsim 对设计进行仿真,验证功能正确性。
(4)上板调试
将设计下载到板上进行调试,验证设计的正确性。
四、实验数据及结果分析:
源码:
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity RTL is
port(
clk: in std_logic;
clr: in std_logic;--拨码开关最后一位(第八,开为0电平)
ok: in std_logic;
x : in STD_LOGIC_vector(0 to 2);--输入xn三位
s : in STD_LOGIC_vector(0 to 2);--选择xn几
led : out STD_LOGIC_vector(0 to 2);
sel : out STD_LOGIC_VECTOR(0 to 7); --只要最后两位 数码管位sel与段seg
seg: out STD_LOGIC_VECTOR(0 to 7)
);
end RTL;
--}} End of automatically maintained section
architecture RTL of RTL is
-- enter your statements here --
signal xn1,xn2,xn3:std_logic_vector(0 to 2);
signal leds : STD_LOGIC_vector(0 to 2):