电子钟的设计.docx

上传人:b****7 文档编号:26613813 上传时间:2023-06-20 格式:DOCX 页数:26 大小:251.86KB
下载 相关 举报
电子钟的设计.docx_第1页
第1页 / 共26页
电子钟的设计.docx_第2页
第2页 / 共26页
电子钟的设计.docx_第3页
第3页 / 共26页
电子钟的设计.docx_第4页
第4页 / 共26页
电子钟的设计.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

电子钟的设计.docx

《电子钟的设计.docx》由会员分享,可在线阅读,更多相关《电子钟的设计.docx(26页珍藏版)》请在冰豆网上搜索。

电子钟的设计.docx

电子钟的设计

 

EDA课程设计

实验报告

 

系别:

自动化工程系

专业:

电子测量技术与仪器

同组人员:

郑洪梅倪英华

指导老师:

史利华

 

一电子钟的设计

一.设计要求:

1.能实现时,分,秒计时。

2.能实现整电报时。

3.能进行对时和分的校准。

二.实验目的:

1.掌握多位计数器相连的方法。

2.掌握十六进制,二十四进制,六十进制计数器的设计方法。

3.握CPLD技术的层次化设计法。

4.了解软件的元件管理含义以及模块元件之间的连接概念。

5.掌握电子电路一般的设计方法,并了解电子产品的研制开发过程,基本掌握电子电路安装和调试方法。

6.培养独立分析问题,团结解决问题的能力。

三.硬件要求:

1.8位8段扫描共阴极数码显示管。

2.三个按键开关(清零,校时,校分)。

四.设计原理

1.数字钟的计时周期为24小时,显示满刻度为23时59分59秒,另外具备校时功能和报时功能。

因此,一个基本的数字钟主要由“时”“分”“秒”计数器校时电路组成。

将标准信号送入“秒计数器”,“秒计数器”采用60进制计数器,每累加60秒发送一个“分脉冲”信号,该信号将被送到“时计数器”,“时计数器”采用24进制计数器,可实现对一天24小时的累计。

译码显示电路将“时”“分”“秒”计数器的输出状态六段显示译码器译码。

通过六位LED七段显示器显示出来

2.校时电路是用来对“时”“分”显示数字进行校时调整的。

五.电子时钟模块设计

1.分频模块FENPIN设计

模块FENPIN原理图如下:

图3FENPIN原理图

FENPIN源程序

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityFENPis

port(clk1:

instd_logic;

clk:

outstd_logic);

end;

architectureoneofFENPis

signala:

std_logic_vector(8downto0);

signalb,c:

std_logic;

begin

process(clk1)

begin

ifclk1'eventandclk1='1'then

ifa="100000000"then

b<='1';

a<="000000000";

else

a<=a+1;

b<='0';

endif;

endif;

endprocess;

clk<=b;

end;

仿真波形如下:

图4FENPIN波形图

2.模块MIAO1设计

模块MIAO1原理图如下,CLK和RESET控制DAOUT,SETIME和CLK控制ENMIN

图5SECOND的原理图

MIAO1的源程序如下

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitymiao1is

port(clk,reset,setmin:

instd_logic;

daout:

outstd_logic_vector(6downto0);

enmin:

bufferstd_logic);

end;

architecturetwoofmiao1is

signald:

std_logic_vector(6downto0);

signalenmin1,enmin2:

std_logic;

begin

process(clk,reset,setmin)

begin

ifreset='1'

thend<="0000000";

