基于CPLD数字钟设计说.docx
《基于CPLD数字钟设计说.docx》由会员分享,可在线阅读,更多相关《基于CPLD数字钟设计说.docx(10页珍藏版)》请在冰豆网上搜索。
基于CPLD数字钟设计说
项目设计说明书
设计课题:
基于CPLD的数字钟设计
系别电气工程系
姓名:
彭诗懿
完成日期2012.6.29
目录
●设计要求
●设计思路
●CPLD简介
●主要VHLD源程序
●波形仿真
●实物图
●心得体会
1、设计要求。
<1>具有时、分、秒的计数显示功能,24小时循环显示。
<2>具有清零、预置初值功能,实现LED动态显示,整点报时采用声音报时。
<3>采用元件例化方式实现各模块间的连接。
2、设计思路.
(原理图)
3、CPLD简介。
CPLD(ComplexProgrammableLogicDevice)复杂可编程逻辑器件,是从PAL和GAL
器件发展出来的器件,相对而言规模大,结构复杂,属于大规模集成电路范围。
是一种用户
根据各自需要而自行构造逻辑功能的数字集成电路。
其基本设计方法是借助集成开发软件平
台,用原理图、硬件描述语言等方法,生成相应的目标文件,通过下载电缆(“在系统”编程)
将代码传送到目标芯片中,实现设计的数字系统。
四、主要VHDL源程序。
<1>24进制计数器。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
--*********************************************************
entitycount24Is
port(en1,en2,clk,rst:
instd_logic;
co:
outstd_logic;
a,b:
outstd_logic_vector(3downto0));
endcount24;
--*********************************************************
architecturertlofcount24is
signalaout,bout:
std_logic_vector(3downto0);
signalcout:
std_logic;
begin
process(en1,en2,clk,rst)
begin
if(rst='0')then
aout<="0000";
aout<="0000";
cout<='0';
elsif(clk'eventandclk='1')then
if(en1='1'oren2='0')then
if(bout=2)then
if(aout=3)then
aout<="0000";
bout<="0000";
cout<='1';
else
aout<=aout+1;
cout<='0';
endif;
elsif(aout=9)then
aout<="0000";
bout<=bout+1;
cout<='0';
else
aout<=aout+1;
cout<='0';
endif;
endif;
endif;
endprocess;
a<=aout;
b<=bout;
co<=cout;
endrtl;
<2>六十进制计数器。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
--*********************************************************
entitymincountIs
port(
en1,en2,clk,rst:
instd_logic;
co:
outstd_logic;
a,b:
outstd_logic_vector(3downto0));
endmincount;
--*********************************************************
architecturertlofmincountis
signalaout,bout:
std_logic_vector(3downto0);
signalcout:
std_logic;
begin
process(en1,en2,clk,rst)
begin
if(rst='0')then
aout<="0000";
bout<="0000";
cout<='0';
elsif(clk'eventandclk='1')then
if(en1='1'oren2='0')then
if(aout=9)then
aout<="0000";
if(bout=5)then
bout<="0000";
cout<='1';
else
bout<=bout+1;
endif;
else
aout<=aout+1;
cout<='0';
endif;
endif;
endif;
endprocess;
a<=aout;
b<=bout;
co<=cout;
endrtl;
(3)主体部分.
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
--*********************************************************
entityscanselectIs
port(clk,rst:
instd_logic;
in1,in2,in3,in4,in5,in6:
instd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0);
dataout:
outstd_logic_vector(3downto0));
endscanselect;
--*********************************************************
architecturertlofscanselectis
signalcnt:
std_logic_vector(2downto0);
begin
process(rst,clk)
begin
if(rst='0')then
cnt<="000";
elsif(clk'eventandclk='1')then
if(cnt="101")then
cnt<="000";
else
cnt<=cnt+1;
endif;
ifcnt="000"thendataout<=in1;
elsifcnt="001"thendataout<=in2;
elsifcnt="010"thendataout<=in3;
elsifcnt="011"thendataout<=in4;
elsifcnt="100"thendataout<=in5;
elsifcnt="101"thendataout<=in6;
endif;
endif;
endprocess;
sel<=cnt;
endrtl;
五、系统仿真/硬件验证
波形仿真
(秒钟计数模块仿真图)
(分钟计数模块仿真图)
(小时计数模块仿真图)
(扫描函数模块仿真)
六、实物图。
七、心得体会。
经过一周星期对实践的制作,从中学到了很多。
首先是对EDA的vhd语言的更深
层次认识,本来觉得EDA编程语言比较麻烦,可是接触了以后也就觉得它还是有它方
便的地方,尤其是和图形编程结合的特点。
其次,这个实践其实到目前为止应该还不是
一个成功的作品,还是有很多的仿真没有完成,原因可能也是自己的技术不到位。
但是
整个制作的过程中,它促进了同学之间的相互沟通,也让我在自己的专业知识的学习过
程中,更多的,更好的学习一门知识,用于以后的实践应用中,做这个数字钟的设计中
包含了很多不同功能的程序,让我在其中学到了一些程序的中的思路,掌握vhd语言。
相信现在只是一个起步,以后,我们会更好的去学习EDA.