最新EDA技术课程设计多功能数字钟.docx
《最新EDA技术课程设计多功能数字钟.docx》由会员分享,可在线阅读,更多相关《最新EDA技术课程设计多功能数字钟.docx(18页珍藏版)》请在冰点文库上搜索。
最新EDA技术课程设计多功能数字钟
EDA技术课程设计
——多功能数字钟
专业:
通信c132
****************
史晓威138241
*******
时间:
2015.12.26
1、设计目的·····················································3
2、设计系统环境·················································3
3、设计性能指标及功能···········································3
3.1设计功能···················································3
3.2性能指标···················································3
4、设计总体框图·················································3
5、底层文件设计··················································4
5.1秒计数器····················································4
5.2分钟计数器··················································4
5.3小时计数器··················································5
5.4整点报时驱动信号产生模块····································5
5.5驱动8位八段共阴扫描数码管的片选驱动信号输出模块··································································6
5.6驱动八段字形译码输出模块·····································6
6、顶层文件设计················································6
7、心得体会······················································7
附录(源程序)·····················································8
1、设计目的
掌握各类计数器和分频器以及它们相连的设计方法;掌握多个数码管的原理与方法;掌握CPLD技术的层次化设计的方法;掌握使用VHDL语言的设计思想;对整个系统的设计有一个了解。
2、设计系统环境
(1)一台PC机;
(2)一套GW48型EDA实验开发系统硬件;
(3)X+PLUSⅡ集成化的开发系统硬件。
3、设计性能指标及功能
3.1设计功能
1)具有时、分、秒计数显示功能,以24小时循环计时。
2)时钟计数显示时有LED灯的花样显示。
3)具有调节小时、分钟、秒及清零的功能。
4)具有整点报时功能。
3.2性能指标
1)时钟计数:
完成时、分、秒的正确计时并且显示所计的数字;对秒、分
——60进制计数,即从0到59循环计数,时钟——24进制计数,即从0到23循环计数,并且在数码管上显示数值。
2)时间设置:
手动调节分钟、小时,可以对所设计的时钟任意调时间,这样使数字钟真正具有使用功能。
我们可以通过实验板上的键7和键4进行任意的调整,因为我们用的时钟信号均是1HZ的,所以每LED灯变化一次就来一个脉冲,即计数一次。
3)清零功能:
reset为复位键,低电平时实现清零功能,高电平时正常计数。
可以根据我们自己任意时间的复位。
4)蜂鸣器在整点时有报时信号产生,蜂鸣器报警。
产生“滴答.滴答”的报警声音。
5)LED灯在时钟显示时有花样显示信号产生。
即根据进位情况,LED不停的闪烁,从而产生“花样”信号。
4、设计总体框图
根据总体方框图及各部分分配的功能可知,本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。
采用自顶向下的设计方法,子模块利用VHDL语言设计,顶层文件用原理图的设计方法。
显示:
小时采用24进制,而分钟均是采用6进制和10进制的组合。
5、模块及模块功能
多功能数字钟中的时钟记数模块、驱动8位八段共阴扫描数码管的片选驱动信号输出模块、驱动八段字形译码输出模块、整点报时驱动信号产生模块。
5.1秒计数器
5.1.1VHDL语言描述程序见附录
模块CNT60_2该模块为60进制计数器,计时输出为秒的数值,在计时到59时送出进位信号CO,因为硬件有延时,所以模块CNT60_2在此模块变为00时加1,符合实际。
5.1.2秒计数器的仿真波形图
5.2分钟计数器
5.2.1VHDL语言描述程序见附录
模块CNT60_1该模块为60进制计数器,计时输出为分的数值,在EN信号有效且时钟到来时,计数器加1。
在sb按下时,EN信号有效,计数值以秒的速度增加,从而实现对分钟的设置。
5.2.2分钟计数器的仿真波形图
5.3小时计数器
5.3.1VHDL语言描述程序见附录
模块CNT24该模块为24进制计数器,计时输出为小时的数值,在EN信号有效且时钟到来时,计数器加1。
在sa按下时,EN信号有效,计数值以秒的速度增加,从而实现对时钟的设置。
5.3.2小时计数器的仿真波形图
5.4整点报时驱动信号产生模块
5.4.1VHDL语言描述程序见附录
该模块功能:
在时钟信号(CLK)的作用下可以生成波形,SPEAK输出接扬声器,
以产生整点报时发声。
5.4.2整点报时驱动信号产生的仿真波形图
5.5驱动8位八段共阴扫描数码管的片选驱动信号输出模块
5.5.1VHDL语言描述程序见附录
5.5.2驱动8位八段共阴扫描数码管的片选驱动信号输出的仿真波形图
5.6驱动八段字形译码输出模块
5.6.1VHDL语言描述程序见附录
该模块功能:
信号输入后,模块驱动八段字形译码输出,A,B,C,D,E,F,G分别接八段共阴级数码管7个接口,即有字形输出。
5.6.2驱动八段字形译码输出的仿真波形图
6、顶层文件设计
6.1总原理图
6.2总电路时序仿真
仿真是EDA技术的重要组成部分,也是对设计的电路进行功能和性能测试的有效手段。
EDA工具提供了强大且与电路实时行为相吻合的精确硬件系统测试工具。
在建立了波形文件、输入信号节点、波形参数、加输入信号激励电平并存盘之后,选择主菜单“MAX+plusII”中的仿真器项“Simulator”,弹出对话框之后单击“Start”进行仿真运算,完成之后就可以看到时序波形。
图为总电路的时序图。
7、心得体会
1、在此次的数字钟设计过程中,更进一步地熟悉了芯片的结构及掌握了各芯的
工作原理及具体使用方法。
2、设计的模块要分块调试,免得所有部分都做完了再调试不知道哪出错了,毫无头绪。
3、在连接二十四进制,六十进制的进位的接法中,要求熟悉逻辑电路及其芯片各引脚的功能,那么在电路出错时便能准确地找出错误所在并及时纠正了.。
附录(源程序)
1.秒计数器VHDL语言描述程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitysecondis
port(reset,clk,setmin:
instd_logic;
daout:
outstd_logic_vector(7downto0);
enmin:
outstd_logic);
endsecond;
architecturebehavofsecondis
signalcount:
std_logic_vector(3downto0);
signalcounter:
std_logic_vector(3downto0);
signalcarry_out1:
std_logic;
signalcarry_out2:
std_logic;
begin
p1:
process(reset,clk)
begin
ifreset='0'then
count<="0000";
counter<="0000";
elsif(clk'eventandclk='1')then
if(counter<5)then
if(count=9)then
count<="0000";
counter<=counter+1;
else
count<=count+1;
endif;
carry_out1<='0';
else
if(count=9)then
count<="0000";
counter<="0000";
carry_out1<='1';
else
count<=count+1;
carry_out1<='0';
endif;
endif;
endif;
endprocess;
daout(7downto4)<=counter;
daout(3downto0)<=count;
enmin<=carry_out1orsetmin;
endbehav;
2.分钟计数器VHDL语言描述程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityminuteis
port(reset,clk,sethour:
instd_logic;
daout:
outstd_logic_vector(7downto0);
enhour:
outstd_logic);
endminute;
architecturebehavofminuteis
signalcount:
std_logic_vector(3downto0);
signalcounter:
std_logic_vector(3downto0);
signalcarry_out1:
std_logic;
signalcarry_out2:
std_logic;
begin
p1:
process(reset,clk)
begin
ifreset='0'then
count<="0000";
counter<="0000";
elsif(clk'eventandclk='1')then
if(counter<5)then
if(count=9)then
count<="0000";
counter<=counter+1;
else
count<=count+1;
endif;
carry_out1<='0';
else
if(count=9)then
count<="0000";
counter<="0000";
carry_out1<='1';
else
count<=count+1;
carry_out1<='0';
endif;
endif;
endif;
endprocess;
p2:
process(clk)
begin
if(clk'eventandclk='0')then
if(counter=0)then
if(count=0)then
carry_out2<='0';
endif;
else
carry_out2<='1';
endif;
endif;
endprocess;
daout(7downto4)<=counter;
daout(3downto0)<=count;
enhour<=(carry_out1andcarry_out2)orsethour;
endbehav;
3.小时计数器VHDL语言描述程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityhouris
port(reset,clk:
instd_logic;
daout:
outstd_logic_vector(7downto0));
endhour;
architecturebehavofhouris
signalcount:
std_logic_vector(3downto0);
signalcounter:
std_logic_vector(3downto0);
begin
p1:
process(reset,clk)
begin
ifreset='0'then
count<="0000";
counter<="0000";
elsif(clk'eventandclk='1')then
if(counter<2)then
if(count=9)then
count<="0000";
counter<=counter+1;
else
count<=count+1;
endif;
else
if(count=3)then
count<="0000";
counter<="0000";
else
count<=count+1;
endif;
endif;
endif;
endprocess;
daout(7downto4)<=counter;
daout(3downto0)<=count;
endbehav;
4.整点报时驱动信号产生模块VHDL语言描述程序
LibraryIEEE;
useIEEE.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityalertis
Port(
clkspk:
instd_logic;
second:
instd_logic_vector(7downto0);
minute:
instd_logic_vector(7downto0);
speak:
outstd_logic;
lamp:
outstd_logic_vector(8downto0));
endalert;
architecturebehavofalertis
signaldivclkspk2:
std_logic;
begin
p1:
process(clkspk)
begin
if(clkspk'eventandclkspk='1')then
divclkspk2<=notdivclkspk2;
endif;
endprocess;
p2:
process(second,minute)
begin
if(minute="01011001")then
casesecondis
when"01010001"=>lamp<="000000001";speak<=divclkspk2;
when"01010010"=>lamp<="000000010";speak<='0';
when"01010011"=>lamp<="000000100";speak<=divclkspk2;
when"01010100"=>lamp<="000001000";speak<='0';
when"01010101"=>lamp<="000010000";speak<=divclkspk2;
when"01010110"=>lamp<="000100000";speak<='0';
when"01010111"=>lamp<="001000000";speak<=divclkspk2;
when"01011000"=>lamp<="010000000";speak<='0';
when"01011001"=>lamp<="100000000";speak<=clkspk;
whenothers=>lamp<="000000000";
endcase;
endif;
endprocess;
endbehav;
5.驱动8位八段共阴扫描数码管的片选驱动信号输出VHDL语言描述程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityseltimeis
port(
ckdsp:
instd_logic;
reset:
instd_logic;
second:
instd_logic_vector(7downto0);
minute:
instd_logic_vector(7downto0);
hour:
instd_logic_vector(7downto0);
daout:
outstd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0));
endseltime;
architecturebehavofseltimeis
signalsec:
std_logic_vector(2downto0);
begin
process(reset,ckdsp)
begin
if(reset='0')then
sec<="000";
elsif(ckdsp'eventandckdsp='1')then
if(sec="101")then
sec<="000";
else
sec<=sec+1;
endif;
endif;
endprocess;
process(sec,second,minute,hour)
begin
casesecis
when"000"=>daout<=second(3downto0);
when"001"=>daout<=second(7downto4);
when"010"=>daout<=minute(3downto0);
when"011"=>daout<=minute(7downto4);
when"100"=>daout<=hour(3downto0);
when"101"=>daout<=hour(7downto4);
whenothers=>daout<="XXXX";
endcase;
endprocess;
sel<=sec;
endbehav;
6.驱动八段字形译码输出VHDL语言描述程序
LIBRARYIEEE;
USEIEEE.STD_LOGIC_1164.ALL;
ENTITYDELEDIS
PORT(
S:
INSTD_LOGIC_VECTOR(3DOWNTO0);
A,B,C,D,E,F,G,H:
OUTSTD_LOGIC);
ENDDELED;
ARCHITECTUREBEHAVOFDELEDIS
SIGNALDATA:
STD_LOGIC_VECTOR(3DOWNTO0);
SIGNALDOUT:
STD_LOGIC_VECTOR(7DOWNTO0);
BEGIN
DATA<=S;
PROCESS(DATA)
BEGIN
CASEDATAIS
WHEN"0000"=>DOUT<="00111111";
WHEN"0001"=>DOUT<="00000110";
WHEN"0010"=>DOUT<="01011011";
WHEN"0011"=>DOUT<="01001111";
WHEN"0100"=>DOUT<="01100110";
WHEN"0101"=>DOUT<="01101101";
WHEN"0110"=>DOUT<="01111101";
WHEN"0111"=>DOUT<="00000111";
WHEN"1000"=>DOUT<="01111111";
WHEN"1001"=>DOUT<="01101111";
WHEN"1010"=>DOUT<="01110111";
*求圆面积的独立自定义函数area.prgWHEN"1011"=>DOUT<="01111100";
WHEN"1100"=>DOUT<="00111001";
ifn=0WHEN"1101"=>DOUT<="01011110";
SELECT学号,姓名,总成绩FROMstud1WHERE学号IN(SELECT学号FROMstud2WHERE选课=”操作系统”)WHEN"1110"=>DOUT<="01111001";
WHEN"1111"=>DOUT<="01110001";
36.1系统漏洞2黑客攻击3病毒入侵4网络配置管理不当(6分)WHENOTHERS=>DOUT<="00000000";
ENDCASE;
docaseENDPROCESS;
30、DNSH<=DOUT(7);
G<=DOUT(6);
【答案】AF<=DOUT(5);
【答案】DBFE<=DOUT(4);
D<=DOUT(3);
C<=DOUT
(2);
52.将学号为“02080110”、课程号为“102”的选课记录的成绩改为92,正确的SQL语句是________。
B<=DOUT
(1);
A<=DOUT(0);
ENDBEHAV;
【答案】A