基于VHDL的多功能数字钟设计报告.docx

上传人:b****5 文档编号:7684854 上传时间:2023-01-25 格式:DOCX 页数:20 大小:182.93KB
下载 相关 举报
基于VHDL的多功能数字钟设计报告.docx_第1页
第1页 / 共20页
基于VHDL的多功能数字钟设计报告.docx_第2页
第2页 / 共20页
基于VHDL的多功能数字钟设计报告.docx_第3页
第3页 / 共20页
基于VHDL的多功能数字钟设计报告.docx_第4页
第4页 / 共20页
基于VHDL的多功能数字钟设计报告.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

基于VHDL的多功能数字钟设计报告.docx

《基于VHDL的多功能数字钟设计报告.docx》由会员分享,可在线阅读,更多相关《基于VHDL的多功能数字钟设计报告.docx(20页珍藏版)》请在冰豆网上搜索。

基于VHDL的多功能数字钟设计报告.docx

基于VHDL的多功能数字钟设计报告

基于VHDL的多功能数字钟

设计报告

021215班

卫时章

02121451

一、设计要求

1、具有以二十四小时制计时、显示、整点报时、时间设置和闹钟的功能。

2、设计精度要求为1秒。

二、设计环境:

QuartusII

三、系统功能描述

1、系统输入:

时钟信号elk采用50MHz;系统状态及较时、定时转换的控制信号为k、set,校时复位信号为reset,均由按键信号产生°

2、系统输出:

LED显示输出;蜂鸣器声音信号输出。

3、多功能数字电子钟系统功能的具体描述如下:

(一)计时:

正常工作状态下,每日按24h计时制计时并显示,蜂鸣器无声,逢整点报时。

(2)校时:

在计时显示状态下,按下“k”键,进入“小时”待校准状态,若此时按下“set”键,小时开始校准;之后按下“k”键则进入“分”待校准状态;继续按下“k”键则进入“秒”待复零状态;再次按下“k”键数码管显示闹钟时间,并进入闹钟“小时”待校准状态;再次按下“k”键则进入闹钟“分”待校准状态;若再按下“k”键恢复到正常计时显示状态。

若校时过程中按下“reset"键,则系统恢复到正常计数状态。

(1)“小时”校准状态:

在“小时”校准状态下,显示“小时”的数码管以2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。

(2)“分”校准状态:

在“分”校准状态下,显示“分”的数码管以2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。

(3)“秒”校准状态:

在“秒复零”状态下,显示“秒”的数码管以2Hz闪烁,并以1Hz的频率递增计数。

(4)闹钟“小时”校准状态:

在闹钟“小时”校准状态下,显示“小时”的数码管以2Hz闪烁,并按下“s巳「键时以2Hz的频率递增计数。

(5)闹钟“分”校准状态:

在闹钟“分”校准状态下,显示“分”的数码管以

一输入时钟信号

--每来个时钟上升沿时cout开始计数--当cout<=25000时,qlKHz输出“0”;--当25000

--输出T,完成lKHz频率输出

2Hz闪烁,并按下“set”键时以2Hz的频率递增计数。

(三)整点报时:

蜂鸣器在“59”分钟的第"51”、“53”、“55”、"57”秒发频率为500Hz的低音,在“59”分钟的第“59”秒发频率为1000Hz的髙音,结束时为整点。

(四)显示:

采用扫描显示方式驱动4个LED数码管显示小时、分,秒由两组led灯以4位BCD码显示。

(五)闹钟:

闹钟定时时间到,蜂鸣器发出频率为1000Hz的高音,持续时间为60秒。

四、各个模块分析说明

1、分频器模块(freq,vhd)

(1)模块说明:

输入一个频率为50MHz的CLK,利用计数器分出

lKHz的qlKHz,500Hz的qSOOHz,2Hz的q2Hz和1Hz的qlHz。

(2)源程序:

libraryieee;useieee・stdlogic_l164.all;useieee・stdlogiconsigned・all;

entityfreqisport(CLK:

instdlogic;

qlKHz:

bufferstdlogic;q500Hz:

bufferstdlogic;q2Hz:

bufferstdlogic;qlHz:

outstdlogic):

endfreq;

architecturebhvoffreqisbegin

P1KHZ:

process(CLK)variablecout:

integer:

=0;begin

ifCLK1eventandCLK二T'thencout:

=cout+l;