elsif(clk'eventandclk='1')then

ifd<16#60#then

ifd="1011001"then

d<="0000000";enmin1<='1';

elsed<=d+1;enmin1<='0';

ifd(3downto0)="1001"thend<=d+7;

endif;endif;

endif;endif;endprocess;

daout<=d;

enmin<=(enmin1orenmin2);

enmin2<=(setminandclk);

end;

波形仿真图如下

图1-4MIAO1的波形仿真

3.模块FENZ设计

模块FENZ原理图如下,CLK和RESET控制DAOUT,SEHOUR控制ENHOUR

图6fen图

FENZ的源程序如下

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityfenis

port(reset,clk,sethour,clk1:

instd_logic;

daout:

outstd_logic_vector(6downto0);

enhour:

bufferstd_logic);

end;

architecturetwooffenis

signald:

std_logic_vector(6downto0);

signalenhour1,enhour2:

std_logic;

begin

process(clk,clk1,reset,sethour)

begin

ifreset='1'

thend<="0000000";

elsif(clk'eventandclk='1')then

ifd<16#60#then

ifd="1011001"then

d<="0000000";enhour1<='1';

elsed<=d+1;enhour1<='0';

ifd(3downto0)="1001"thend<=d+7;

endif;endif;

endif;endif;endprocess;

daout<=d;

enhour<=(enhour1orenhour2);

enhour2<=(sethourandclk1);

end;

 

波形仿真图如下

图7FENZ的波形仿真

4.模块HOUR设计

模块HOUR原理图如下,CLK和RESET控制DAOUT。

图8HOUR的原理图

HOUR的源程序如下

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityhouris

port(reset,clk:

instd_logic;

daout:

outstd_logic_vector(5downto0));

end;

architecturetwoofhouris

signald:

std_logic_vector(5downto0);

begin

process(clk,reset)

begin

ifreset='1'

thend<="000000";

elsif(clk'eventandclk='1')then

ifd<16#60#then

ifd="100011"then

d<="000000";

elsed<=d+1;ifd(3downto0)="1001"thend<=d+7;endif;endif;

endif;endif;endprocess;

daout<=d;

end;

波形仿真图如下

图9HOUR的波形仿真

5.模块XIANS设计

模块XIANS原理图如下,当SEL取不同值时DAOUT分别选择输出SEC.MIN.HOUR

图10SELTIME的原理图

SELTIME的源程序

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityseltimeis

port(clk2,reset:

instd_logic;

hour,sec,min:

instd_logic_vector(6downto0);

daout:

outstd_logic_vector(3downto0);

sel:

outstd_logic_vector(2downto0));

end;

architecturebhvofseltimeis

signalq1:

std_logic_vector(2downto0);

begin

process(clk2,reset)

variabledaa:

std_logic_vector(3downto0);

begin

ifreset='1'thendaout<="0000";sel<="000";

elsifclk2'eventandclk2='1'then

q1<=q1+1;

caseq1is

when"101"=>daa:

=sec(3downto0);

when"100"=>daa:

='0'&sec(6downto4);

when"011"=>daa:

=min(3downto0);

when"010"=>daa:

='0'&min(6downto4);

when"001"=>daa:

=hour(3downto0);

when"000"=>daa:

='0'&hour(6downto4);

whenothers=>daa:

="0000";

endcase;

sel<=q1;

daout<=daa;

endif;

endprocess;

end;

仿真波形如下

图11XIANS的波形仿真

6.模块QIDUAN设计

QIDUAN图如下通过判断Q有4位输入数字组成16种状态确定输出Y点亮的什么数字,通过SEL选择输出Y的值。

图12.QIDUAN的原理图

LED源程序如下:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityledis

port(q:

instd_logic_vector(3downto0);

sel:

instd_logic_vector(2downto0);

y:

outstd_logic_vector(7downto0));

endled;

architecturertlofledis

signalc:

std_logic_vector(7downto0);

begin

process(q,sel)

begin

caseqis

when"0000"=>c(6downto0)<="0111111";

when"0001"=>c(6downto0)<="0000110";

when"0010"=>c(6downto0)<="1011011";

when"0011"=>c(7downto0)<="1001111";

when"0100"=>c(6downto0)<="1100110";

when"0101"=>c(6downto0)<="1101101";

when"0110"=>c(6downto0)<="1111101";

when"0111"=>c(7downto0)<="0000111";

when"1000"=>c(6downto0)<="1111111";

when"1001"=>c(6downto0)<="1101111";

when"1010"=>c(6downto0)<="1110111";

when"1011"=>c(7downto0)<="1111100";

when"1100"=>c(6downto0)<="0111001";

when"1101"=>c(6downto0)<="1011110";

when"1110"=>c(6downto0)<="1111001";

whenothers=>c(6downto0)<="0000000";

endcase;

if(sel="001"orsel="011"orsel="101")then

c(7)<='1';

elsec(7)<='0';

endif;

y<=c;

endprocess;

endrtl;

灯管连线:

仿真波形如下:

图13QIDUAN的波形图

7.模块BAOS设计

LAMP原理图如下,当DAIN为0的时候SPEAK发声,在这段发声时间内LAMP的三个灯相继点亮。

图14LAMP原理图

LAMP源程序如下:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitylampis

port(clk:

instd_logic;

dain:

instd_logic_vector(6downto0);

speak:

outstd_logic;

lamp:

outstd_logic_vector(2downto0));

end;

architecturebehavoflampis

begin

process(clk)

variableb:

std_logic_vector(1downto0);

variableh:

std_logic;

variablelam:

std_logic_vector(2downto0);

begin

ifdain="0000000"thenh:

='1';

elseh:

='0';

endif;

ifclk'eventandclk='1'then

b:

=b+1;

casebis

when"00"=>lam:

="000";

when"01"=>lam:

="001";

when"10"=>lam:

="010";

when"11"=>lam:

="100";

whenothers=>lam:

="000";

endcase;

endif;

ifh='1'then

lamp<=lam;

elselamp<="000";

endif;

speak<=h;

endprocess;

end;

仿真波形如下:

图15BAOS波形图

顶层原理图如下:

图1顶层文件原理图

时序仿真:

程序仿真主要由计数器完成,在时钟脉冲作用下,完成始终功能,由时序图可以看出每个时钟上升沿到来时加一,当接受到REST信号,即REST为高电平,所有计数为零,并重新计数,SETMIN和SETHOUR可以完成调节时钟功能,都是高电平调节,每来一个脉冲,相应的时或分加1。

图2时序仿真

引脚锁定

Clk=83,lamp0=51,lamp1=50,lamp2=49,led7s0=81,led7s1=80,led7s2=79,led7s3=77,

led7s4=76,led7s5=75,led7s6=74,led7s7=73;res=45,sel0=70,sel1=69,sel2=68;

sethour=41,setmin=44;

实验总结:

通过本次实验我们了解到电子时钟的设计原理,让我们更加了解到这些生活中的东西怎么设计出来的,并且学会找出错误,改正错误。

对时、分、秒的设计了解到很多知道,通过本次学习对我们以后有了很大的帮助。

 

二交通灯设计

设计说明:

现代,在城市的交通繁忙的交叉路口,行人比较多的路口,或学校附近都设有许多的红绿交通灯。

它指示着行人、车辆有序的通行。

其中,红灯停,绿灯行,黄灯表警示。

在灯的旁边还有数字晶体显示器,用于提示行人、司机三种颜色的灯即将跳转所剩的时间,让其做好应有的准备。

一.设计要求:

1.在十字路口的方向上各设一组红绿黄灯,显示顺序为:

其中一个方向是绿灯、黄灯、红灯,另外一个方向是红灯、绿灯、黄灯。

2.设置4个数码管,以倒计时的方式显示允许通过或禁止的时间,其中绿灯、黄灯、红灯的持续时间分别是30秒、5秒、35秒。

二.设计原理图

状态转换图

三、各模块设计

1、模块CNT8设计

模块FENPIN如下图,该模块的功能是将时间256分频,得到占空比为1:

256的方波。

图1-4CNT8顶层图

分频器FP程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityfpis

port(clk:

instd_logic;

sel:

outstd_logic_vector(2downto0);

d:

outstd_logic);

end;

architecturebhvoffpis

signalclk2:

std_logic;

signalq:

std_logic_vector(2downto0);

begin

process(clk,clk2)

variablecount:

std_logic_vector(7downto0);

begin

ifclk'eventandclk='1'then

ifcount="10000000"thenclk2<=not(clk2);count:

="00000000";

elsecount:

=count+1;

endif;

endif;

endprocess;

d<=clk2;

process(clk)

begin

ifclk'eventandclk='1'thenq<=q+1;

endif;

endprocess;

sel<=q;

endbhv;

波形仿真如下:

图1-5CNT8波形仿真图

2、模块JTD设计

如图1-2,该模块为整个程序的核心,它实现东西和南北方向的三种交通灯颜色的交替点亮、时间的倒计时。

图1-6JTD顶层图

JTD的源程序

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitydengis

port(clk,clr:

instd_logic;

dx,nb:

outstd_logic_vector(2downto0);

shi1,ge1:

outstd_logic_vector(3downto0));

end;

architectureadofdengis

signalshi,ge:

std_logic_vector(3downto0);

typefsm_stis(s1,s0,s2,s3);

signalstate:

fsm_st;

begin

process(clk,clr)

begin

ifclr='1'thenstate<=s0;ge<="0000";shi<="0011";

elsifclk'eventandclk='1'then

casestateis

whens0=>dx<="100";nb<="001";

ifge="0000"thenifshi="0000"thenstate<=s1;

ge<="0101";shi<="0000";

elseshi<=shi-1;

ge<="1001";

endif;

elsege<=ge-1;

endif;

whens1=>dx<="100";nb<="010";

ifge="0000"thenifshi="0000"thenstate<=s2;

ge<="0000";shi<="0011";

elseshi<=shi-1;

ge<="0000";

endif;

elsege<=ge-1;

endif;

whens2=>dx<="001";nb<="100";

ifge="0000"thenifshi="0000"thenstate<=s3;

ge<="0101";shi<="0000";

elseshi<=shi-1;

ge<="1001";

endif;

elsege<=ge-1;

endif;

whens3=>dx<="010";nb<="100";

ifge="0000"thenifshi="0000"thenstate<=s0;

ge<="0000";shi<="0011";

elseshi<=shi-1;

ge<="0101";

endif;

elsege<=ge-1;

endif;

endcase;

endif;

shi1<=shi;

ge1<=ge;

endprocess;

end;

波形仿真图如下:

图1-7JTD波形仿真图

3、模块MUX设计

顶层图如下,通过SEL的不同状态选择输出不同的值,当SEL=“000”输出“shi”,当SEL=“001”时输出“ge”。

图1-8MUX顶层图

MUX源程序如下:

libraryieee;

useieee.std_logic_1164.all;

entitymux1is

port(ge,shi:

instd_logic_vector(3downto0);

sel:

instd_logic_vector(2downto0);

y:

outstd_logic_vector(3downto0));

end;

architecturegaofmux1is

begin

process(sel)

variabled:

std_logic_vector(3downto0);

begin

caseselis

when"001"=>d:

=ge;

when"000"=>d:

=shi;

whenothers=>d:

="0000";

endcase;

y<=d;

endprocess;

end;

波形仿真图如下:

图1-9波形仿真图

4、模块LED设计

顶层图如下,通过判断Q有4位数字组成16种状态,确定输出Y点亮什么数字。

通过SEL选择输出Y的值。

图1-10LED顶层图

LED源程序如下:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityledis

port(q:

instd_logic

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 临床医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1