




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
基于VHDL的电子表设计目录电子表的系统分析和设计计时器状态机闹钟寄存器4123电子表顶层电路的实现6铃声管理模块5电子表的系统分析和设计设计要求: 设计一个电子表,可以用于显示时间丶设定闹钟和整点报时。电子表的输入设备是一个4×4的编码键盘,输出设备是用于显示的6位LED数码管丶若干LED指示灯以及蜂鸣器。YourTextYourTextYourTextYourText电子表的系统分析和设计YourTextYourTextYourTextYourText闹钟时间寄存器计时器MUX
铃声管理系统结构和模块划分YourTextYourText状态机计时器分频器时间计数的频率为1Hz,而外部晶振频率为1MHz,所以需要1M分频计数器计数器时间计数器的目的是为了得到时间输出,因此需要每秒技术一次。状态机状态机模块是电子表的控制器,它给出其他模块的时序。状态机的输入信号是键盘模块的输出信号keyvalue,keypressed和functionkey。状态机的输出信号是缓存时间信号buffertime,闹钟时间加载信号alarmload,计时器时间加载信号timeload,闹钟开关状态alarmom和整点报时开关状态houralarmon。Time是由用户通过键盘输入的时间信号,可以送给闹钟寄存器和计时器。状态机包括两部分:1.用于产生缓存时间信号buffertime,闹钟时间加载信号alarmload和计时器时间加载信号timeload,称这部分状态机为校时和设闹状态机。2.用于产生闹钟开关状态信号alarmon和整点报时开关状态信号houralarmom,称为闹钟和整点报时开关状态机。闹钟寄存器闹钟寄存器是一个带有并行加载功能的寄存器。其中clk是全局时钟,buffertime是并行加载的数据输入,alarmload为并行加载的控制输入,alarmtime为寄存器的输出。TitleinhereTitleinhereTitleinhereTitleinhereABCD铃声管理模块闹钟铃声状态机Alarmtime=timeS0/0S4/1
S2/0
S1/0
S3/1Time(6)=‘1’Time(6)=‘0’Time(6)=‘1’Time(6)=‘0’alarmon=‘0’电子表顶层电路的实现闹钟和整点报时状态机校时和设闹状态机闹钟寄存器计时器校时和设闹输出闹铃管理模块ContentsContentsContentsContents顶层文件采用元件例化的方法将各个模块连接起来,组成电子表系统componentcounter port( clk,load:instd_logic; buffertime:instd_logic_vector(23downto0); time:outstd_logic_vector(23downto0) );endcomponent;componentalarmreg port( clk,alarmload:instd_logic; buffertime:instd_logic_vector(23downto0); alarmtime:outstd_logic_vector(23downto0) );endcomponent;componentbell port( clk,houralarmon,alarmon:instd_logic; alarmtime,time:instd_logic_vector(23downto0); alarm_signal:outstd_logic );endcomponent;signalbuffertime,time,alarmtime:std_logic_vector(23downto0);signaliscount,alarmload,timeload:std_logic;begin sm1:statemachine portmap(clk,keypressed,functionkey,keyvalue, iscount,alarmload,timeload,buffertime); sm2:statemachine2 portmap(clk,keypressed,keyvalue,alarmon,houralarmon); cnt:counter portmap(clk,timeload,buffertime,time); reg:alarmreg portmap(clk,alarmload,buffertime,alarmtime); bl:bell portmap(clk,houralarmon,alarmon,alarmtime,time,alarm_signal);
process(iscount,time,buffertime) begin if(iscount='1')then displaytime<=time; else displaytime<=buffertime; endif; endprocess;endrt;计数器程序(1)libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitycounteris port( clk,load:instd_logic; buffertime:instd_logic_vector(23downto0); time:outstd_logic_vector(23downto0) );endcounter;architecturertofcounteriscomponentdivider_1m port( clk:instd_logic; clk1s:outstd_logic );endcomponent;signalclk1s:std_logic;signaltime_sig:std_logic_vector(23downto0);begin
else time_sig(15downto12)<=time_sig(15downto12)+1;endif;else time_sig(11downto8)<=time_sig(11downto8)+1;endif;else time_sig(7downto4)<=time_sig(7downto4)+1;endif;elsetime_sig(3downto0)<=time_sig(3downto0)+1;endif;endif;endif;endif;endprocess; time<=time_sig;endrt;libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;entitydivider_1mis port( clk:instd_logic; clk1s:outstd_logic );enddivider_1m;architecturert1ofdivider_1missignalcnt:integerrange0to999999;begin process(clk) begin if(clk'eventandclk='1')then if(cnt=cnt'high)then cnt<=0; clk1s<='1'; else cnt<=cnt+1; clk1s<='0'; endif; endif; endprocess;endrt1;计数器程序(2)闹钟和整点报时libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;useieee.std_logic_unsigned.all;entitystatemachine2is port( clk,keypressed:instd_logic; keyvalue:instd_logic_vector(3downto0); alarmon,houralarmon:outstd_logic );endstatemachine2;architecturertofstatemachine2istypestateis(s_off,s_on);signalps_alarmon,ns_alarmon,ps_houralarmon,ns_houralarmon:state:=s_off;begin process(clk) begin if(clk'eventandclk='1')then ps_alarmon<=ns_alarmon; ps_houralarmon<=ns_houralarmon; endif; endprocess; process(ps_alarmon,keypressed,keyvalue)
process(ps_houralarmon,keypressed,keyvalue) begin if(ps_houralarmon=s_on)then if(keypressed='1'andkeyvalue="1100")then ns_houralarmon<=s_off; else ns_houralarmon<=ps_houralarmon; endif; houralarmon<='1'; else if(keypressed='1'andkeyvalue="1100")then ns_houralarmon<=s_on; else ns_houralarmon<=ps_houralarmon; endif; houralarmon<='0'; endif; endprocess;endrt;
闹钟寄存器libraryieee;useieee.std_logic_1164.all;entityalarmregis port( clk,alarmload:instd_logic; buffertime:instd_logic_vector(23downto0); alarmtime:outstd_logic_vector(23downto0) );endalarmreg;architecturertofalarmregisbegin process(clk) begin if(clk'eventandclk='1')then if(alarmload='1')then alarmtime<=buffertime; endif; endif; endprocess;endrt;铃声管理libraryieee;useieee.std_logic_1164.all;entitybellis port( alarmtime,time:instd_logic_vector(23downto0); alarmon,houralarmon,clk:instd_logic; alarm_signal:outstd_logic );endbell;architecturertofbellissignalalarm,houralarm:std_logic;typestateis(s0,s1,s2,s3,s4);signalpresent_state,next_state:state:=s0;begin process(clk,alarmon) begin if(alarmon='0')then present_state<=s0; elsif(clk'eventandclk='1')then present_state<=next_state; endif; endprocess;
whens4=>If(time(6)='0')thennext_state<=s0;elsenext_state<=present_state;endif;whenothers=>next_state<=s0;endcase;endprocess;process(present_state)beginif(present_state=s3orpresent_state=s4)thenalarm<='1';elsealarm<='0';endif;endprocess;process(houralarmon,time)beginif(houralarmon='1'andtime(15downto0)="00000")thenhouralarm<='1';elsehouralarm<='0';endif;endprocess;alarm_signal<=alarmorhouralarm;endrt;状态机libraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;entitystatemachineis port( clk,keypressed,functionkey:instd_logic; keyvalue:instd_logic_vector(3downto0); buffertime:bufferstd_logic_vector(23downto0); iscount,alarmload,timeload:outstd_logic );endstatemachine;whenmodifytime2=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andfunctionkey='0'and time_temp(23downto20)<="0001")then next_state<=modifytime3; time_temp(19downto16)<=keyvalue; elsif(keypressed='1'andkeyvalue<="0011"and time_temp(23downto20)<="0010")then next_state<=modifytime3; time_temp(19downto16)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whenmodifytime3=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andkeyvalue<="0101")then next_state<=modifytime4; time_temp(15downto12)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whenmodifytime4=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andfunctionkey='0')then next_state<=modifytime5; time_temp(11downto8)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whenmodifytime5=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andkeyvalue<="0101")then next_state<=modifytime6; time_temp(7downto4)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whenmodifytime6=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andfunctionkey='0')then next_state<=modifytime7; time_temp(3downto0)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whenmodifytime7=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andkeyvalue<="1010")then next_state<=loadtime;
else next_state<=present_state;
endif; time_temp<=time_temp;whenloadtime=> next_state<=count; time_temp<=time_temp;whensetalarm1=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andkeyvalue<="0010")then next_state<=setalarm2; time_temp(23downto20)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whensetalarm2=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andfunctionkey='0'and time_temp(23downto20)<="0001")then next_state<=setalarm3; time_temp(19downto16)<=keyvalue; elsif(keypressed='1'andkeyvalue<="0011"and time_temp(23downto20)<="0010")then next_state<=setalarm3; time_temp(19downto16)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whensetalarm3=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andkeyvalue<="0101")then next_state<=setalarm4; time_temp(15downto12)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whensetalarm4=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andfunctionkey='0')then next_state<=setalarm5; time_temp(11downto8)<=keyvalue; else next_state<=present_state; time_temp<=time_temp; endif;whensetalarm5=> if(keypressed='1'andkeyvalue="1011")then next_state<=count; elsif(keypressed='1'andkeyvalue<="0101")then next_state<=setalarm6; time_temp(7downt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 兽医急救药品使用试题及答案
- 气象灾害的应对与预防策略试题及答案
- 投资咨询工程师投资策略试题及答案
- 如何做点名课件
- 创业低成本项目案例分享
- 劳动教育的意义与实施
- 人力资源管理师考试的模拟试题及答案
- 医院急诊部的工作效率提升计划
- 应对工作中突发事件的预案计划
- 提升班级艺术活动参与度的策略计划
- 企业廉洁风险防控课件教学
- 中医护理三基练习题库+答案
- 火龙罐综合灸疗法
- 形势与政策(吉林大学)智慧树知到答案章节测试2023年
- 用户中心积分成长值体系需求文档
- 2021商超全年52周企划MD营销销售计划培训课件-96P
- 劳务派遣用工管理办法
- 初中数学人教七年级下册第七章 平面直角坐标系 平面直角坐标系中图形面积的求法PPT
- 颊癌病人的护理查房
- 特种设备使用登记表(范本)
- YSJ 007-1990 有色金属选矿厂 试验室、化验室及技术检查站工艺设计标准(试行)(附条文说明)
评论
0/150
提交评论