欢迎来到天天文库
浏览记录
ID:8526092
大小:113.00 KB
页数:10页
时间:2018-03-31
《基于quartusⅱ的vhdl语言多功能数字钟》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、基于QuartusⅡ的VHDL语言多功能数字钟注:任何人不得作为商业用途数字钟的功能1)以24小时制显示时、分、秒计数;2)时间清零,时设置,分设置功能;3)整点报时功能。实验环境1.软件环境:QuartusII7.22.硬件环境:MAXII-EPM240T100C51.分频器1KHz分频器VHDL:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityFPQ1Kisport(clk:instd_logic;q1khz:outstd_logic);end;ar
2、chitecturebehavofFPQ1Kisbegins1:process(clk)variablecount2:integerrange0to50000;beginif(clk='1'andclk'event)thencount2:=count2+1;if(count2=25000)thenq1khz<='1';elsif(count2=50000)thenq1khz<='0';count2:=0;endif;endif;endprocess;ENDbehav;1KHz分频器顶层设计原理图1Hz分频器VHDL:libraryieee;useieee.
3、std_logic_1164.all;useieee.std_logic_unsigned.all;entityFPQ1isport(clk:instd_logic;q1hz:outstd_logic);end;architecturebehavofFPQ1isbegins1:process(clk)variablecount2:integerrange0to1000;beginif(clk='1'andclk'event)thencount2:=count2+1;if(count2=500)thenq1hz<='1';elsif(count2=1000)
4、thenq1hz<='0';count2:=0;endif;endif;endprocess;ENDbehav;1Hz分频器顶层设计原理图2.秒模块设计libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitySecisport(clk,reset,min_set:instd_logic;--clk为1Hz的秒脉冲输入信号,reset为秒清零(复位)信号--min_set为分钟调整enmin:outstd_logic;--enmin为秒模块进位输出daout:ou
5、tstd_logic_vector(6downto0));--2n-1≥60,n=7,27=64,分钟用7位二进制数表示--daout(6..4)为十位,daout(3..0)为个位,60循环计数endentitySec;architecturebehaveofSecissignalcount:std_logic_vector(6downto0);--定义内部计数节点,60循环计数signalenmin1,enmin2:std_logic;--enmin为60秒产生的进位,enmin2为调分键产生的向分模块的进位begindaout<=count;enmi
6、n2<=(min_setandclk);enmin<=(enmin1orenmin2);--60秒钟到和调分键均向分模块产生进位脉冲process(clk,reset,min_set)beginif(reset='0')thencount<="";--检测秒模块的1Hz脉冲上升沿elsif(clk'eventandclk='1')thenif(count(3downto0)="1001")then--秒的个位是否到“9”ifcount(6downto4)="101"then--秒各位到“9”后,十位计数到“5”enmin1<='1';--秒模块的60秒进位
7、输出enmin置“1”,向分模块产生进位count<="";--秒计数值“”(零秒)elsecount<=count+7;--秒各位到“9”后,十位计数没到“5”,则加“7”变为“0”,同时向十位进位endif;elsecount<=count+1;--秒个位没计到“9”时,秒计数值加“1”enmin1<='0';--秒模块的60秒进位输出enmin1置“0”,不向分模块进位endif;endif;endprocess;endbehave;秒模块顶层设计原理图3.分模块设计LIBRARYieee;useieee.std_logic_1164.all;use
8、ieee.std_logic_unsigned.all;ENTIT
此文档下载收益归作者所有