ifcout<=25000thenqlKHz<='0';elsifcout<50000thenqlKHz<=,1elsecout:

=0;

endif;

endif;

endprocess;

P500HZ:

process(qlKHz)—qlKHz作为输入信号,分出qSOOHz

variablecout:

integer:

=0;

begin

ifq1KHzreventandqlKHz=Tthen

cout:

=cout+l;

ifcout=lthenq500Hz<='0';―二分频

elsifcout=2thencout:

=0:

q500Hz<=rT;

endif;

endif;

endprocess;

P2HZ:

process(q500Hz)

variablecout:

integer:

=0;

begin

ifq500Hzreventandq500Hz二T‘thencout:

=cout+l;

ifcout<=125thenq2Hz<='0';

elsifcout<250thenq2Hz〈二T‘;elsecout:

=0;

endif;

endif;

endprocess;

P1HZ:

process(q2Hz)

variablecout:

integer:

=0;

begin

ifq2Hzreventandq2Hz二Tthencout:

=cout+l;

ifcout=lthenqlHz〈=O;

elsifcout=2thencout:

二0;qlHz〈二i;

endif;

endif;

endprocess;

endbhv;

2x控制器模块(contral.vhd)

(1)模块说明:

输入端口k,set键来控制6个状态,这六个状态分别是:

显示计时时间状态,调计时的时、分、秒的3个状态,调闹铃的时.分的3个状态,reset键是复位键,用来回到显示计时时间的状态。

(2)波形仿真图:

Sene

dk

reset

set

obh

cth

OW

£1沁flakinfloshz

lrf-l

04

06

5

06

衬纟

Oto

n

(3)模块图:

300as

7

160.0ns

400.0ns

240pz

460.a0ns

 

:

control

0

»

elk

cth

k

ctm

!

纯t

cts

\—

reset

ebh

»I

cbm

»

>

»

0

flashh

flashnn

flashs

>

»

s-eLsfww

jinstl

二选一模块(mux21a.vhd)

(1)源程序:

libraryieee;useieee・stdlogic_l164.all;useieee・stdlogic_unsigned.all;entitymux21aisport(a,b,s:

inbit;

y:

outbit);

endentitymux21a;architectureoneofmux21ais

begin

process(a,b,s)

begin

ifs='0,then

y<=a;―若s=0,y输出a,反之输出b。

elsey<=b;endif;endprocess;

endarchitectureone;

(2)仿真波形图:

 

(3)模块图:

=mux21a

?

y

i—

b

i——

s

?

inst2

:

••••••••••••・••••・•・・・•••••••••••••・••・・・•・•・••夕

4.计时模块

a.秒计时(second,vhd)

(1)仿真波形图:

xsldo阳

jnjinjuwurLnjrLnjWiJirLrLnjinLrwumniJinuLrLnJLnjiJTnLnnrLnrLninjij

「「门门x

(2)模块图:

