EDA 技术实验报告
实验项目名称:7段数码显示译码器设计
实验日期:2012.06.04 实验成绩:
实验评定标准:
一、实验目的
学习7段数码显示译码器设计,学习VHDL的CASE语句应用及多层次设计方法。
二、实验器材
QuartusII7.2软件
三、实验内容(实验过程)
(一).
1、首先设计一个2选1的数据选择器
(1)打开软件,选择菜单file—>new,在弹出的new对话框中选择Device Design Files 的VHDL File项,按OK键后进入VHDL文本编辑方式。
根据7段数码显示译码器的功能编辑相应的源程序。如下:
library ieee;
use ieee.std_logic_1164.all;
entity decl7s is
port (a:in std_logic_vector(3 downto 0);
led7s:out std_logic_vector(6 downto 0));
end decl7s;
architecture one of decl7s is
begin
process(a)
begin
case a is
when"0000"=>led7s<="0111111";
when"0001"=>led7s<="0000110";
when"0010"=>led7s<="1011011";
when"0011"=>led7s<="1001111";
when"0100"=>led7s<="1100110";
when"0101"=>led7s<="1101101";
when"0110"=>led7s<="1111101";
when"0111"=>led7s<="0000111";
when"1000"=>led7s<="1111111";
when"1001"=>led7s<="1101111";
when"1010"=>led7s<="1110111";
when"1011"=>led7s<="1111100";
when"1100"=>led7s<="0111001";
when"1101"=>led7s<="1011110";
when"1110"=>led7s<="1111001";
when"1111"=>led7s<="1111001";
when others =>null;
end case;
end process;
end one;
2、对该VHDL语言进行编辑后,无误后进行仿真。点击相应的编辑按钮用来检查源程序的正确性。(文档由风行播放器https://www.wendangku.net/doc/a510270347.html,/ 暴风影音2014:https://www.wendangku.net/doc/a510270347.html,/ 整理)
3.、编译和仿真
仿真前要新建波形文件:file→new→other files→vector waveform file 点击OK后在出现的新建波形文件左边空白栏点击鼠标右键,选择insert→insert node or bus.在出现的对话框中直接点击node finder。之后,在出现的对话框中选择list。当左边的nodes found栏中出现设计文件的输入输出端口后,点击》加入到右边的
selected node中,点击OK。
在完成7段数码显示译码器源程序的编辑后,执行Processing→start compilation 命令,对decl7s.vhd进行编译。
下图是7段数码显示译码器对应的仿真波形:
在完成对源文件的编译后,执行File→create/update→create symbol files for current 命令,为VHDL设计文件生成元件符号。其元件符号如图所示符号如图所示
可以供其他电路和系统设计的调用。
4、下载
选择电路模式6。用数码8显示译码输出,键8、键7、键6、键5四位控制输入,硬件验证译码器的工作性能。
目标芯片选择:实验箱上的目标芯片为ACEX1K系列的EP1K30TC芯片,必须选择正确的芯片才能下载成功。在菜单栏里选择:assignments→device 在出现的对话框中选择正确的芯片即可。
(1)引脚的选择:通过试验箱左下角的按键选择模式6。键八、键七、键六、键五分别接a[3]、a[2]、a[1]、a[0];PIO46—PIO40分别接g,f,e,d,c,b,a.
(2)引脚绑定:引脚选定之后,可以把输入输出端口绑定在选择好的引脚上。
即a[3]绑定在引脚27上,a[2]绑定在引脚26上,a[1]绑定在引脚23上,a[0]绑定在引脚22上,led7s[6]接在引脚95上,led7s[5]接在引脚92上,led7s[4]接在引脚91上,led7s[3]接在引脚90上,led7s[2]接在引脚89上,
led7s[1]接在引脚88上led7s[0]接在引脚87上。如图:
(3)下载和硬件测试:把实验箱连接好电源和计算机接口,把程序下载到目标芯片上,就可以在实验箱上通过按键和发光二级管来检验实验的正确性。
5.设计加法计数器
(1)打开软件,选择菜单file—>new,在弹出的new对话框中选择Device Design Files 的VHDL File项,按OK键后进入VHDL文本编辑方式。
根据加法计数器的功能编辑相应的源程序。如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt10 is
port(
clk,rst,en :in std_logic;
cq :out std_logic_vector(3 downto 0);
cout :out std_logic);
end cnt10;
architecture behav of cnt10 is
begin
process(clk,rst,en)
variable cqi :std_logic_vector(3 downto 0);
begin
if rst ='1' then cqi :=(others=>'0');
elsif clk'event and clk='1' then
if en='1' then
if cqi<9 then cqi:=cqi+1;
else cqi:=(others=>'0');
end if;
end if;
end if;
if cqi =9 then cout<='1';
else cout<='0';
end if;
cq<=cqi;
end process;
end behav;
6、对该VHDL语言进行编辑后,无误后进行仿真。点击相应的编辑按钮用来检查源程序的正确性。
7.、编译和仿真
仿真前要新建波形文件:file→new→other files→vector waveform file 点击OK后在出现的新建波形文件左边空白栏点击鼠标右键,选择insert→insert node or bus.在出现的对话框中直接点击node finder。之后,在出现的对话框中选择list。当左边的nodes found栏中出现设计文件的输入输出端口后,点击》加入到右边的selected node中,点击OK。
在完成加法计数器源程序的编辑后,执行Processing→start compilation命令,对cnt10.vhd进行编译。
下图是加法计数器对应的仿真波形:
在完成对源文件的编译后,执行File→create/update→create symbol files for current 命令,为VHDL设计文件生成元件符号。其元件符号如图所示符号如图所示
可以供其他电路和系统设计的调用。
8、利用元件例化语句,按实验书上的图6.3方式连接成顶层设计电路。源程序如下:
library ieee;
use ieee.std_logic_1164.all;
entity tan is
port(clock0:in std_logic;
rat0:in std_logic;
ena0:in std_logic;
led:out std_logic_vector (6 downto 0);
cout0:out std_logic);
end tan;
architecture lang of tan is
signal tmp:std_logic_vector (3 downto 0);
component cnt10
port(
clk,rst,en :in std_logic;
cq :out std_logic_vector(3 downto 0);
cout :out std_logic);
end component;
component decl7s
port (a:in std_logic_vector(3 downto 0);
led7s:out std_logic_vector(6 downto 0));
end component;
begin
cnt4b:cnt10 port map(clock0,rat0,ena0,tmp,cout0);
decl7a:decl7s port map(tmp,led);
end lang;
9、对该VHDL语言进行编辑后,无误后进行仿真。点击相应的编辑按钮用来检查源程序的正确性。
10.、编译和仿真
仿真前要新建波形文件:file→new→other files→vector waveform file 点击OK后在出现的新建波形文件左边空白栏点击鼠标右键,选择insert→insert node or bus.在出现的对话框中直接点击node finder。之后,在出现的对话框中选择list。当左边的nodes found栏中出现设计文件的输入输出端口后,点击》加入到右边的selected node中,点击OK。
在完成7段数码显示译码器源程序的编辑后,执行Processing→start compilation 命令,对tan.vhd进行编译。
下图是图6.3对应的仿真波形:
11、下载
选择电路模式6。用数码8显示译码输出,键3作为时钟输入,,或者直接接clock0.
目标芯片选择:实验箱上的目标芯片为ACEX1K系列的EP1K30TC芯片,必须选择正确的芯片才能下载成功。在菜单栏里选择:assignments→device 在出现的对话框中选择正确的芯片即可。
(1)引脚的选择:通过试验箱左下角的按键选择模式6。Clock0接clock0;.键八接rat0,键七接ena0;speaker接cout0;PIO46—PIO40分别接g,f,e,d,c,b,a.
(2)引脚绑定:引脚选定之后,可以把输入输出端口绑定在选择好的引脚上。即rat0绑定在引脚27上,ena0绑定在引脚26上,clock0绑定在引脚126上,cout0绑定在引脚99上,led7s[6]接在引脚95上,led7s[5]接在引脚92上,led7s[4]接在引脚91上,led7s[3]接在引脚90上,led7s[2]接在引脚89上,led7s[1]接在引脚88上led7s[0]接在引脚87上。如图:
四、结果及分析
以下是硬件测试的结果: