模电课程设计数字钟Word格式文档下载.docx
《模电课程设计数字钟Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《模电课程设计数字钟Word格式文档下载.docx(14页珍藏版)》请在冰点文库上搜索。
当时钟时、分“走”到与上面设置的闹钟的时、分一致时,comout输出1,一分钟后时钟分与闹钟分不一致,comout输出0。
5).报时设置:
当时钟分位走到59,秒位走到51时,发出第一声512Hz响声,秒位走到53时,发出第二声512Hz响声,55第三声,57第四声,走到59秒时,发出1024Hz响声。
闹铃实现:
当comout输入为1时,发出1024Hz响声,当comout输入为0时,响声停止。
系统框图:
3、系统以及模块硬件电路设计
试验箱设备采用FLEX10K/EPF10K10L84-8(摸5)
说明:
1)、控制部分:
键8为时钟设置“时”的设置按键,键7为“分”的设置按键,键6为闹钟设置时和分的设置按键,键5为reset置零键,键4为时钟设置控制键,键3为闹钟设置控制键,键2为闹钟时和分设置的切换键。
2)、显示部分:
D8显示时钟“时”的高位,D7显示时钟“时”的低位,D6显示时钟“分”的高位,D5显示“分”低位,D4显示“秒”高位,D3显示“秒”低位,D2显示设置闹钟“时”或者“分”的高位,D1显示设置闹钟“时”或者“分”的低位。
3)、clk为时钟输入CLK,为1Hz,clk1024为闹铃和报时输入CLK,为1024Hz。
摸5时GW48结构图信号名:
下载时选择的开发系统模式以及管脚定义
接口名称
类型(输入/输出)
结构图上的信号名
引脚号
说明
clka
输入
PIO7
16
时间“时”设置
PIO6
11
时间“分”设置
sel
PIO3
8
时间设置控制
reset
PIO4
9
置0控制
setc
PIO2
7
闹钟设置控制
set1
PIO1
6
闹钟“时”“分”设置切换
f
PIO5
10
闹钟设置
clk
CLOCK0
2
时钟频率
clk1
CLOCK5
83
铃声频率
hh
输出
PIO47-PIO44
72、73、78、79
“时”高位
hl
PIO43-PIO40
66、67、70、71
“时”低位
mh
PIO39-PIO36
61、62、64、65
“分”高位
ml
PIO35-PIO32
54、58、59、60
“分”低位
sh
PIO31-PIO28
50、51、52、53
“秒”高位
sl
PIO27-PIO24
39、47、48、49
“秒“低位
high
PIO23-PIO20
35、36、37、38
闹钟“时”或“分”高位
low
PIO19-PIO16
27、28、29、30
闹钟“时”或“分”低位
bell
SPEAKER
3
闹铃和报时声音
引脚图
4、系统的VHDL设计
1)、分、秒模块(摸60计数器)
程序:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
useieee.std_logic_arith.all;
entitymunite_and_secondis
port(clk:
instd_logic;
reset:
instd_logic;
--置0设置
qh:
outstd_logic_vector(3downto0);
--“秒”或“分”高位
ql:
--“秒”或“分”低位
co:
outstd_logic);
--为下一个模块提供脉冲
endmunite_and_second;
architectureaofmunite_and_secondis
signalqqh,qql:
std_logic_vector(3downto0);
begin
process(clk)
begin
if(reset='
0'
)then
qqh<
="
0000"
;
qql<
elsif(clk'
eventandclk='
1'
if(qqh="
0101"
andqql="
1001"
qqh<
qql<
co<
='
elsif(qql="
qql<
qqh<
=qqh+1;
else
=qql+1;
endif;
endif;
endprocess;
qh<
=qqh;
ql<
=qql;
enda;
2)、小时模块(模24计数器)
程序:
entityhouris
hh:
hl:
outstd_logic_vector(3downto0));
endhour;
architectureaofhouris
signalhhh,hhl:
if(reset='
)then—置零设置
hhh<
hhl<
elsif(clk'
if(hhh="
0010"
andhhl="
0011"
hhh<
elsif(hhl="
hhl<
hhh<
=hhh+1;
else
=hhl+1;
endif;
hh<
=hhh;
hl<
=hhl;
3)、调时模块
entityadjustis
port(clka,d0,sel:
y:
endadjust;
architectureaofadjustis
process(clka,d0,sel)
if(sel='
)then—调时控制
y<
=clka;
--手动调时
else
=d0;
--时钟自动运行
记时调时电路图:
4)、闹钟设置模块
entityclksetis
port(hh,hl,mh,ml:
instd_logic_vector(3downto0);
setc,set1,f:
instd_logic;
bhg,bhd,bmg,bmd:
bufferstd_logic_vector(3downto0);
comout:
outstd_logic);
endclkset;
architecturebehavofclksetis
com:
process(hh,mh,hl,ml)
if(bhg=hhandbhd=hlandbmg=mhandbmd=ml)then
comout<
--时钟和设置的闹钟比较,输出值
else
endif;
endprocess;
set:
process(f)
if(f'
eventandf='
)then—手动对闹铃进行设定
if(setc='
andset1='
)then—选择设定闹钟“时”
if(bhg="
andbhd="
)then
bhd<
bhg<
elsif(bhd="
=bhg+1;
elsif(bhd<
"
)then
=bhd+1;
)then—手动设置闹钟
)then—选择设置闹钟“分”
if(bmg="
andbmd="
bmd<
bmg<
elsif(bmd="
=bmg+1;
elsif(bmd<
=bmd+1;
endbehav;
电路:
5)、显示模块
entityshowis
port(show1:
hh,hl,mh,ml:
instd_logic_vector(3downto0);
high,low:
outstd_logic_vector(3downto0));
end;
architectureaofshowis
process(show1)
begin
caseshow1is
when'
=>
high<
=hh;
low<
=hl;
--设置闹钟时选择显示“时”或“分”
whenothers=>
=mh;
=ml;
endcase;
6)、报时模块
entitybaoshiis
port(mh,ml,sh,sl:
f512hz,clk,comout:
bell:
endbaoshi;
architectureaofbaoshiis
process(clk,mh,ml,sh,sl,f512hz)
if(comout='
)then—闹铃控制
bell<
=clk;
elsif(mh="
andml="
)then
if(sh="
if(sl="
bell<
--当59分59秒时,报时频率为clk频率
elsif(sl="
0001"
orsl="
0111"
)then--当59分51、53、55、57秒时,报时频率为f512频率
=f512hz;
endif;
else
elsif(ml<
ormh<
orsh<
--当分钟小于59或者秒高位小于5时,不报时
6)、分频模块
entityfenpinis
f512:
endfenpin;
architectureaoffenpinis
signaltmp1:
std_logic;
if(clk'
tmp1<
=nottmp1;
--在上升沿时,temp1翻转
f512<
=tmp1;
总仿真结果:
5、结论以及结果说明
1)运行环境:
芯片名称:
FLEX10K/EPF10LC84-8
调试软件:
MAX+PLUSII10.2
参数选取:
CLOCK0=1Hz,CLOCK5=1kHz
2)运行结果:
当reset置0时,时钟时,分,秒全部置0,当reset置1时,时钟开始运行。
当时钟“走”到和设定闹钟一致时,喇叭发出声音,持续1分钟。
每当时钟分走到59,秒走到51时,喇叭发出一声低响,53秒、55秒、57秒均发出低响,到59秒时发出一声比较高的响声,所有5声均持续1秒。
运行良好。