数字时钟的VHDL设计.docx
- 文档编号:24082685
- 上传时间:2023-05-24
- 格式:DOCX
- 页数:12
- 大小:15.55KB
数字时钟的VHDL设计.docx
《数字时钟的VHDL设计.docx》由会员分享,可在线阅读,更多相关《数字时钟的VHDL设计.docx(12页珍藏版)》请在冰豆网上搜索。
数字时钟的VHDL设计
vhdl数字钟程序数字时钟的VHDL设计
一、设计目的
1.掌握各类计数器及将它们相连的方法;
2.掌握多个数码管动态显示的原理与方法;
3.掌握用FPGA技术的层次化设计方法;
4.进一步掌握用VHDL硬件描述语言的设计思想;
5.了解有关数字系统的设计。
二、设计要求
基本要求:
1、24小时计数显示;
2、具有校时功能(时,分);
附加要求:
1、实现闹钟功能(定时,闹响);
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityszzis
port(clk:
instd_logic;
clk1:
instd_logic;
md1:
instd_logic;
md2:
instd_logic_vector(1downto0);
speak:
outstd_logic;
dout:
outstd_logic_vector(6downto0);
selout:
outstd_logic_vector(2downto0));
endszz;
architectureoneofszzis
signalsel:
std_logic_vector(2downto0);
signalhou1:
std_logic_vector(3downto0);
signalhou2:
std_logic_vector(3downto0);
signalmin1:
std_logic_vector(3downto0);
signalmin2:
std_logic_vector(3downto0);
signalseth1:
std_logic_vector(3downto0);
signalseth2:
std_logic_vector(3downto0);
signalsetm1:
std_logic_vector(3downto0);
signalsetm2:
std_logic_vector(3downto0);
signalsec1:
std_logic_vector(3downto0);
signalsec2:
std_logic_vector(3downto0);
signalh1:
std_logic_vector(3downto0);
signalh2:
std_logic_vector(3downto0);
signalm1:
std_logic_vector(3downto0);
signalm2:
std_logic_vector(3downto0);
signals1:
std_logic_vector(3downto0);
signals2:
std_logic_vector(3downto0);
-------------------------------------------------
begin
----------------------------------------------模6计数
choice:
process(clk1)
begin
ifclk1'eventandclk1='1'then
ifsel="101"then
sel<="000";
else
sel<=sel+1;
endif;
endif;
endprocesschoice;
-----------------------------------------------小时十位
h110:
process(clk,hou2,min1,min2,sec1,sec2,md1,md2)
begin
ifclk'eventandclk='1'then
if(hou1="0010"andhou2="0011")and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001") then
hou1<="0000";
elsifhou1="0010"andhou2="0011"andmd1='0'andmd2="01"then--当时间为23点且处于校时状态时
hou1<="0000";
elsif(hou2="1001"and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001"))or(hou2="1001"andmd1='0'andmd2="01") then
hou1<=hou1+1;
endif;
endif;
endprocessh110;
-----------------------------------------------小时个位
h220:
process(clk,min1,min2,sec1,sec2,md1,md2,hou1)
begin
ifclk'eventandclk='1'then
if(hou1="0010"andhou2="0011")and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then
hou2<="0000";
elsifhou2="1001"and(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001") then
hou2<="0000";
elsif(hou2="1001"andmd1='0'andmd2="01")or(hou1="0010"andhou2="0011")then
hou2<="0000";--md<='1';
elsif((min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001"))or(md1='0'andmd2="01")then
hou2<=hou2+1;--speak<=clk;
endif;
endif;
endprocessh220;
-----------------------------------------------分钟十位
m110:
process(clk,min2,sec1,sec2,md1,md2)
begin
ifclk'eventandclk='1'then
if(min1="0101"andmin2="1001")and(sec1="0101"andsec2="1001")then
min1<="0000";
elsifmin1="0101"andmin2="1001"and(md1='0'andmd2="00")then
min1<="0000";
elsif(min2="1001"and(sec1="0101"andsec2="1001"))or(min2="1001"andmd1='0'andmd2="00")then
min1<=min1+1;
endif;
endif;--endif;
endprocessm110;
----------------------------------------------分钟个位
m220:
process(clk,sec1,sec2,md1,md2)
begin
ifclk'eventandclk='1'then
ifmin2="1001"and(sec1="0101"andsec2="1001")then
min2<="0000";
elsifmin2="1001"and(md1='0'andmd2="00")then
min2<="0000";
else if(sec1="0101"andsec2="1001")or(md1='0'andmd2="00")then
min2<=min2+1;
endif;
endif;endif;
endprocessm220;
---------------------------------------------秒十位
s110:
process(clk)
begin
ifclk'eventandclk='1'then
if(sec1="0101"andsec2="1001")then
sec1<="0000";
elseifsec2="1001"then
sec1<=sec1+1;
endif;
endif;endif;
endprocesss110;
--------------------------------------------秒个位
s220:
process(clk)
begin
ifclk'eventandclk='1'then
ifsec2="1001"then
sec2<="0000";
elsesec2<=sec2+1;
endif;
endif;
endprocesss220;
-------------------------------------------时间设置小时部分
sethour1:
process(clk,seth2)
begin
ifclk'eventandclk='1'then
ifseth1="0010"andseth2="0011"then
seth1<="0000";
elsifseth2="1001" then
seth1<=seth1+1;
endif;
endif;
endprocesssethour1;
-------------------------------------------
sethour2:
process(clk,md1,md2,seth1)
begin
ifclk'eventandclk='1'then
if(seth1="0010"andseth2="0011")orseth2="1001"then
seth2<="0000";
elsifmd1='1'andmd2="00"then
seth2<=seth2+1;
endif;
endif;
endprocesssethour2;
-------------------------------------------时间设置分钟部分
setmin1:
process(clk,setm2)
begin
ifclk'eventandclk='1'then
ifsetm1="0101"andsetm2="1001"then
setm1<="0000";
elsifsetm2="1001"then
setm1<=setm1+1;
endif;
endif;
endprocesssetmin1;
----------------------------------------------
setmin2:
process(clk,md1,md2)
begin
ifclk'eventandclk='1'then
ifsetm2="1001"then
setm2<="0000";
elsifmd1='1'andmd2="01"then
setm2<=setm2+1;
endif;
endif;
endprocesssetmin2;
--------------------------------------------
--------------------------------------------闹铃
speaker:
process(clk1,hou1,hou2,min1,min2)
begin
ifclk1'eventandclk1='1'then
ifseth1=hou1andseth2=hou2andsetm1=min1andsetm2=min2then
speak<=clk1;
elsespeak<='0';
endif;
endif;
endprocessspeaker;
-------------------------------------------
-------------------------------------------
disp:
process(sel,md1,hou1,hou2,min1,min2,sec1,sec2,seth1,seth2,setm1,setm2)
begin
ifsel="000"then
selout<="000";
caseh1is
when"0000"=>dout<="0111111";
when"0001"=>dout<="0000110";
when"0010"=>dout<="1011011";
whenothers=>dout<="1000000";
endcase;
elsifsel="001"then
selout<="001";
caseh2is
when"0000"=>dout<="0111111";
when"0001"=>dout<="0000110";
when"0010"=>dout<="1011011";
when"0011"=>dout<="1001111";
when"0100"=>dout<="1100110";
when"0101"=>dout<="1101101";
when"0110"=>dout<="1111101";
when"0111"=>dout<="0000111";
when"1000"=>dout<="1111111";
when"1001"=>dout<="1101111";
whenothers=>dout<="1000000";
endcase;
elsifsel="010"then
selout<="010";
casem1is
when"0000"=>dout<="0111111";
when"0001"=>dout<="0000110";
when"0010"=>dout<="1011011";
when"0011"=>dout<="1001111";
when"0100"=>dout<="1100110";
when"0101"=>dout<="1101101";
whenothers=>dout<="1000000";
endcase;
elsifsel="011"then
selout<="011";
casem2is
when"0000"=>dout<="0111111";
when"0001"=>dout<="0000110";
when"0010"=>dout<="1011011";
when"0011"=>dout<="1001111";
when"0100"=>dout<="1100110";
when"0101"=>dout<="1101101";
when"0110"=>dout<="1111101";
when"0111"=>dout<="0000111";
when"1000"=>dout<="1111111";
when"1001"=>dout<="1101111";
whenothers=>dout<="1000000";
endcase;
elsifsel="100"then
selout<="100";
cases1is
when"0000"=>dout<="0111111";
when"0001"=>dout<="0000110";
when"0010"=>dout<="1011011";
when"0011"=>dout<="1001111";
when"0100"=>dout<="1100110";
when"0101"=>dout<="1101101";
whenothers=>dout<="1000000";
endcase;
elsifsel="101"then
selout<="101";
cases2is
when"0000"=>dout<="0111111";
when"0001"=>dout<="0000110";
when"0010"=>dout<="1011011";
when"0011"=>dout<="1001111";
when"0100"=>dout<="1100110";
when"0101"=>dout<="1101101";
when"0110"=>dout<="1111101";
when"0111"=>dout<="0000111";
when"1000"=>dout<="1111111";
when"1001"=>dout<="1101111";
whenothers=>dout<="1000000";
endcase;
endif;
ifmd1='0' then---------------计时时间显示和设置模式
h1<=hou1;h2<=hou2;
m1<=min1;m2<=min2;
s1<=sec1;s2<=sec2;
else -----------闹铃时间现实和设置模式
h1<=seth1;h2<=seth2;
m1<=setm1;m2<=setm2;
s1<="1111";s2<="1111";
endif;
endprocessdisp;
------------------------------------------
end one;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数字 时钟 VHDL 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)