基于FPGA的语音数字时钟系统.docx

上传人:b****2 文档编号:17495366 上传时间:2023-07-26 格式:DOCX 页数:19 大小:20.65KB
下载 相关 举报
基于FPGA的语音数字时钟系统.docx_第1页
第1页 / 共19页
基于FPGA的语音数字时钟系统.docx_第2页
第2页 / 共19页
基于FPGA的语音数字时钟系统.docx_第3页
第3页 / 共19页
基于FPGA的语音数字时钟系统.docx_第4页
第4页 / 共19页
基于FPGA的语音数字时钟系统.docx_第5页
第5页 / 共19页
基于FPGA的语音数字时钟系统.docx_第6页
第6页 / 共19页
基于FPGA的语音数字时钟系统.docx_第7页
第7页 / 共19页
基于FPGA的语音数字时钟系统.docx_第8页
第8页 / 共19页
基于FPGA的语音数字时钟系统.docx_第9页
第9页 / 共19页
基于FPGA的语音数字时钟系统.docx_第10页
第10页 / 共19页
基于FPGA的语音数字时钟系统.docx_第11页
第11页 / 共19页
基于FPGA的语音数字时钟系统.docx_第12页
第12页 / 共19页
基于FPGA的语音数字时钟系统.docx_第13页
第13页 / 共19页
基于FPGA的语音数字时钟系统.docx_第14页
第14页 / 共19页
基于FPGA的语音数字时钟系统.docx_第15页
第15页 / 共19页
基于FPGA的语音数字时钟系统.docx_第16页
第16页 / 共19页
基于FPGA的语音数字时钟系统.docx_第17页
第17页 / 共19页
基于FPGA的语音数字时钟系统.docx_第18页
第18页 / 共19页
基于FPGA的语音数字时钟系统.docx_第19页
第19页 / 共19页
亲,该文档总共19页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

基于FPGA的语音数字时钟系统.docx

《基于FPGA的语音数字时钟系统.docx》由会员分享,可在线阅读,更多相关《基于FPGA的语音数字时钟系统.docx(19页珍藏版)》请在冰点文库上搜索。

基于FPGA的语音数字时钟系统.docx

基于FPGA的语音数字时钟系统

基于FPGA的语音数字时钟系统设计

1.设计要求:

(1)计时功能:

这是这个计时器设计的基本功能,每隔一分钟记一次时间并在屏幕上显示出当前时间。

⑵闹钟功能:

如果当前时间与设置的闹钟时间相同,贝y扬声器会发出报时声音。

⑶设置新的计时器时间:

用户用数字键0~9输入新的时间,然后按

下TIME健确认。

⑷设置新的闹钟时间:

用户用数字键0~9输入新的闹钟时间,然后按下ALARM健确认。

(5)显示所设置的闹钟时间:

在正常记时显示状态下,用户直接按下ALARM健,则显示器上显示已经设置好的闹钟时间。

2.设计思路:

控制器命名为Alarm_controller,外部端口

4

Alarm-Controller*1

KeyLoadnew

AlarmbottonLoadnewo

TimebottonShownewtime*1

r

k

r

r

*

ClkShow

reset+J

Jr-

k

各个端口定义:

(1)Clk外部时钟信号

⑵Reset复位信号

⑶Alarm_botton闹钟信号,当其为高电平时,表示用户按下

⑷Time_botton时间信号,当其为高电平时,表示用户按下

(5)Key键盘信号,当其为高电平时,表示用户按下0~9

(6)Load_new_a读取新的闹钟时间,高电平有效

⑺Load_new_c控制设置新的时间,高电平有效

(8)Show_new_time读取并显示新的时间,高电平有效

(9)Show_a当Show_new_time为低电平时,根据Show_a控制当前是

显示闹钟时间还是时钟时间

根据端口的设置以及控制要求,设定如下5个状态

SO:

闹钟正常计数状态

S1:

键盘输入状态,当用户按下键盘,即进入此状态,当一段时间后

用户没有按下Alarm或者Time确认,则自动返回S0状态

S2:

设定闹钟状态,当用户按完键盘,按下Alarm键时进入此状态

S3:

设定时间状态,当用户按完键盘,按下Time键时进入此状态

S4:

