实验项目名称:7段数码显示译码器设计 实验日期: 2012.06.04 实验评定标准:
1)实验程序是否正确 2)实验仿真、结果及分析是否合理 3)实验报告是否按照规定格式 实验成绩: ___________
A ( ) B ( ) C () A ( ) B ( ) C () A ( ) B ( ) C () 一、实验目的
学习7段数码显示译码器设计,学习VHDL的CASE语句应用及多层次设 计方
法。
二、 实验器材
QuartusII7.2 软件
三、 实验内容(实验过程)
(-).
1、首先设计一个2选1的数据选择器
(1) 打开软件,选择菜单file—>new,在弹出的new对话框中选择Device Design Files的VHDLFile项,按OK键后进入VHDL文本编辑方式。 根据7段数码显示译码器的功能编辑相应的源程序。如下: library ieee;
use ieee.std_logic_l 164.all; entity decl7s is
port (a:in std_logic_vector(3 downto 0);
led7s:out std_logic_vector(6 downto 0));
end dec!7s;
architecture one of dec!7s is
begin process(a) begin case a is
whenH0000H=>led7s<=H0111111H; when,,0001,,=>led7s<=\"0000110\"; when\"0010\"=>led7s<=\"1011011\"; when”0011 H=>led7s<=H 1001111”; when\"0100\"=>led7s<=\" 1100110\"; when\"0101 \"=>led7s<=\" 1101101\"; whenM0110n=>led7s<=Hll 11101”; when\"011 r=>led7s<=\"0000111H; when\"1000\"=>led7s<=\" 1111111\"; when,,1001,,=>led7s<=H 1101111”; when\" 1010\"=>led7s<=\" 1110111”; whenH1011n=>led7s<=Hll 11100M; when111100H=>led7s<=M0111001M; when\" 110r,=>led7s<=,,1011110\"; when\" 1110\"=>led7s<=\" 111 lOOl1'; when1' 1111 H=>led7s<=H 1111001”; when others =>null; end case; end process; end one;
2、 对该VHDL语言进行编辑后,无误后进行仿真。点击相应的编辑按钮用来检 查源程序的正确性°, 整理》
3. 、编译和仿真
仿真前要新建波形文件:file~^ new-^other files-^vector waveform file 点击 OK 后 在出现的新建波形文件左边空口栏点击鼠标右键,选择insert->insert node or bus. 在岀现的对话框中直接点击node findero之后,在岀现的对话框中选择list。当 左边的nodes found栏中岀现设计文件的输入输出端口后,点击》加入到右边的
r http://www.funsion.net/ i 2014: http://www.baofeng5.net/ selected node 中,点击 OK。
在完成7段数码显示译码器源程序的编辑后,执行Processing-^start compilation 命令,对decl7s.vhd进行编译。
下图是7段数码显示译码器对应的仿真波形:
Master The Bai:
158ns
< I * Pcincer
Irterval Sta-i: 20. Q ns 30 Q ns Value 15.8 po 4 1^-2 時3 )(fl] } IS 8 M 回a •*[3】 -»[z] L“[0] H lcd75 -..6J X ( : A I A I A I 〔1] (21 0] h A I A I A i A i \"i : ⑹ r 穆5 36 4 A [I: ? ) zxz r i i \"L \\[ r zx0 ■・• 4] -..3] i S CJMD a】2 -..1] L..oj A A A l r 在完成对源文件的编译后,执行 Filecreate/updatecreate symbol files for current 命令,
为VHDL设计文件生成元件符号。其元件符号如图所示符号如图所示 可以供其他电路和系统设计的调用。
f d«c=l75 2 ! 9 led?5[6..O] 4 a[3.,0] ■ * / ;inst
• o • /y ■ • X 皿〃〃〃〃〃〃〃〃/* 4、下载
选择电路模式6。用数码8显示译码输出,键8、键7、键6、键5四位控制输入, 硬件验证译码器的工作性能。
LI标芯片选择:实验箱上的LI标芯片为ACEX1K系列的EP1K30TC芯片,必须 选择正确的芯片才能下载成功。在菜单栏里选择:assignments->device在岀现的 对话框中选择正确的芯片即可。
(1)引脚的选择:通过试验箱左下角的按键选择模式6。键八、键七、键六、 键五
分别接 a⑶、a[2]、a[l]、a[0];PIO46—PIO40 分别接 g,f,edcba・ (2)引脚绑定:引脚选定之后,可以把输入输岀端口绑定在选择好的引脚上。 即
a[3]绑定在引脚27上,a⑵绑定在引脚26 ±, a[l]绑定在引脚23上, a[0]绑定在引脚22上,led7s[6]接在引脚95 ±, led7s[习接在引脚92 ±, led7s[4]接在引脚91上,led7s[3]接在引脚90 ±, led7s[2]接在引脚89上,
Ied7s[l]接在引脚88上led7s[0]接在引脚87上。如图:
;Namea: |z
二I 空1 tat: xj^z
Nods Name Direction Input Input Input Input Outpjt Location / Reser xod o(3. .0] <3. .0] *・・0] G-cup l 2 3 4 5 6 7 6 9 10 o[0] a[L] 或2] 43] led7s[0] Ied7$[l] Ied7$[z] Ied7s[3] Icd7s[4] lcd7$[S] hd7s[6] P1N-22 P1N-23 A P1N-26 Dt* P1NJ27 P1N-87 P1N 88 PIN 89 PIN SO led7s(6..O] led7s[6..O] ledrs[6..o) led7<£o..O] lcd?s[6..O] lcd7<[6..0] led 独 6・.0] :GutpJt OutpJl Gutpjl Outpjt Cutpjt P1N 92
11 0 (3) 下载和硬件测试:把实验箱连接好电源和讣算机接口,把程序下载到LI标 芯
片上,就可以在实验箱上通过按键和发光二级管来检验实验的正确性。 5 •设计加法计数器
(1)打开软件,选择菜单file—>new,在弹出的new对话框中选择Device Design Files的VHDLFile项,按OK键后进入VHDL文本编辑方式。 根据加法计数器的功能编辑相应的源程序。如下: library ieee;
use ieee.std_logic_l 164.all; use ieee.std Jogic_imsigned.dll; entity ent 10 is po«(
clk,rst,en :in std_logic;
cq :out std_logic_vector(3 downto 0); cout :out std」ogic);
end ent 10;
architecture behav of ent 10 is begin
process(clk,rst,en)
variable cqi :std_logic_vector(3 downto 0); begin
if rst =V then cqi :=(others二>O); elsif clkevent and clk=*r then
if en= I* then
if cqi<9 then cqi:=cqi+l;
else cqi:=(others二>'0'); end if; end if; end if;
if cqi =9 then cout<= T; else cout<=,0,; end if; cq<=cqi; end process; end behav;
6、 对该VHDL语言进行编辑后,无误后进行仿真。点击相应的编辑按钮用来检 查源程序的正确性。 7. 、编译和仿真
仿真前要新建波形文件:file-^ new-^other files-^vector waveform file 点击 OK 后 在出现的新建波形文件左边空口栏点击鼠标右键,选择insertinsert node or bus. 在岀现的对话框中直接点击node findero之后,在出现的对话框中选择list。当 左边的nodes found栏中出现设计文件的输入输出端口后,点击》加入到右边的 selected node 中,点击 OK。 在完成加法讣数器源程序的编辑后,执行Processing-^start compilation命令,对 cntlO.vhd进行编译。
下图是加法计数器对应的仿真波形:
Master Time Bai:
15.9
<| »| Porter 2.48
Infeivat
13.42 ns Ss
End 20 0 nz .■
IS 9 c
I\" >仪
在完成对源文件的编译后,执行 Filecreate/updatecreate symbol files for current 命令,为VHDL设计文件生成元件符号。其元件符号如图所示符号如图所示 可以供其他电路和系统设计的调用。
8、利用元件例化语句,按实验书上的图6.3方式连接成顶层设讣电路。 源程序如
下: libraiy ieee;
use ieee.std」ogic_l 164.all; entity tan is
port(clockO:in std」ogic;
ratO:in std」ogic; enaO:in std_logic;
led:out std」ogic_vector (6 downto 0); coutO:out std」ogic); end tan;
architecture lang of tan is
signal tmp:std_logic_vector (3 downto 0); component ent 10 port(
clk,rst,en :in std_logic;
cq :out std_logic_vector(3 downto 0);
cout :out std」ogic);
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:cntl0 port inap(clock0,rat0,ena0,tmp,coutO); decl7a:decl7s port map(tmpJed); end lang;
9、 对该VHDL语言进行编辑后,无误后进行仿真。点击相应的编辑按钮用来检 查源程序的正确性。
10. 、编译和仿真
仿真询要新建波形文件:file-^ new-^other files-^vector waveform file 点击 OK 后 在出现的新建波形文件左边空白栏点击鼠标右键,选择insert-^insert node or bus. 在岀现的对话框中直接点击node findero之后,在岀现的对话框中选择list。当 左边的nodes found栏中出现设计文件的输入输出端口后,点击》加入到右边的 selected node 中,点击 OK。 在完成7段数码显示译码器源程序的编辑后,执行Processing-^start compilation 命令,对tan.vhd进行编译。
下图是图6.3对应的仿真波形:
159ns 11.5 ne Irtef'/at 10 1} ns 44 ns Siait End: 20 9 05 A )2 15.9 A i A i A A • A i A A A A A A A 1 Wan* clocMj coutO 。佃 EJ led IS/ ■ 0 -1 5 T 衿3 厂 ? ■r f 3 -...6] • • 5] ..4] 4 3 -...3】 -.2] r • 1] L...o] 4^9 •X#10 1K下载
选择电路模式6。用数码8显示译码输出,键3作为时钟输入,,或者直接接clockO. 口标芯片选择:实验箱上的LI标芯片为ACEX1K系列的EP1K30TC芯片,必须 选择正确的芯片才能下载成功。在菜单栏里选择:assignments->device在岀现的 对话框中选择正确的芯片即可。
⑴引脚的选择:通过试验箱左下角的按键选择模式6。ClockO接clockO;•键八接 ratO,键七接 enaO;speaker 接 coutO: PIO46一PIO40 分别接 gXe,d,c,b,a.
(2)引脚绑定:引脚选定之后,可以把输入输出端口绑定在选择好的引脚上。即 ratO绑定在引脚27上,enaO绑定在引脚26 ±, clockO绑定在引脚126 ±, coutO 绑定在引脚99上,led7s[6]接在引脚95上,led7s[5]接在引脚92上,led7s[4]接 在引脚91上,led7s[3]接在引脚90上,led7s[2]接在引脚89上,led7s[l]接在引 脚88 ± Ied7s[0]接在引脚87 ±o如图:
irn r n 厂 Narred: ||
V| 凹 Edit X]y |PIN.91 Njde Name clockO Input Output [rput Output Output DKecticn PIN.9? PIM 26 PIN.95 PHg PHJ 91 PIM 90 LCCdttrn Reserved Gojp 1 PIW_126 2 3 4 5 6 抄 coU:0 ensO led⑹
7 A a a 坊 led[6..O] kd[6..O] led[6..O] led[6..O] ted同 18⑷ IS⑶ Output Output 四、结果及分析
以下是硕件测试的结果:
因篇幅问题不能全部显示,请点此查看更多更全内容