数字钟VHDLWord格式文档下载.docx

上传人:b****6 文档编号:17253120 上传时间:2022-11-29 格式:DOCX 页数:17 大小:64.06KB
下载 相关 举报
数字钟VHDLWord格式文档下载.docx_第1页
第1页 / 共17页
数字钟VHDLWord格式文档下载.docx_第2页
第2页 / 共17页
数字钟VHDLWord格式文档下载.docx_第3页
第3页 / 共17页
数字钟VHDLWord格式文档下载.docx_第4页
第4页 / 共17页
数字钟VHDLWord格式文档下载.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

数字钟VHDLWord格式文档下载.docx

《数字钟VHDLWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《数字钟VHDLWord格式文档下载.docx(17页珍藏版)》请在冰豆网上搜索。

数字钟VHDLWord格式文档下载.docx

显示“小时”的数码管以1Hz的频率递增计数。

“分”设置状态:

在闹钟“分”设置状态下,显示“分”

的数码管以1Hz的频率递增计数。

三:

仿真。

分主控模块、计时校时模块、闹钟设定模块、选择显示模块、整点报时及闹铃模块、分频模块、动态显示模块。

主控模块代码:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entitycontrolis

port(clk,k,set,reset,trans:

instd_logic;

jh,jm,js,nh,nm,ns,flashh,flashm,flashs,selct:

outstd_logic);

endcontrol;

architecturebehavofcontrolis

typestatesis(s0,s1,s2,s3,s4,s5,s6,s7);

signalcurrent_state,next_state:

states;

begin

process(reset,clk,next_state,current_state,k,set)

if(reset='

1'

)then

current_state<

=s0;

