数字逻辑电路设计.docx
- 文档编号:12885892
- 上传时间:2023-06-08
- 格式:DOCX
- 页数:13
- 大小:65.27KB
数字逻辑电路设计.docx
《数字逻辑电路设计.docx》由会员分享,可在线阅读,更多相关《数字逻辑电路设计.docx(13页珍藏版)》请在冰点文库上搜索。
数字逻辑电路设计
数字逻辑电路设计
——多功能数字钟
学院:
计算机科学与通信工程学院
专业:
软件工程
班级:
1202
学号:
3120608045
姓名:
多功能数字钟课程设计实验报告
1.设计任务及要求
(1)拥有正常的时、分、秒计时功能。
(2)能利用实验板上的按键实现校时、校分及清零功能。
(3)能利用实验板上的扬声器做整点报时。
(4)闹钟功能。
(5)在MAXPLUSII中采用层次化设计方法进行设计。
(6)完成全部电路设计后在实验板上下载,验证设计课题的正确性。
2.设计方案
根据总体设计框图,可以将整个系统分为六个模块来实现,分别是计时模块、校时模块、整点报时模块、动态显示模块及闹钟模块。
(1)计时模块
该模块的设计简单,使用一个二十四进制和两个六十进制计数级联,构成数字钟的基本框架。
(2)校时模块
校时模块设计要求实现校时、校分以及清零的功能。
按下校时键,小时计数器迅速递增以调至所需要的小时位。
按下校分键,分计数器迅速递增以调至所需要的分位。
按下清零键,将秒计数器清零。
(3)整点报时模块
该模块的功能要求是:
计时到59分50秒时,每两秒一次低音报时,整点时进行高音报时,可以将报时信号接到实验板上的扬声器输出。
(4)分频模块
在本系统中需要用到多种不同频率的脉冲信号,上至高音报时信号,下至1HZ的几秒脉冲。
(5)动态显示模块
时间的显示需要用到6个数码管,如果实验板上可用的静态显示数码管有6个或以上则很容易实现,只需要将小时高位到秒低位共6组输出按顺序锁定到6个数码管上即可。
(6)闹钟模块
闹钟模块要求数字钟计时到所设定的任意时间时均能驱动扬声器报时。
该模块的设计应考虑到一下几个问题。
设定的闹钟的时间应使用新的计数器进行存储,与正常的计时互不干扰。
与正常计时状态的显示切换。
可以设定一个按键,用于选择是将计时时间还是将闹钟时间状态送动态显示模块。
应实现一个比较模块,当计时到与闹钟时间相等时,则驱动扬声器鸣叫。
闹钟响声应限定在一定时间内,比如一分钟,且在这段时间内应随时可以通过按键取消闹时状态。
将上述6个功能模块分别加以实现再连接成为顶层原理图,编译后锁定管脚下载验证结果的正确性。
3.顶层图及相关模块说明
(1)顶层图
(2)各模块源代码
计时模块
24进制
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycnt24is
port(clk:
instd_logic;
ql,qh:
outstd_logic_vector(3downto0);
tc:
outstd_logic);
endcnt24;
architectureoneofcnt24is
begin
process(clk)
variableiql,iqh:
std_logic_vector(3downto0);
begin
ifclk'eventandclk='1'theniql:
=iql+1;
ifiql="1010"theniqh:
=iqh+1;iql:
="0000";
endif;
if(iqh="0010")and(iql="0100")thentc<='0';iqh:
="0000";iql:
="0000";
endif;
endif;
ql<=iql;qh<=iqh;
endprocess;
endone;
60进制
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycnt60is
port(clk,clr:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0);
tc:
outstd_logic
);
endcnt60;
architecturebehavorofcnt60is
begin
tc<='0'when(clk='1'andql="0000"andqh="0110")else'1';
process(clk,clr,ql,qh)
variableiql,iqh:
std_logic_vector(3downto0);
begin
if(clr='0'or(iql="0000"andiqh="0110"))then
iql:
="0000";
iqh:
="0000";
elseif(clk'eventandclk='1')then
iql:
=iql+1;
if(iql="1010")then
iql:
="0000";
iqh:
=qh+1;
endif;
endif;
endif;
ql<=iql;qh<=iqh;
endprocess;
ENDbehavor;
校时模块
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entitysel2is
port(sel:
instd_logic;
ip:
instd_logic;
a,b:
outstd_logic);
endsel2;
architecturebehofsel2is
begin
process(sel)
begin
if(sel='0')thena<=ip;
elseb<=ip;
endif;
endprocess;
endbeh;
整点报时模块
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityzdbsis
port(mh,ml,sh,sl:
instd_logic_vector(3downto0);
sig500,sig1k:
outstd_logic
);
endzdbs;
architecturebehaviorofzdbsis
begin
sig500<='1'whenmh="0101"andml="1001"andsh="0101"
and(sl="0000"orsl="0010"orsl="0100"orsl="0110"orsl="1000")
else'0';
sig1k<='1'whenmh="0000"andml="0000"andsh="0000"andsl="0000"
else'0';
endbehavior;
分频模块
LIBRARYIEEE;
USEIEEE.STD_LOGIC_1164.ALL;
USEIEEE.STD_LOGIC_ARITH.ALL;
USEIEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITYfreq_dividerIS
PORT(clk:
INSTD_LOGIC;
hz1:
OUTSTD_LOGIC;
hz4:
OUTSTD_LOGIC;
hz64:
OUTSTD_LOGIC;
hz512:
OUTSTD_LOGIC);
ENDfreq_divider;
ARCHITECTURErtlOFfreq_dividerIS
SIGNALcount:
STD_LOGIC_VECTOR(9DOWNTO0);
BEGIN
PROCESS(clk)
BEGIN
IF(clk'eventandclk='1')THEN
IF(count="1111111111")THEN
Count<=(OTHERS=>'0');
ELSE
Count<=count+1;
ENDIF;
ENDIF;
ENDPROCESS;
hz512<=count(0);
hz64<=count(3);
hz4<=count(7);
hz1<=count(9);
ENDrtl;
动态显示模块
LIBRARYIEEE;
USEIEEE.STD_LOGIC_1164.ALL;
USEIEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITYdtsmis
port(
clk:
instd_logic;
h:
instd_logic_vector(7downto0);
m:
instd_logic_vector(7downto0);
s:
instd_logic_vector(7downto0);
seg7out:
outstd_logic_vector(6downto0);
sel:
bufferstd_logic_vector(2downto0)
);
ENDdtsm;
ARCHITECTUREbehaofdtsmis
signalkey:
std_logic_vector(3downto0);
BEGIN
PROCESS(clk)
variabledount:
std_logic_vector(2downto0):
="000";
BEGIN
IF(rising_edge(clk))then
IFdount="111"then
dount:
="000";
ELSE
dount:
=dount+1;
ENDIF;
ENDIF;
sel<=dount;
endprocess;
PROCESS(sel)
BEGIN
CASEselIS
when"000"=>key<=h(7downto4);
when"001"=>key<=h(3downto0);
when"010"=>key<="1010";
when"011"=>key<=m(7downto4);
when"100"=>key<=m(3downto0);
when"101"=>key<="1010";
when"110"=>key<=s(7downto4);
when"111"=>key<=s(3downto0);
whenothers=>null;
ENDCASE;
ENDPROCESS;
PROCESS(key)
BEGIN
casekeyis
when"0000"=>seg7out<="0111111";
when"0001"=>seg7out<="0000110";
when"0010"=>seg7out<="1011011";
when"0011"=>seg7out<="1001111";
when"0100"=>seg7out<="1100110";
when"0101"=>seg7out<="1101101";
when"0110"=>seg7out<="1111101";
when"0111"=>seg7out<="0000111";
when"1000"=>seg7out<="1111111";
when"1001"=>seg7out<="1101111";
when"1010"=>seg7out<="1000000";
whenothers=>null;
ENDCASE;
ENDPROCESS;
ENDbeha;
闹钟模块
闹钟设置
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityalarmsetis
port(sel:
instd_logic;
hclo,mclo,sclo,halr,malr,salr:
instd_logic_vector(7downto0);
h,s,m:
outstd_logic_vector(7downto0));
endalarmset;
architecturebehofalarmsetis
begin
process(sel)
begin
if(sel='0')thenh<=hclo;
m<=mclo;
s<=sclo;
elseh<=halr;
m<=malr;
s<="00000000";
endif;
endprocess;
endbeh;
闹钟比较
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entityalarmcmpis
port(h,m,halr,malr:
instd_logic_vector(7downto0);
stop:
instd_logic;
sig:
outstd_logic);
endalarmcmp;
architecturebehofalarmcmpis
begin
process(h,m,halr,malr,stop)
begin
ifstop='1'then
sig<='0';
endif;
ifh=halrandm=malrandstop='0'then
sig<='1';
elsesig<='0';
endif;
endprocess
endbeh;
4.课程设计总结
通过这一次课程设计,我对VHDL语言有了进一步的了解。
在课程设计的一开始就遇到了许多的麻烦:
对VHDL语言不熟悉,没有对课程设计做出整体规划,对电路图的画法不熟悉,不知道该做些什么,以至于耽误了课程设计的进度。
随着设计的进行,在各方面都学到了很多,对软件的使用也熟悉了,在同学的帮助下也理清了思路,在后续的工作中进行的比较顺利。
这一次课程设计让我懂得了在学习过程中要理论与实践相结合,因此我觉得这次课程设计是相当有必要的,也是相当有实际意义的。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字 逻辑电路 设计