VLSI 设计的 FPGA 验证
PROM芯片的配置文件:counter_LED.mcs 6. 第六步:FPGA测试
下载成功后,取下program引脚短接跳线块,即可进行测试。 测试方法:手动操作按键,观测LED数码管。
实验结论与分析:
通过观测发现,LED数码能有效显示计数器的计数值,但一次手动按键操作有多次误计数的不稳定现象。说明本设计的可靠性较差,需要作进一步改进设计。
VLSI 设计的 FPGA 验证
实验(三)标准实验报告
实验名称:改进型计数器设计与FPGA验证实验
实验目的:通过改进型计数器设计使学生认识到工程设计实践中稳定性、可靠性
设计的必要性,通过FPGA实物验证使学生充分认识去抖动电路的抗噪效果。并养成在完成功能设计的同时兼顾性能设计的良好习惯。
实验原理:参见《VLSI设计的FPGA验证实验指导书》 实验步骤及实验记录:
1. 第一步:分析实验二的计数器计数值不稳定的原因
实验二计数器实验中计数值不稳定现象是:LED显示数据有乱跳的现象。 引起不稳定现象的原因是手动操作按键时有“抖动”噪声。 要消除抖动噪音,可以引入去抖动电路。
改进后的模块框图如下,从图中可以很清楚它们的连接关系。
其中增加的弹跳消除模块为图中的debounce模块,端口包括: clk:系统时钟端口 touch:键盘输入端口 clr:清零复位端口
push_out:进行完噪声消除以后的键盘输入信号。 2.第二步:去抖动电路设计
去抖动电路基本思路:引入采样时钟,在对输入信号采样时,当相邻两次采样数据相同,则认为信号稳定有效,输出该值;否则当成非稳定信号,去抖输出保持原值不变。
去抖动电路源程序:
VLSI 设计的 FPGA 验证
--content definition of component "debounce" library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; --io signal declaraction entity debounce is
port(clk: in std_logic; --basic clock input
clr:in std_logic;
touch: in std_logic; --push button signal
push_out: out std_logic); --cleared push botton signal
end debounce;
architecture arch of debounce is
signal sample: std_logic;
--declaraction of self_built sampling pulse from clock begin
sampling_signal: block --input clk --output sample
signal delay:std_logic; --one_step delay
signal q: std_logic_vector(4 downto 0); --osc/2^5=32hz(31.25ms)
begin
process(clk) begin
if clr='1' then q<="00000"; delay<='0';
elsif rising_edge(clk) then
delay<=q(4); q<=q+1;
VLSI 设计的 FPGA 验证
end if;
sample<=q(4) and not delay; --leading_edge differentiating
end process; end block sampling_signal; --cleared push botton signal generation cleared_push:block --input:clk,sample,touch --output:push_out
signal dff0,dff1:std_logic; --two_step delay ff signal push:std_logic; --output of rsff for push signal signal q1,q2:std_logic; begin
process(clk) begin
if clr='1' then
dff0<='0'; dff1<='0'; push<='0';
elsif rising_edge(clk) then
if sample='1' then dff1<=dff0;
dff0<=touch;
push<=dff0 and dff1; end if; end if; end process; process(clk) begin
if clr='1' then
q2<='0';
VLSI 设计的 FPGA 验证
q1<='0';
elsif rising_edge(clk) then
q2<=q1; q1<=push; end if;
push_out<=q1 and not q2;
end process;
end block
cleared_push; end arch;
3.第三步:采样时钟电路设计
FPGA开发板上晶振为33MHz,将该时钟信号进行4分频后得到8.25MHz的采样时钟。
4. 第四步:改进型计数器的VHDL仿真
仿真工具选择:Active-HDL 仿真波形如下图所示:
由时钟产生一个取样信号,然后对键盘输入的信号进行取样。只有在两次取样均能采到信号时,才算一次输入,否则不被计入。
如上图可见,当输入信号(touch)保持200ns时,能被有效识别,其它的都没有被识别。达到了消除噪声的目的。 5. 第五步:VHDL程序的综合
综合工具选择:FPGA Express。 综合后形成的网表文件:counter_EN.edf 6. 第六步:FPGA物理实现及下载
物理实现及其下载工具选择:Xilinx Foundation 管脚分配文件:counter_EN.ucf
VLSI 设计的 FPGA 验证
用跳线块将FPGA开发板上的program引脚与GND短接,使FPGA处于下载就绪状态,选择目标下载文件完成下载。
FPGA目标下载文件:counter_EN.bit PROM目标下载文件:counter_EN..mcs 7. 第七步:FPGA测试
下载成功后,取下program引脚短接跳线块,即可进行测试。 测试方法:手动操作按键,观测LED数码管。
实验结论与分析:
通过观测发现,LED数码能有效显示计数器的计数值,且一次手动按键操作只发生一次计数,计数操作稳定。
通过与实验二作对比发现:引入去抖动设计后计数器的计数效果得到了明显改进。