elsif(clk'

eventandclk='

=next_state;

endif;

casecurrent_stateis

whens0=>

flashh<

='

0'

;

flashm<

flashs<

jh<

jm<

js<

nh<

nm<

ns<

selct<

if(trans='

)thennext_state<

=s4;

elsif(set='

)then

next_state<

=s1;

else

whens1=>

if(set='

=s2;

whens2=>

)then

=s3;

whens3=>

if(set='

)then

whens4=>

if(trans='

elsif(set='

=s5;

whens5=>

)then

next_state<

=s6;

whens6=>

=s7;

whens7=>

If(set='

endcase;

endprocess;

endbehav;

主控模块仿真图

2、计时校时模块(包括二选一,60进制及24进制部分)

二选一

entitymux2_1is

port(d0,d1,en:

instd_logic;

sel:

y:

endmux2_1;

architecturemux2_1_archofmux2_1is

begin

process(d0,d1,sel)

begin

if(sel='

y<

=d0;

elsif(sel='

anden='

=d1;

endif;

endprocess;

endmux2_1_arch;

六十进制计数

entitycount_60is

port(clk:

qh:

bufferstd_logic_vector(3downto0);

ql:

co:

bufferstd_logic);

endcount_60;

architecturebehavofcount_60is

process(clk)

if(rising_edge(clk))then

if(qh="

0101"

andql="

1001"

qh<

="

0000"

co<

ql<

elsif(ql="

=qh+1;

=ql+1;

二十四进制计数

entitycount_24is

hh:

hl:

bufferstd_logic_vector(3downto0));

endcount_24;

architecturebehavofcount_24is

if(hh="

0010"

andhl="

0011"

hh<

hl<

elsif(hl="

=hh+1;

=hl+1;

计时校时仿真图如下

3、闹钟设置模块

entityclksetis

port(hh,hl,mh,ml,sh:

instd_logic_vector(3downto0);

nh,nm,ns,f4,k:

bhg,bhd,bmg,bmd,bsg,bsd:

comout:

endclkset;

architecturebehavofclksetis

com:

process(hh,mh,sh,hl,ml)

if(bhg=hhandbhd=hlandbmg=mhandbmd=mlandbsg=sh)then

comout<

set:

process(f4)

if(f4'

eventandf4='

if(nh='

andk='

if(bhg="

andbhd="

bhd<

bhg<

elsif(bhd="

=bhg+1;

elsif(bhd<

"

)then

=bhd+1;

if(nm='

if(bmg="

andbmd="

bmd<

bmg<

elsif(bmd="

=bmg+1;

elsif(bmd<

=bmd+1;

if(ns='

andk='

if(bsg="

andbsd="

bsd<

bsg<

elsif(bsd="

=bsg+1;

elsif(bsd<

=bsd+1;

4、选择显示控制模块

entitycompareis

port(hh,hl,mh,ml,sh,sl,bhg,bhd,bmg,bmd,bsg,bsd:

flashh,flashm,flashs,clk1,selct:

shh,shl,smh,line,sml,ssh,ssl:

outstd_logic_vector(3downto0));

endcompare;

architecturebehavofcompareis

line<

1010"

process(clk1)

ifselct='

then

ssl<

=sl;

ssh<

=sh;

sml<

=ml;

smh<

=mh;

shl<

=hl;

shh<

=hh;

elsifselct='

=bsd;

=bsg;

=bmd;

=bmg;

=bhd;

=bhg;

if(clk1='

andflashs='

1111"

andflashm='

andflashh='

endbehav;

5、整点报时及闹钟

entitybaoshiis

port(mh,ml,sh,sl:

comout,f1024hz,f512hz,clk:

bell:

endbaoshi;

architecturebehavofbaoshiis

process(clk,mh,ml,sh,sl,f1024hz,f512hz)

if(comout='

bell<

=clk;

elsif(mh="

andml="

)then

if(sh="

if(sl="

bell<

=f1024hz;

elsif(sl="

0001"

orsl="

0111"

=f512hz;

else

elsif(ml<

ormh<

orsh<

6、分频模块

entityfenpinis

port(clk:

f512,f4,f1:

endfenpin;

architecturefenoffenpinis

signalm:

std_logic_vector(9downto0);

if(clk'

ifm="

1111111111"

m<

0000000000"

m<

=m+'

f512<

=m(0);

f1<

=m(9);

f4<

=m(7);

endfen;

仿真图

7、动态显示模块

八选一

entitymux8_1is

port(D0,D1,D2,D3,D4,D5,D6,D7:

instd_logic_vector(2downto0);

Q:

outstd_logic_vector(3downto0));

endmux8_1;

architecturearchofmux8_1is

process(D0,D1,D2,D3,D4,D5,D6,D7,SEL)

caseselis

when"

000"

=>

Q<

=D0;

001"

=D1;

010"

=D2;

011"

=D3;

100"

=D4;

101"

=D5;

110"

=D6;

111"

=D7;

whenothers=>

XXXX"

endarch;

八进制计数器

数码管七段显示

entitydeledis

port(num:

instd_logic_vector(3downto0);

a,b,c,d,e,f,g:

outstd_logic);

enddeled;

architectureartofdeledis

signalled:

std_logic_vector(6downto0);

process(num)

casenumis

when"

=>

led<

1111110"

0110000"

1101101"

1111001"

0100"

0110011"

1011011"

0110"

1011111"

1110000"

1000"

1111111"

1111011"

0000000"

whenothers=>

0000001"

endcase;

a<

=led(6);

b<

=led(5);

c<

=led(4);

d<

=led(3);

e<

=led

(2);

f<

=led

(1);

g<

=led(0);

endart;

3-8译码器

entitydecode3_8is

port(a,b,c:

s1,s2,s3:

outstd_logic_vector(7downto0));

enddecode3_8;

architecturertlofdecode3_8is

signalind:

std_logic_vector(2downto0);

ind<

=c&

b&

a;

process(ind,s1,s2,s3)

if(s1='

ands2='

ands3='

caseindis

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

当前位置:首页 > 幼儿教育 > 少儿英语

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

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