利用按键开关控制点阵进行八进制数字显示.docx
《利用按键开关控制点阵进行八进制数字显示.docx》由会员分享,可在线阅读,更多相关《利用按键开关控制点阵进行八进制数字显示.docx(15页珍藏版)》请在冰豆网上搜索。
利用按键开关控制点阵进行八进制数字显示
1、课程设计目的
1.学习操作数字电路设计实验开发系统,掌握点阵显示模块的工作原理及应用。
2.掌握组合逻辑电路、时序逻辑电路的设计方法。
3.学习掌握可编程器件设计的全过程。
2、课程设计内容和要求
2.1、设计内容
利用按键开关控制点阵进行八进制数字显示。
2.2、设计要求
1.学习掌握按键开关控制模块、点阵显示模块的工作原理及应用;
2.熟练掌握VHDL编程语言,编写按键开关控制模块的控制逻辑;
3.仿真所编写的程序,模拟验证所编写的模块功能;
4.下载程序到芯片中,硬件验证所设置的功能,能够实现八进制数字的显示;
5.整理设计内容,编写设计说明书。
3、设计方案及实现情况
3.1、设计思路
根据题目设计要求,采用自顶向下设计方法,顶层采用原理图设计方法,模块分为分频(FENPIN)、计数(JISHU)、功能控制(CNTA)、16×16点阵显示(XIANSHI)四个模块,通过对各模块编写程序实现模块功能,生成器件,再将将四个模块综合,实现利用按键开关控制点阵进行八进制数字显示。
3.2、工作原理及框图
工作原理:
系统的输入信号有复位信号RST,系统时钟信号CLOCK,按键信号ANJIAN。
系统的输出信号有点阵行驱动输出信号Y[15..0],点阵列选信号Q[3..0]。
系统利用分频模块对CLOCK进行分频,然后消斗进行手动计数,控制八进制,计数输出结果CN[2..0]控制XIANSHI模块输出相应的图形。
CNTA模块产生类扫描信号,控制XIANSHI模块进行逐列扫描,在点阵上就可以出现八进制数的输出。
图1系统整体工作原理图
3.3、各模块功能描述
1.分频模块(FENPIN):
对时钟进行1000分频。
图2分频模块图及管脚
libraryieee;
Useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityfenpinis
port(clk:
instd_logic;
clkout:
outstd_logic);
endfenpin;
architecturer1offenpinis
signalcnt:
integerrange0to15;
begin
process(clk)
begin
ifclk'eventandclk='1'then
ifcnt<8then
clkout<='0';
else
clkout<='1';
endif;
cnt<=cnt+1;
endif;
endprocess;
endr1;
2.消斗模块(XIAODOU):
对按键信号进行消斗,使案件输出稳定,最终使点阵显示稳定。
图3消抖模块图及管脚
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityxiaodouis
port(
clk:
instd_logic;
rst:
instd_logic;
d_click:
outstd_logic;
click:
instd_logic
);
endxiaodou;
architecturer1ofxiaodouis
signalcount:
integerrange0to10000;--std_logic_vector(9downto0);
signalcount1:
std_logic_vector(7downto0);
signaldout1:
std_logic;
begin
process(clk,rst)
begin
ifrst='1'then
dout1<='1';
count1<="00000000";
elsifclk'eventandclk='1'then
if(click='0')and(count1(7)='0')and(dout1='1')then
dout1<='1';
count1<=count1+1;
elsif(click='0')and(count1(7)='1')and(dout1='1')then
dout1<='0';
count1<="00000000";
elsif(click='1')and(count1(7)='0')and(dout1='0')then
dout1<='0';
count1<=count1+1;
elsif(click='1')and(count1(7)='1')and(dout1='0')then
dout1<='1';
count1<="00000000";
else
d_click<=dout1;
count1<="00000000";
endif;
endif;
endprocess;
endr1;
3.计数模块(JISHU):
进行八进制计数,输出控制显示模块的CH[2..0]。
图4计数模块及管脚图
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityjishuis
port(clk:
instd_logic;
rst:
instd_logic;
count:
outstd_logic_vector(2downto0));
endjishu;
architecturer1ofjishuis
signalcn:
std_logic_vector(2downto0);
begin
count<=cn;
process(clk,rst)
begin
ifrst='1'then
cn<="000";
elsifclk'eventandclk='1'then
ifcn="111"then
cn<="000";
else
cn<=cn+1;
endif;
endif;
endprocess;
endr1;
4.功能控制模块(CNTA):
利用时钟进行十六进制计数,控制列信号从0000-1111变化。
图5功能控制模块及管脚图
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycntais
port(clk:
instd_logic;
q:
outstd_logic_vector(3downto0));
endcnta;
architecturer1ofcntais
begin
process(clk)
variabletmp:
std_logic_vector(3downto0);
begin
ifclk'eventandclk='1'then
iftmp="1111"then
tmp:
="0000";
else
tmp:
=tmp+1;
endif;
endif;
q<=tmp-1;
endprocess;
endr1;
5.16×16点阵显示(XIANSHI):
用CH[2..0]与SEL[3..0]控制显示从0-7八个数字。
图6显示模块及其管脚图
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityxianshiis
port(ch:
instd_logic_vector(2downto0);
sel:
instd_logic_vector(3downto0);
dout:
outstd_logic_vector(15downto0));
endxianshi;
architecturer1ofxianshiis
begin
process(ch,sel)
begin
casechis
when"000"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000011111100000";
when"0010"=>dout<="0000111111110000";
when"0011"=>dout<="0001111111111000";
when"0100"=>dout<="0011000000001100";
when"0101"=>dout<="0011000000001100";
when"0110"=>dout<="0011000000001100";
when"0111"=>dout<="0011000000001100";
when"1000"=>dout<="0011000000001100";
when"1001"=>dout<="0011000000001100";
when"1010"=>dout<="0011000000001100";
when"1011"=>dout<="0001111111111000";
when"1100"=>dout<="0000111111110000";
when"1101"=>dout<="0000011111100000";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"001"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000000000000000";
when"0010"=>dout<="0000000000000100";
when"0011"=>dout<="0000000000000100";
when"0100"=>dout<="0000000000000100";
when"0101"=>dout<="0000000000000100";
when"0110"=>dout<="0001111111111100";
when"0111"=>dout<="0001111111111100";
when"1000"=>dout<="0001111111111100";
when"1001"=>dout<="0000100000000100";
when"1010"=>dout<="0000100000000100";
when"1011"=>dout<="0000100000000100";
when"1100"=>dout<="0000000000000100";
when"1101"=>dout<="0000000000000000";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"010"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000000000010000";
when"0010"=>dout<="0000111000011100";
when"0011"=>dout<="0001111100001100";
when"0100"=>dout<="0001111110001100";
when"0101"=>dout<="0001000110001100";
when"0110"=>dout<="0001000011001100";
when"0111"=>dout<="0001000001001100";
when"1000"=>dout<="0001000001101100";
when"1001"=>dout<="0001000000101100";
when"1010"=>dout<="0001000000111100";
when"1011"=>dout<="0001111000011100";
when"1100"=>dout<="0000111000001100";
when"1101"=>dout<="0000010000001100";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"011"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000000000100000";
when"0010"=>dout<="0000010001111000";
when"0011"=>dout<="0000111001111000";
when"0100"=>dout<="0001111111011100";
when"0101"=>dout<="0001101110000100";
when"0110"=>dout<="0001000110000100";
when"0111"=>dout<="0001000110000100";
when"1000"=>dout<="0001000110000100";
when"1001"=>dout<="0001000110000100";
when"1010"=>dout<="0001000000000100";
when"1011"=>dout<="0001110000011100";
when"1100"=>dout<="0000110000011100";
when"1101"=>dout<="0000110000011000";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"100"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000000000100100";
when"0010"=>dout<="0000000000100100";
when"0011"=>dout<="0000000000100100";
when"0100"=>dout<="0001111111111100";
when"0101"=>dout<="0001111111111100";
when"0110"=>dout<="0001111111111100";
when"0111"=>dout<="0000110000100100";
when"1000"=>dout<="0000011000100100";
when"1001"=>dout<="0000001000100100";
when"1010"=>dout<="0000000100100000";
when"1011"=>dout<="0000000110100000";
when"1100"=>dout<="0000000011100000";
when"1101"=>dout<="0000000001100000";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"101"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000000001100000";
when"0010"=>dout<="0001000011110000";
when"0011"=>dout<="0001000111111000";
when"0100"=>dout<="0001001111011100";
when"0101"=>dout<="0001001100000100";
when"0110"=>dout<="0001001100000100";
when"0111"=>dout<="0001001100000100";
when"1000"=>dout<="0001001100000100";
when"1001"=>dout<="0001001100000100";
when"1010"=>dout<="0001001100000100";
when"1011"=>dout<="0001111110011100";
when"1100"=>dout<="0001111110111000";
when"1101"=>dout<="0000000000011000";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"110"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0000000001110000";
when"0010"=>dout<="0000100011111000";
when"0011"=>dout<="0001110111111000";
when"0100"=>dout<="0001100110001100";
when"0101"=>dout<="0001100100000100";
when"0110"=>dout<="0001000100000100";
when"0111"=>dout<="0001000100000100";
when"1000"=>dout<="0001000100000100";
when"1001"=>dout<="0001000100000100";
when"1010"=>dout<="0001100110001100";
when"1011"=>dout<="0000111111111000";
when"1100"=>dout<="0000011111111000";
when"1101"=>dout<="0000001111110000";
when"1110"=>dout<="0000000011000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
when"111"=>
caseselis
when"0000"=>dout<="0000000000000000";
when"0001"=>dout<="0001000000000000";
when"0010"=>dout<="0001100000000000";
when"0011"=>dout<="0001110000000000";
when"0100"=>dout<="0001011000000000";
when"0101"=>dout<="0001001100000000";
when"0110"=>dout<="0001000111000000";
when"0111"=>dout<="0001000011111100";
when"1000"=>dout<="0001000001111100";
when"1001"=>dout<="0001000000111100";
when"1010"=>dout<="0001100000000000";
when"1011"=>dout<="0001100000000000";
when"1100"=>dout<="0001110000000000";
when"1101"=>dout<="0000110000000000";
when"1110"=>dout<="0000000000000000";
when"1111"=>dout<="0000000000000000";
whenothers=>null;
endcase;
whenothe