数电实验报告.docx
《数电实验报告.docx》由会员分享,可在线阅读,更多相关《数电实验报告.docx(27页珍藏版)》请在冰豆网上搜索。
![数电实验报告.docx](https://file1.bdocx.com/fileroot1/2023-4/21/f050c88a-7e15-472f-b4f2-9ad3193c92d6/f050c88a-7e15-472f-b4f2-9ad3193c92d61.gif)
数电实验报告
数字电路与逻辑设计综合设计实验报告
实验名称:
8X8点阵显示装置
一.摘要:
本实验主要在理论分析和具体的软硬件实现上,针对8×8矩阵的扫描显示、字符的单个显示,字符的循环显示,以及对各项显示功能的切换控制等内容进行了分析与探讨。
在理论分析的基础上,用VHDL语言编写源代码,再配合具体电路连接,实现点阵的扫描,字符的单个显示,字符的循环显示,以及对各项显示功能的切换控制等。
关键字:
扫描,切换
二.设计任务要求:
1.用8×8点阵做一个基本矩阵,设计扫描控制电路,使光点从左上角象素点开始扫描,终止于右下角象素点,然后周而复始地重复下去,扫过一帧所需时间为16秒;
2.用8×8点阵显示4个字符,每秒显示一个字符;
3.显示一个活动的简单图像;
4.以上三种功能可以手动或自动转换;
三.所用元器件:
EPM7128一块
面包板一块
8×8点阵模块一块
按键开关一个
导线若干
四.设计思路和总体设计框图:
1.逐点扫描的实现:
实验要求扫描一帧是16秒,由于是8×8点阵,即每一点亮1/4秒,而我们的时钟信号是1MHz的信号。
因此要对时钟信号进行分频以获得周期为1/4秒的信号,其频率是4Hz,而1M信号的224分频是4Hz,因此我在实验中选择m(21),m(22),m(23)三路信号来控制行选通,又因为每行有8个点,所以列选通只要比行选通快三位,m(18),m(19),m(20)就可以了。
2.显示的实现:
字符的显示其实与逐点扫描一样,只不过要求扫描速率足够快,快到超人眼所能分辨的程度就行了。
在实验中我选用的是m(20),m(21)两路信号来控制行选通,用m(10),m(11),m(12)三路信号来控制列选通。
3.循环显示的实现:
循环显示原理与字符显示一样,只是帧数较多,只要把两个字符显示状态的过渡状态也写成代码就行了,实验中,我选择每两个字符之间用三帧来过渡,并选用m(18),m(19),m(20),m(21)四路信号来控制行选通,用m(10),m(11),m(12)三路信号来控制列选通。
4.总体结构框图:
五.控制器部分的状态转移图和流程图:
1.状态转移图:
2.流程图:
六.分块电路的关键源程序:
1.分频部分的关键源程序:
process(clk)
begin
if(clk'eventandclk='1')then
m<=m+1;
fangdou<=m(15);
f0r<=m(23downto21);
f0c<=m(20downto18);
f1c<=m(12downto10);
f1r<=m(21downto20);
f2c<=m(12downto10);
f2r<=m(21downto18);
endif;
endprocess;
2.防抖部分的关键源程序:
process(fangdou)
begin
iffangdou'eventandfangdou='1'then
k
(2)<=k
(1);
k
(1)<=k(0);
k(0)<=key;
endif;
g<=k
(2)andk
(1)andk(0);
endprocess;
3.按键计数的关键源程序:
process(g)
begin
if(g'eventandg='1')then
ifx=2then
x<=0;
else
x<=x+1;
endif;
endif;
endprocess;
4.点阵扫描模块实现的关键源程序:
process(f0c)
begin--点阵逐点扫描
casef0cis
when"000"=>column<="11111110";
when"001"=>column<="11111101";
when"010"=>column<="11111011";
when"011"=>column<="11110111";
when"100"=>column<="11101111";
when"101"=>column<="11011111";
when"110"=>column<="10111111";
when"111"=>column<="01111111";
whenothers=>column<="00000000";
endcase;
endprocess;
process(f0r)
begin
casef0ris
when"000"=>row<="00000001";
when"001"=>row<="00000010";
when"010"=>row<="00000100";
when"011"=>row<="00001000";
when"100"=>row<="00010000";
when"101"=>row<="00100000";
when"110"=>row<="01000000";
when"111"=>row<="10000000";
whenothers=>row<="11111111";
endcase;
endprocess;
5.字符显示模块实现的关键源程序:
process(f1r,f1c)
begin
casef1cis
when"000"=>c1<="11111110";
when"001"=>c1<="11111101";
when"010"=>c1<="11111011";
when"011"=>c1<="11110111";
when"100"=>c1<="11101111";
when"101"=>c1<="11011111";
when"110"=>c1<="10111111";
when"111"=>c1<="01111111";
whenothers=>c1<="11111111";
endcase;
casef1ris
when"00"=>
casef1cis
……
endcase;
when"01"=>
casef1cis
……
endcase;
when"10"=>
casef1cis
……
endcase;
whenothers=>
casef1cis
……
endcase;
endcase;
endprocess;
6.动画显示模块实现的关键源程序:
process(f2r,f2c)
begin
casef2cis
when"000"=>c2<="11111110";
when"001"=>c2<="11111101";
when"010"=>c2<="11111011";
when"011"=>c2<="11110111";
when"100"=>c2<="11101111";
when"101"=>c2<="11011111";
when"110"=>c2<="10111111";
when"111"=>c2<="01111111";
whenothers=>c2<="11111111";
endcase;
casef2ris
when"0000"=>
casef2cis
……
endcase;
when"0001"=>
casef2cis
……
endcase;
when"0010"=>
casef2cis
……
endcase;
when"0011"=>
casef2cis
……
endcase;
when"0100"=>
casef2cis
……
endcase;
when"0101"=>
casef2cis
……
endcase;
when"0110"=>
casef2cis
……
endcase;
when"0111"=>
casef2cis
……
endcase;
when"1000"=>
casef2cis
……
endcase;
when"1001"=>
casef2cis
……
endcase;
when"1010"=>
casef2cis
……
endcase;
when"1011"=>
casef2cis
……
endcase;
when"1100"=>
casef2cis
……
endcase;
when"1101"=>
casef2cis
……
endcase;
when"1110"=>
casef2cis
……
endcase;
whenothers=>
casef2cis
……
endcase;
endcase;
endprocess;
七.所实现功能说明:
本实验主要完成以下几大功能:
1.点阵的扫描显示:
1)功能实现描述:
y(8),t(8)分别控制点阵的行的8个输入端和列的8个输入端。
当行为高电位,列为低电位时。
二极管发光,否则不发光。
由中间变量f0c,f0r充当判决依据,以此控制行列的输出信号。
2)仿真波形:
2.字符的单个显示:
功能实现描述:
采用列扫描的方法来实现点字符的显示。
用计数信号m的20,21位充当判决条件,控制行信号y和列信号t的输出,实现行和列的连续循环。
用计数信号m的10,11,12位充当判决条件,控制不同字符显示的循环。
3.字符的循环显示:
循环显示跟字符显示的原理差不多的。
只是其中每一个字符的完整显示需要4帧的时间。
用计数信号m的18,19,20,21位充当判决条件,控制不同字符显示的循环。
器件的资源占用情况:
八.故障及问题分析:
实验中出现了不少问题,但其中有三个比较主要的问题,如下:
1.逐点扫描时,不该亮的点会亮而显示字符时字符有明显的跳跃感
解决方法:
提高扫描频率,利用人眼反应的迟滞性正常显示点和字符
2.在显示字符时,行与列难以实现同步
解决方法:
选择同一个判决变量控制行列的输出,即可实现行与列同步。
3.实验连线比较复杂,并有不断重复工作,很繁琐
解决方法:
利用MaxPlus中的手动分配管脚的功能,自己根据实验需要设置输出管脚,减少重复的连线工作.
九.实验心得:
本次实验是自学习数字电路程序设计以来综合性最强的一次实验,使我对数电程序设计有了进一步的了解和掌握。
通过这次实验,我对VHDL语言有了更深一步的了解,并学会了如何手动分配管脚,对点阵的具体用法也有了更深一步的认识。
最终基本上实现了点阵扫描,单个字符的显示,字符的循环的显示等功能。
总体来讲,这次实验锻炼了我的意志品质,培养了我独立思考解决问题的能力,使我受益匪浅。
十.完整源程序:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitydianzhenis
port(clk:
instd_logic;--1M的系统时钟
key:
instd_logic;--开关,控制点阵图案切换
y:
bufferstd_logic_vector(0to7);-行输出变量
t:
bufferstd_logic_vector(0to7));-列输出变量
enddianzhen;
architecturepartofdianzhenis
signalx:
integerrange0to2;
signalrow,column,r1,c1,r2,c2:
std_logic_vector(0to7);
signalm:
std_logic_vector(23downto0):
="000000000000000000000000";--总分频
signalf1c,f0r,f0c,f2c,k:
std_logic_vector(2downto0);--控制输出信号及中间变量
signalf1r:
std_logic_vector(1downto0);-字符显示的行控制变量
signalf2r:
std_logic_vector(3downto0);-字符循环显示的行控制变量
signalfangdou,g:
std_logic;
begin
process(clk)--分频部分
begin
if(clk'eventandclk='1')then
m<=m+1;
fangdou<=m(15);
f0r<=m(23downto21);
f0c<=m(20downto18);
f1c<=m(12downto10);
f1r<=m(21downto20);
f2c<=m(12downto10);
f2r<=m(21downto18);
endif;
endprocess;
process(fangdou)--防抖部分
begin
iffangdou'eventandfangdou='1'then
k
(2)<=k
(1);
k
(1)<=k(0);
k(0)<=key;
endif;
g<=k
(2)andk
(1)andk(0);
endprocess;
process(g)
begin
if(g'eventandg='1')then
ifx=2then
x<=0;
else
x<=x+1;
endif;
endif;
endprocess;
process(f0c)
begin--点阵逐点扫描
casef0cis
when"000"=>column<="11111110";
when"001"=>column<="11111101";
when"010"=>column<="11111011";
when"011"=>column<="11110111";
when"100"=>column<="11101111";
when"101"=>column<="11011111";
when"110"=>column<="10111111";
when"111"=>column<="01111111";
whenothers=>column<="00000000";
endcase;
endprocess;
process(f0r)
begin
casef0ris
when"000"=>row<="00000001";
when"001"=>row<="00000010";
when"010"=>row<="00000100";
when"011"=>row<="00001000";
when"100"=>row<="00010000";
when"101"=>row<="00100000";
when"110"=>row<="01000000";
when"111"=>row<="10000000";
whenothers=>row<="11111111";
endcase;
endprocess;
process(f1r,f1c)--显示文字图案
begin
casef1cis
when"000"=>c1<="11111110";
when"001"=>c1<="11111101";
when"010"=>c1<="11111011";
when"011"=>c1<="11110111";
when"100"=>c1<="11101111";
when"101"=>c1<="11011111";
when"110"=>c1<="10111111";
when"111"=>c1<="01111111";
whenothers=>c1<="11111111";
endcase;
casef1ris
when"00"=>
casef1cis-显示C
when"000"=>r1<="00000000";
when"001"=>r1<="00111100";
when"010"=>r1<="01000010";
when"011"=>r1<="10000001";
when"100"=>r1<="10000001";
when"101"=>r1<="10000001";
when"110"=>r1<="01000010";
when"111"=>r1<="00000000";
whenothers=>r1<="00000000";
endcase;
when"01"=>
casef1cis-显示E
when"000"=>r1<="11111111";
when"001"=>r1<="10010001";
when"010"=>r1<="10010001";
when"011"=>r1<="10010001";
when"100"=>r1<="10010001";
when"101"=>r1<="10010001";
when"110"=>r1<="10010001";
when"111"=>r1<="10010001";
whenothers=>r1<="00000000";
endcase;
when"10"=>
casef1cis-显示T
when"000"=>r1<="00000001";
when"001"=>r1<="00000001";
when"010"=>r1<="00000001";
when"011"=>r1<="00000001";
when"100"=>r1<="11111111";
when"101"=>r1<="00000001";
when"110"=>r1<="00000001";
when"111"=>r1<="00000001";
whenothers=>r1<="00000000";
endcase;
whenothers=>
casef1cis-显示6
when"000"=>r1<="00000000";
when"001"=>r1<="11111111";
when"010"=>r1<="10001001";
when"011"=>r1<="10001001";
when"100"=>r1<="10001001";
when"101"=>r1<="10001001";
when"110"=>r1<="11111001";
when"111"=>r1<="00000000";
whenothers=>r1<="00000000";
endcase;
endcase;
endprocess;
process(f2r,f2c)--显示动画
begin
casef2cis
when"000"=>c2<="11111110";
when"001"=>c2<="11111101";
when"010"=>c2<="11111011";
when"011"=>c2<="11110111";
when"100"=>c2<="11101111";
when"101"=>c2<="11011111";
when"110"=>c2<="10111111";
when"111"=>c2<="01111111";
whenothers=>c2<="11111111";
endcase;
casef2ris
when"0000"=>
casef2cis-显示C
when"000"=>r2<="00000000";
when"001"=>r2<="00111100";
when"010"=>r2<="01000010";
when"011"=>r2<="10000001";
when"100"=>r2<="10000001";
when"101"=>r2<="10000001";
when"110"=>r2<="01000010";
when"111"=>r2<="00000000";
whenothers=>r2<="00000000";
endcase;
when"0001"=>
casef2cis
when"000"=>r2<="00000000";
when"001"=>r2<="00111100";
when"010"=>r2<="10000001";
when"011"=>r2<="10000001";
when"100"=>r2<="10000001";
when"101"=>r2<="10000001";
when"110"=>r2<="10000001";
when"111"=>r2<="00000000";
whenothers=>r2<="00000000";
endcase;
when"0010"=>
casef2cis
when"000"=>r2<="00111100";
when"001"=>r2<="00000000";
when"010"=>r2<="10000001";
when"011"=>r2<="10000001";
when"100"=>r2<="10000001";
when"101"=>r2<="1000000