(•••••••••■•••••••

r&st

s»D[3..O]

dk

sMip..43

co

1—

irtst4

b・分计时(minute,vhd)

(1)仿真波形图:

(2)模块图:

elksk>D[3..O]

ski1[7..4]

co

c.小时计时(hour,vhd)

[hour

»

\

dksk»3[3..0J

4

sMip..4]

:

inst6

d.闹钟分计时(cntm60b.vhd)

(1)仿真波形图:

Nano

33u,5.9?

38.®L3.印u,IS.IT18.7?

321.2.9g3

LnjuinirLnarLnnmarLnnnjwnjiRnnrLruwinjumnmnnjuuiruinr

BP

[mirr^b

i

i■

•ensld0[3..0J

4

s

dksldip..4J

inst7

e.闹钟小时计时(cnth24b.vhd)

(1)仿真波形图:

\-Gntti^b\

■—ensWO[3..O]

;—dksldip..4J—*

;!

:

!

:

irast8j

5、闹钟比较模块(compare,vhd)

(1)模块说明:

比校正常计数时间与闹钟定时时间是否相等,若相等,compout输出T,反之输出“0”。

(2)仿真波形图:

1-compare

th1[7..4joompout

tM[3..O]

t(nO[3...O]

bhip..4]

bmf[7.,4]

bh0[3.,0]

0

>

bmO[3..0]

jinst§

6、报时模块(bell.vhd)

(1)模块说明:

该模块既实现了整点报时的功能,又实现了闹铃的功能,蜂鸣器通过所选频率的不同,而发出不同的声音。

(2)仿真波形图:

Wane

1ps5.1?

us10.^4us】5.3pus204f8us25.§us3072us

16.5ns

#

openbel

compout

1■■■=■!

■■■=■■■■■'=1=「「「i

qlKKz

曲测蒯ill咂测皿测测呱测i■■删测呱

q500Hz

jmnjwinjTrLnjTrLnnnjTrLrLnjwuuirLnjirLnjinjinrLnjinjirLrLrL

(±1tnl

〔5~

[±jtnO

:

9

13tsl

:

5

□tsO

0XlX2:

〈3X4X5X&X7:

〈6:

「mX0)(lX2〉:

3)(4X5X6X7:

〈6)(9X0

bell

l■l■l^l■■lWMlll■l皿L_n_n_nn._nn.jitl一iiil_

(3)模块图:

jtell

!

tell

ts.tp.4]tmop.o

ts.O[3..O]compoutqlKHzq5O3Hz•opsnbel

!

irrstl1

7x控制显示模块(show_con

(1)模块说明:

该模忘实现了数码管既可以显示正常时间,又可以显示闹钟时间的功能;调时过程的定时闪烁功能也在此模块中真正实现。

(2)源程序:

libraryieee;

useieee・stdlogic_l164.all;

useieee・stdlogiconsigned・all;

entityshowconis

seel,mini,hl:

outstdlogic_vector(7downto4);sec0,min0,hO:

outstdlogic_vector(3downto0):

q2Hztflashs,flashh,flashm,sel_show:

instdlogic);

endshowcon;architecturertlofshowconis

begin

process(thl,tml,tsl,thO,tmO,tsO,bhl,bml,bhO,bmO,q2Hz,f1ashs,f1ashh,flashm,seishow)

begin

ifsel_show=r0rthen

if(flashh=,11andq2Hz=,1')thenhl<=',llir,;hO<=,,llir,;一显示小时数码管以2Hz闪烁minl<=tml;min0<=tm0;

secl<=tsl;sec0<=ts0;

elsif(flashm='1'andq2Hz=,1')then

hl<=thl;hO<=thO;mini<=wllllw;minO<=wllllff;

secl<=tsl;sec0<=ts0;

elsif(flashs='1'andq2Hz=,1')then

hl<=thl;hO<=thO;

minl<=tml;min0<=tni0;

secl<=Bllir,;secO<=ttllllw;

else

hl<=thl;hO<=thO;

minl<=tml;min0<=tm0;secl<=tsl;secO<=tsO;endif;

elsifseishow二T'then—若seishow为"1”,数码管显示闹钟时间一一

if(flashh二T‘andq2Hz二T')thenhi<=,,iiii,,;ho<=ffinr,;minl<=bml;minO<=:

bmO;

secl<=tt0000”;sec0<="0000”;

elsif(flashm二T'andq2Hz二T)then

hl<=bhl;hO<=bhO;

minl<=ffllir,;minO<=,,llir,;

sec1<="0000“;sec0<="0000”;

else

hl<=bhl;hO<=bhO;

mini<=bml;min0<=bm0;

sec1<="0000”;sec0<="0000“;

endif;

endif;

endprocess;

endrtl;

(3)模块图:

:

showoora

th1|7..41

sac1[7..4J

L

tm1[7..4)

L

ts1[7.,4]

hip..4)

L

thO[3..O]

Sfe&3[3..0]

L

wop..0]

min(X3..0]

r—

ts-9[3..O)

L

bMp..4)

bm1[7..4J

bW|3..O]

j—

q2Hz

i—

flashs

i—

fias-hh

i—

fl35-hm

sel_5how

instil)

8>动态扫描显示模块(scarified,vhd)

(1)模块说明:

由4组输入信号和输出信号进而实现了时钟时、分的动态显示。

(2)源程序:

libraryieee;

useieee・stdlogic_l164.all;

useieee・stdlogic_unsigned・all;entityscan_ledis

port(clkl:

instdlogic;

hO:

instdlogic_vector(3downto0):

hl:

instdlogic_vector(7downto4);minO:

instdlogic_vector(3downto0):

mini:

instdlogic_vector(7downto4);

ML:

out

MH:

out

HL:

out

HH:

out);

stdlogic_vector(7stdlogic_vector(7stdlogic_vector(7stdlogic_vector(7

downtodowntodowntodownto

0)

0)

0)

0)

 

endscanled;architectureoneofseanledis

signalt4:

stdlogic_vector(ldownto0):

signala:

stdlogic_vector(3downto0);begin

pl:

process(clkl)

begin

ifclklreventandclkl二ithent4<=cnt4+l;

ift4=3then

t4<="00";

endif;

endif;

endprocesspl;

p2:

process(cnt4,hl,hO,mini,minO)

begin

caset4is—控制数码管位选

when,,00'r=>caseminOis

when"0000w=>ML<=,r11000000w;

when”0001"=>ML<=T1111001";

when"0010”=>ML<=T0100100”;

when"0011ff=>ML<="10110000tt;

whenH0100M=>ML<=M10011001

whenh0101m=>ML<=m10010010m;

when”0110”=>ML<=”10000010";

when,,01ir=>ML<=M11111000M;

whenM1000H=>ML<=hl0000000r,;

whenm1001m=>ML<=m10010000m;whenothers^NULL;

endcase;

when"01"=>caseminiis

whenff0000w=>MH<=w11000000'*;whenM000r=>MH<=Millll00r;when"0010”=>MH<=T0100100”;when"0011,r=>MH<=T0110000”;when"0100”=>MH<=T0011001”;when"0101"=>MH<=T0010010”;when"0110”=>MH<=T0000010”;when"Oil1”=>MH<=T1111000”;whenT000”=>MH<=T0000000”;whenT001”=>MH<=TOO10000";whenothers^NULL;

endcase;

whenT0"=>casehOis

when"0000”=>HL<="11000000w;

when"0001”=>HL<=T1111001";when"0010”=>HL<=T0100100”;when"0011ff=>HL<="10110000ff;when"0100”=>HL<=T0011001";when"0101"=>HL<=T0010010";when"0110”=>HL<=T0000010”;when"0111”=>HL<=T1111000”;whenT000”=>HL<=T0000000”;whenM1001M=>HL<=M10010000M;whenothers=>NULL;

endcase;

when,,H,,=>casehlis

when"0000”=>HH<="11000000w;

when"0001”=>HH<=T1111001";when"0010"=>HH<=T0100100";when"0011,r=>HH<=T0110000”;when"0100”=>HH<=T0011001";when"0101”=>HH<=T0010010";when"0110”=>HH<=T0000010”;when"0111"=>HH<=T1111000”;whenT000”=>HH<=T0000000”;when"1001”=>HH<=T0010000";whenothers=>NULL;

endcase;

whenothers=>null;

endcase;

endprocessp2;endone;

(3)模块图:

jscan_ted

\

dkl

ML[7..O]

-4

r—

HX3.0]

MH[7..O]

T

h1[7..4j

HL[7..O]

mirv3[3..0]

B

min1[7..4]

;inst17

五、端口设定

k:

button2,set:

buttonl,reset:

buttonO;

Bell:

SW1用于开关蜂鸣器;

=

Q忤Qa就rwls

()pe^)ASTiiTTaT

Gre^p)as*2irfifl

Q卩吨asp匹“

(ir^)as'zSFTT

3哪)asporTia

Orc^pjftsiSHF

(4FW)A5*ZSTiT

Gfchp)As*ion"ih

Ofvp)astrhfzs

:

:

m-t••..'=

•r;:

「.-•-

0PW)AS7t^G

OPOPP)AS7【心

(myftwzwra

珂"tS[25

単呼呼制ligg

缈呷仮TiigS

Si:

-i\j.\=

Ti^S

(W卿)便onTzfl

QP卿WlINiQ

"与綱A£・?

fSTZa

Ore^p)as-£onTI

6p

Orv^p)AS*ZOnTF

<4Fe^p)ft$-ZSTTb*

ftpcw)AS*ZDNZfl"

3沖)as丘on7b

“却A£2

ONLB

—4

叽即)E

ONZQ

"却AST:

DhTZB

OfC^p)AS7

otTzb

-♦

Q咛p)AST

|・・:

OFVP)AST

orris

•q

QMPP”讥

I「2d2C~MdToJduTSodbudbaTaTEdTbTHjeFmj

rczo

jncxino

E;P

)gp

FG-no

inch:

Miso~[iTS■—石

呼Q

O

kins~

4更]T丘ZEZE"u

ZHN3d:

I汀皿【【EdnH~Md:

»••':

!

ns~MJdnrwidnrwjdn

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

当前位置:首页 > 经管营销 > 金融投资

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

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