显示闹钟时间,当用户直接按下Alarm键时,进入此状态

在S4状态下,用户按下Alarm键时钟即显示闹钟时间,经过一段延时之后,时钟从新恢复S0状态。

以下是程序流程表

当前状态

控制输入

下一状态

控制输出

S0

Key='''

S1

Shownewtime<=1

Alarmbotton=''

S2

Showa<='''

else

S0

Null

Key='''

S1

Shownewtime<=1

Alarmbotton=''

S2

Loadnewa<=T

S1

Timebotton=''

S3

Loadnewc<=''

超时

S0

Null

S1

Show_new_time<=''

S2

Alarmbotton=''

S2

Loadnewa<=''

else

S0

Null

S3

Timebotton=''

S3

Loadnewc<=''

else

S0

Null

S4

Alarmbotton=''

S4

Showa

超时

S0

Null

S4

Showa并等待

程序:

程序包P_alarm圭寸装定义

libraryIEEE;

uselEEE.std_logic_1164.all;

packageP_alarmis

subtypet_digitalisintegerrange0to7;

subtypet_shortisintegerrange0to65535;

typet_clock_timeisarray(3downto0)ofT_digital;

typet_displayisarray(3downto0)ofStd_logic_vector(6downto0);

typeseg7isarray(0to7)ofStd_logic_vector(6downto0);

constantSeven_seg:

seg7:

=("0000000001",--0

"0000000010",--1"0000000100",--2

"0000001000",--3"0000010000",--4

"0000100000",--5"0001000000",--6

"0010000000",--7"0100000000",--8"1000000000",--9);

endpackageP_alarm;-程序包体圭寸装结束

libraryIEEE;

useIEEE.std_logic_1164.all;

useWORK.P_alarm.all;

ENTITYAlarm_contorlleris

port(Key,Alarm_botton,Time_botton,clk,reset:

instd_logic;

Load_new_a,Load_new_c,Show_new_time,Show_a:

out

std_logic);

endAlarm_controller;

ARCHITECTUREartofAlarm_controlleris

typet_stateis(s0,s1,s2,s3,s4);--5种工作状态

constantkey_timeout:

t_short:

=900;--键盘延时时间

constantshow_alarm_timeout:

t_short:

=900;--alarmjianyanshi900ns

signalcurr_state:

t_state;--zhuangtaijidangqianzhuangtaiwei

signalnext_state:

t_state;--zhuangtaijixiayigongzuowei

signalcounter_k:

t_state;--jianpan

signalenable_count_k:

std_logic;--jianpanchaoshiyunxu

signalcount_k_end:

std_logic;--jianpanchaoshi

signalcounter_a:

t_short;--alarmjian

signalenable_count_a:

std_logic;--alarmjianchaoshiyunxu

signalcount_a_end:

std_logic;--alarmjianchaoshijieshu

begin

p0:

process(clk,reset)

begin

ifreset='1'then

curr_state<=s0;

elsifrising_edge(clk)then

curr_state<=next_state;

endif;

endprocess;

p1:

process(Key,Alarm_botton,Time_botton,curr_state,count_a_end,count_k_end)

begin--geigegeshuchufuchushizhi

next_state<=curr_state;

load_new_a<='0';

load_new_c<='0';

show_a<='0';

show_new_time<='0';

enable_count_k<='0';

enable_count_a<='0';

casecurr_stateis

whens0=>

if(Key='1')thennext_state<=s1;

Show_new_time<='1';

elsif(Alarm_botton<='1')thennext_state<=s2;

Show_a<='1';

else

next_state<=s0;

null;

endif;

whens1=>

if(key='1')then

next_state<=s1;

Show_new_time<='1';

elsif(Alarm_botton<='1')thennext_state<=s2;

Load_new_a<='1';

elsif(Time_botton<='1')thennext_state<=s3;

Load_new_c<='1';

if(count_k_end='1')thennext_state<=s0;

null;

elsenext_state<=s1;

Show_new_time<='1';

endif;enable_count_k<='1';

endif;

whens2=>

if(Alarm_botton<='1')thennext_state<=s2;Load_new_a<='1';

else

next_state<=s0;

null;

endif;

whens3=>

if(Time_botton<='1')thennext_state<=s3;Load_new_c<='1';

next_state<=s0;

null;

endif;

whens4=>

if(Alarm_botton<='1')thennext_state<=s4;

elseif(count_a_end='1')thennext_state<=s0;

null;

else

next_state<=s4;

Show_a<='1';

endif;

enable_count_a<='1';

endif;

whenothers=>

null;

endcase;

endprocess;

Count_key:

process(Enable_count_k,clk)

begin

if(Enable_count_k<='0')then

Counter_k<='0';count_k_end<='0';

elsif(rising_edge(clk))thenif(counter_k>=key_tinmeout)thencount_k_end='1';

else

counter_k<=Counter_k+1;

endif;

endif;

endprocessCount_key;

Count_alarm:

process(Enable_count_a,clk)

begin

if(enable_count_a<='1')then

counter_a<='0';

count_a_end<='0';

elsif(rising_edge(clk))then

if(counter_a>=show_alarm_timeout)thencount_a_end<='1';

else

counter_a<=counter_a+1;

endif;

endif;

endprocessCount_alarm;

endart;

二.闹钟系统译码器设计

1•设计思路:

每次按下闹钟系统的数字键盘后产生一个数字所对应的

10位二进制数据信号转换为1位十进制整数信号,作为小时,分钟计数的4个数字之一。

结构图

Decoder

Keypad

valuer

输入

0000000001

0000000010

0000000100

0000001000

0000010000

输出

0

1

2

3

4

输入

0000100000

0001000000

0010000000

010*******

1000000000

输出

5

6

7

8

9

libraryIEEE;

uselEEE.std_logic_1164.all;

useWORK.P_alarm.all;

ENTITYdecoderisport(keypad:

instd_logic_vector(9downto0);

value:

outT_digital);

enddecoder;

ARCHITECTUREartofdecoderis

begin

withkeypadselect

value<=0when"0000000001",

1when"0000000010",

2when"0000000100",

3when"0000001000",

4when"0000010000",

5when"0000100000",

6when"0001000000",

7when"0010000000",

8when"0100000000",

9when"1000000000",

0whenothers;

endart;

三.闹钟系统的移位寄存器的设计

1.设计思路:

在clk的上升沿同步下,将key端口的输入信号移入new_time端口的输出端口最低位,原有信息一次向左移动,最高位舍去,reset对输出端口new_time异步清零。

电路原理图

bfFVjJ

-*

CLK*J

RESET

NEWTIMEQ

libraryIEEE;

uselEEE.std_logic_1164.all;

useWORK.P_alarm.all;

ENTITYkey_bufferis

port(key:

int_digital;

clk,reset:

instd」ogic;

new_time:

outt_clock_time);

endkey_buffer;

ARCHITECTUREartofkey_bufferis

signaln_t:

t_clock_time;

process(clk,reset)

begin

if(reset<='1')then

n_t<=(0,0,0,0);

elsif(rising_edge(clk))then

foriin3downto1loop--zuohuanyi

n_t(i)<=n_t(i-1);

endloop;

n_t(O)<=key;

endif;

endprocess;

new_time<=n_t;

endart;

四.闹钟寄存器的设计

1•设计思路:

闹钟寄存器在时钟上升沿同步下,根据Load_new_a端

口的输入信号控制Alarm_time口的输出,当控制信号为高电平时,把New_alarm_time端口的赋给alarm_time然后输出,reset端口输入信号对alarm_time端口的输出进行异步清零复位。

电路原理图

Ifc-

Loadnewa*

IF

Newalarmtime+J

Clk+-'

Reset

Alarrvii+im—1

hj口in11%11rItr*-

libraryIEEE;

uselEEE.std_logic_1164.all;

useWORK.P_alarm.all;

ENTITYAlarm_regisport(clk,reset:

instd_logic;

new_alarm_time:

int_clock_time;

load_new_a:

instd_logic;

alarm_time:

outstd_logic);

ARCHITECTUREartofAlarm_regis

begin

process(clk,reset)

begin

if(reset='1')thenalarm_clock<=(0,0,0,0);

else

ifrising_edge(clk)then

ifload_new_a='1'then

alarm_time<=new_alarm_time;

elsifload_new_a='0'then

assertfalsereport"uncertainload_new_alarmcontrol"

severitywarning

endif;

endif;

endif;

endprocess;

endart;

五.时间计数器的设计

1.设计思路:

时间计数器在时钟上升沿同步下,根据load_new_c端口的输入控制信号控制current_time口的输出,当控制信号为高电平时,把newcurrenttime端口的值赋给currenttime进行输出。

当reset

端口为高电平时,对current_time端口进行清零操作。

Reset的优先

级高于load_new_c且当reset,load_new_c同时为低电平时,在时钟上

升沿处,对current_time端口输出信号进行累加一次加1,并根据小时,分钟的进位规律进位。

Alarm_counter

Loadnewc+j

r>l€\v匚urrent:

ime^

I■i■u>i■u

elk-1

Currenttime-

Reset

libraryIEEE;

useIEEE.std_logic_1164.all;

useWORK.P_alarm.all;

ENTITYAlarm_counterisport(load_new_c:

instd_logic;

clk,reset:

instd」ogic;

new_current_time:

int_clock_time;

current_time:

outt_clock_time);

endAlarm_counter;

ARCHITECTUREartofAlarm_counteris

signali_current_time:

t_clock_time;

begin

process(clk,reset)

variablec_t:

t_clock_time;

ifreset='1'then

i_current_time<=(0,0,0,0);

elsifload_new_c<='1'then

i_current_time<=new_current_time;

elsifrising_edge(clk)then

ifc_t(0)<=9then

c_t(0):

=c_t(0)+1;

else

c_t(0):

=0;

ifc_t

(1)<6then

c_t

(1):

=c_t

(1)+1;

else

c_t

(1):

=0;

ifc_t(3)<2then

ifc_t

(2)<=9then

c_t

(2):

=c_t

(2)+1;

else

c_t

(2):

=0;

c_t(3):

=c_t(3)+1;

endif;

elsec_t

(2)<3then

c_t

(2):

=c_t

(2)+1;

else

c_t

(2):

=0;

c_t(3):

=0;

endif;

endif;

endif;

endif;

i_current_time<=c_t;

endif;

endprocess;

current_time<=i_current_time;

endart;

六.闹钟系统显示驱动器

1.设计思路:

当show_new_time输入为高电平时,根据new_time端口输入的时间数据,产生相应的4个七段数码显示器的驱动数据,并在display端口输出该信号;当show_new_time为低电平时,判断show_a端口的输入电平,如果为高电平,则根据alarm_time端口输入的时间数据,产生相应的4个七段数码显示器的驱动数据,并也在display端口输出。

若show_a也为低电平,根据current_time端口的输入信号,对display端口驱动。

当alarm_time端口的输入信号值与current_time端口的输入信号值相同时,sound_alarm端口的输出信

号有效。

反之无效

Display_driver

Newtim臼

Display*

Soundalarm*

Currenttime

Alarmtime

V^^VV^ri"i».V^VV,¥,¥

Shownewtimz

11il■u

Showa

libraryIEEE;

uselEEE.std_logic_1164.all;

useWORK.P_alarm.all;

ENTITYdisplay_driveris

port(new_time:

int_clock_time;

current_time:

int_clock_time;alarm_time:

int_clock_time;show_new_time:

instd_logic;show_a:

instd_logic;display:

outt_display;

sound_alarm:

outstd_logic);

enddisplay_driver;

ARCHITECTUREartofdisplay_driverissignaldisplay_time:

t_clock_time;

beginprocess(new_time,alarm_time,current_time,show_new_time,show_a)begin

sound_loop:

foriinalarm_time'rangeloopif(current_time(i)=alarm_time(i))thensound_alarm<='1';

else

sound_alarm<='0';

endif;

endloopsound_loop;

ifshow_new_time<='1'then

display_time<=new_time;

elsifshow_a<='1'then

display_time<=alarm_time;

elsifshow_a<='0'then

display_time<=current_time;

else

assertfalsereport"uncertaindisplay_drivercontrol!

"

severitywaring;

endif;

endprocess;

disp:

process(display_time)

beginforiindisplay_time'rangeloop

display(i)v=seven_seg(display_time(i))

endloop;

endprocess;

endart;

七.闹钟分

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

当前位置:首页 > IT计算机

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2