EDA课程设计数字秒表.doc
《EDA课程设计数字秒表.doc》由会员分享,可在线阅读,更多相关《EDA课程设计数字秒表.doc(11页珍藏版)》请在冰点文库上搜索。
课程设计
题目数字秒表设计
院系信息工程学院
班 级
姓 名
指导教师
-11-
目录
第一章:
系统设计要求..............................................................................................3
第二章:
实验目的......................................................................................................3
第三章:
实验原理......................................................................................................3
第四章:
系统设计方案..............................................................................................3
第五章:
主要VHDL源程序.....................................................................................4
1)十进制计数器的VHDL源程序..............................................................4
2)六进制计数器的VHDL源程序..............................................................5
3)蜂鸣器的VHDL源程序..........................................................................5
4)译码器的VHDL源程序..........................................................................6
5)控制选择器的VHDL源程序..................................................................7
6)元原件例化的VHDL源程序..................................................................8
第六章:
系统仿真.......................................................................................................10
第七章:
系统扩展思路...............................................................................................11
第八章:
设计心得总结...............................................................................................11
数字秒表的设计
一、系统设计要求
1.秒表共有6个输出显示,分别为百分之一秒、十分之一秒、秒、十秒、分、十分,所以共有6个计数器与之相对应,6个计数器的输出全都为BCD码输出,这样便于和显示译码器的连接。
当计时达60分钟后,蜂鸣器鸣响10声。
2.整个秒表还需有一个启动信号和一个归零信号,以便秒表能随意停止及启动。
3.秒表的逻辑结构较简单,它主要由显示译码器、分频器、十进制计数器、六进制计数器和报警器组成。
在整个秒表中最关键的是如何获得一个精确的100HZ计时脉冲。
二、实验目的
通过本次课设,加深对EDA技术设计的理解,学会用QuartusⅡ工具软件设计基本电路,熟练掌握VHDL语言,为以后工作使用打下坚实的基础。
三、实验原理
秒表由于其计时精确,分辨率高(0.01秒),在各种竞技场所得到了广泛的应用。
秒表的工作原理与数字时基本相同,唯一不同的是秒表的计时时钟信号,由于其分辨率为0.01秒,所以整个秒表的工作时钟是在100Hz的时钟信号下完成。
当秒表的计时小于1个小时时,显示的格式是mm-ss-xx(mm表示分钟:
0~59;ss表示秒:
0~59;xx表示百分之一秒:
0~99),当秒表的计时大于或等于一个小时时,显示的和多功能时钟是一样的,就是hh-mm-ss(hh表示小时:
0~99),由于秒表的功能和钟表有所不同,所以秒表的hh表示的范围不是0~23,而是0~99,这也是和多功能时钟不一样的地方。
在设计秒表的时候,时钟的选择为100Hz。
变量的选择:
因为xx(0.01秒)和hh(小时)表示的范围都是0~99,所以用两个4位二进制码(BCD码)表示;而ss(秒钟)和mm(分钟)表示的范围是0~59,所以用一个3位的二进制码和一个4位的二进制码(BCD)码表示。
显示的时候要注意的问题就是小时的判断,如果小时是00,则显示格式为mm-ss-xx,如果小时不为00,则显示hh-mm-ss。
四、系统设计方案
秒表的逻辑结构较简单,它主要由显示译码器、分频器、十进制计数器、六进制计数器和报警器组成。
四个10进制计数器:
用来分别对百分之一秒、十分之一秒、秒和分进行计数;两个6进制计数器:
用来分别对十秒和十分进行计数;分频器:
用来产生100HZ计时脉冲;显示译码器:
完成对显示的控制。
根据电路持点,用层次设计概念将此设计任务分成若干模块,规定每一模块的功能和各模块之间的接口。
按适配划分后的管脚定位,同相关功能块硬件电路接口连线。
用VHDL语言描述所有底层模块。
清零信号为异步清零。
当最高位记到6时停止计数显示译码器全部显示零,并发出十声警报声。
按下复位按钮后继续计数。
数字秒表拟由单片的CPLD/FPGA来实现,经分析设计要求,拟定整个系统由10个模块组成,原理图如下:
五、主要VHDL源程序
1.十进制计数器的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycount10is
port(clk,start,clr:
instd_logic;
cout:
outstd_logic;
daout:
outstd_logic_vector(3downto0));
endcount10;
architectureoneofcount10is
signalq0:
std_logic_vector(3downto0);
signalq1:
std_logic;
begin
process(clk,clr)
begin
ifclr='1'thenq0<="0000";
elsif(clk'eventandclk='1')then
ifstart='1'then
ifq0="1001"thenq0<="0000";q1<='1';
elseq0<=q0+1;q1<='0';
endif;
endif;
endif;
endprocess;
daout<=q0;
cout<=q1;
endone;
2.六进制计数器的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycount6is
port(clk,start,clr:
instd_logic;
cout:
outstd_logic;
daout:
outstd_logic_vector(3downto0));
endcount6;
architecturetwoofcount10is
signalq0:
std_logic_vector(3downto0);
signalq1:
std_logic;
begin
process(clk,clr)
begin
ifclr='1'thenq0<="0000";
elsif(clk'eventandclk='1')then
ifstart='1'then
ifq0="0101"thenq0<="0000";q1<='1';
elseq0<=q0+1;q1<='0';
endif;
endif;
endif;
endprocess;
daout<=q0;
cout<=q1;
endtwo;
3.蜂鸣器的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityalarmis
port(clk,I:
instd_logic;
q:
outstd_logic
);
endalarm;
architecturearofalarmis
signaln:
integerrange0to20;
signalq0:
std_logic;
begin
process(clk)
begin
ifclk'eventandclk='1'
then
ifi='0'thenq0<='0';
n<=0;
elsifn<=19andi='1'then
q0<=notq0;
n<=n+1;
elseq0<='0';
endif;
endif;
endprocess;
q<=q0;
endar;
4.译码器的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entitydeledis
port(num:
instd_logic_vector(3downto0);
led:
outstd_logic_vector(6downto0));
enddeled;
architectureaofdeledis
begin
process(num)
begin
casenumis
when"0000"=>led<="0111111";
when"0001"=>led<="0000110";
when"0010"=>led<="1011011";
when"0011"=>led<="1001111";
when"0100"=>led<="1100110";
when"0101"=>led<="1101101";
when"0110"=>led<="1111101";
when"0111"=>led<="0100111";
when"1000"=>led<="1111111";
when"1001"=>led<="1101111";
whenothers=>led<="0000000";
endcase;
endprocess;
enda;
5.控制选择器的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityseltimeis
port(clr,clk:
inbit;
dain0,dain1,dain2,dain3,dain4,dain5:
instd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0);
daout:
outstd_logic_vector(3downto0));
endseltime;
architectureaofseltimeis
signaltemp:
integerrange0to5;
begin
process(clk)
begin
if(clr='1')then
daout<="0000";
sel<="000";
temp<=0;
elsif(clk='1'andclk'event)then
iftemp=5thentemp<=0;
elsetemp<=temp+1;
endif;
casetempis
when0=>sel<="000";daout<=dain0;
when1=>sel<="001";daout<=dain1;
when2=>sel<="010";daout<=dain2;
when3=>sel<="011";daout<=dain3;
when4=>sel<="100";daout<=dain4;
when5=>sel<="101";daout<=dain5;
endcase;
endif;
endprocess;
enda;
6.分频器的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entitydivis
port(clr,clk:
instd_logic;
q:
bufferstd_logic);
enddiv;
architectureaofdivis
signalcount:
integerrange0to99999;
begin
process(clr,clk)
begin
if(clk'eventandclk='1')then
ifclr='1'then
count<=0;
elsifcount=99999then
count<=0;
q<=notq;
else
count<=count+1;
endif;
endif;
endprocess;
enda;
7.元原件例化的VHDL源程序
libraryieee;
useieee.std_logic_1164.all;
entitymb_topis
port(
stop,start,clk:
instd_logic;
a,b,c,d,e,f,g,speaker:
outstd_logic;
sel:
outstd_logic_vector(2downto0));
endmb_top;
architectureaofmb_topis
componentdiv
port(clr,clk:
instd_logic;
q:
bufferstd_logic);
endcomponent;
componentcount10
port(
clr,start,clk:
instd_logic;
cout:
outstd_logic;
daout:
bufferstd_logic_vector(3downto0));
endcomponent;
componentcount6
port(
clr,start,clk:
instd_logic;
cout:
outstd_logic;
daout:
bufferstd_logic_vector(3downto0));
endcomponent;
componentseltime
port(
clr,clk:
instd_logic;
dain1:
instd_logic_vector(3downto0);
dain2:
instd_logic_vector(3downto0);
dain3:
instd_logic_vector(3downto0);
dain4:
instd_logic_vector(3downto0);
dain5:
instd_logic_vector(3downto0);
dain6:
instd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0);
daout:
outstd_logic_vector(3downto0));
endcomponent;
componentdeled
port(
num:
instd_logic_vector(3downto0);
led:
outstd_logic_vector(6downto0));
endcomponent;
componentalarm
port(
clk,i:
instd_logic;
q:
outstd_logic);
endcomponent;
signaldiv_q,b_cout,s_cout,m_cout,sm_cout,f_cout,sf_cout:
std_logic;
signalb_daout,s_daout,m_daout,sm_daout,f_daout,sf_daout,seltime_daout:
std_logic_vector(3downto0);
signalledout:
std_logic_vector(6downto0);
begin
a<=ledout(0);b<=ledout
(1);c<=ledout
(2);d<=ledout(3);
e<=ledout(4);f<=ledout(5);g<=ledout(6);
u1:
divportmap(stop,clk,div_q);
u2:
count10portmap(stop,start,div_q,b_cout,b_daout);
u3:
count10portmap(stop,start,b_cout,s_cout,s_daout);
u4:
count10portmap(stop,start,s_cout,m_cout,m_daout);
u5:
count6portmap(stop,start,m_cout,sm_cout,sm_daout);
u6:
count10portmap(stop,start,sm_cout,f_cout,f_daout);
u7:
count6portmap(stop,start,f_cout,sf_cout,sf_daout);
u8:
seltimeportmap(stop,div_q,b_daout,s_daout,m_daout,sm_daout,f_daout,sf_daout,sel,seltime_daout);
u9:
deledportmap(seltime_daout,ledout);
u10:
alarmportmap(div_q,sf_cout,speaker);
enda;
六、系统仿真
1.十进制
2.六进制
3.蜂鸣器
4.译码器
5.控制选择器
七、系统扩展思路
根据实验的内容可以适当的添加一些有实际作用和可行性的功能,如可以记录并显示多个数据。
根据扩展的内容设计相应的电路和模块来完成扩展的内容。
比如记录和显示多个数据,可以用多个秒表进行计数,在秒表电路的后面可以添加一个选择电路,运用选择电路选择需要输出的那个秒表的数值。
八、设计心得及体会
通过此次课程设计,让我对EDA这门技术有了更深的体会,并更好的学会了使用QuartusⅡ软件进行硬件设计。
在编写程序的过程中,遇到了很多问题,使我发现自己以前学习上存在的不足。
通过与同学探讨和请教老师,终于把问题都解决了,并加深了对数字时钟原理和设计思路的了解。
同时我也掌握了做课程设计的一般流程,为以后的电子设计这块积累了一定的经验,为以后从事相关工作有一些帮助。
最终解决了问题,攥写成报告。
通过对设计对实现和对报告对撰写,深深体会到了VHDL语言和EDA技术的一些技巧和设计思想,在完成设计的过程中,应该具有很清晰地思路,才可以使电路更完美和简便,要敢想敢做但是不应该有投机取巧的心理。
在完成每一步的时候都有意想不到的收获也有可能导致错误,所以在设计对过程中要集中精神。
在写报告的过程中,更加凸显了细心二字。
不可自认为完美,必须按照格式要求来撰写自己的报告,所以必须做到足够的精确。
利用EDA工具,电子设计师可以从概念、算法、协议等开始设计电子系统,大量工作可以通过计算机完成,并可以将电子产品从电路设计、性能分析到设计版图的整个过程的计算机上自动处理完成。
在进行设计时并不束缚设计者的想象力,这使得自学、扩展也可以很容易实现。
在设计中充分的认识到EDA课程对硬件设计的重要性,若把本门课程学好、学精,对硬件设计将有很大对帮助。
以后若有机会我将会利用更多时间来学习EDA技术、更加深入的学习EDA技术。
EDA技术以其独有的优点和应用范围有着非常好的发展前景,是近几年电子工业的发展趋向,中国的EDA行业发展十分迅速,有着很大的潜力。
所以我们学好这门课程是十分必要的,我们不应该仅仅