资源描述:
《基于FPGA数字时钟》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、........基于FPGA的数字时钟设计一、课程设计目的1、进一步熟悉QuartusⅡ的软件使用方法;2、熟悉可编程逻辑器件的开发流程及硬件测试方法;3、熟悉基于FPGA的综合数字系统设计方法;二、设计任务设计一台可以显示时、分、秒的数字钟。如图1所示为基于FPGA的数字钟设计的系统框图。图1数字钟系统三、设计要求1、能直接显示小时、分、秒,其中小时为以二十四为计数周期;2、能够显示日期(即年、月、日),且要求在显示时钟的数码管上显示日期,即时钟数码管与日期数码管复用;3、年、月、日要严格按照实际日期,例如1月3
2、1天,4月30天,2月闰年29天等;4、当数字钟发生走时错误时,要求电路有校时功能,可以对时、分单独校正,且校正时间时系统时钟不工作;5、当日期发生错误时,要求有校正日期功能,可以对年、月、日单独校正,且矫正日期时时钟系统仍然工作;6、.专业学习资料.........具有闹钟功能,即输入想要定时的时间,当时钟到达该时间时报警,系统可由灯亮代表报警信号。一、设计内容1、时间计数模块本次是将秒分时各个模块分开进行设计,用秒的进位作为分模块的脉冲,用分的进位作为是模块的脉冲。秒进位的仿真波形程序:秒的程序.专业学习资料.
3、........modulemiao(clk,gdata,ddata,en,cl,clr);inputclk;inputen;inputclr;output[3:0]ddata;output[3:0]gdata;outputcl;reg[7:0]q;regcl;assignddata=q%10;assigngdata=q/10;always@(negedgeclkorposedgeclr)beginif(clr==1)q=0;elsebeginif(en==1)beginif(q<59)begin.专业学习资料..
4、.......q=q+1;cl=0;endelsebeginq=0;cl=1;endendendendendmodule分模块和时模块的程序一秒程序类似,只是进位计数不一样。2、日期模块.专业学习资料.........与时间模块一样,用低的进位作为高的脉冲。日的仿真波形日模块程序.专业学习资料.........moduleri(nian,yue,shi,gdata,ddata,en,cl,clr);inputshi;inputen;input[3:0]yue;inputclr;input[15:0]nian;out
5、put[3:0]ddata;output[3:0]gdata;outputcl;reg[7:0]q;regcl;reg[7:0]r;assignddata=(q+1)%10;assigngdata=(q+1)/10;always@(posedgeshiorposedgeclr)beginif(clr==1)q=0;elseif(en==1)begincl=0;.专业学习资料.........if(yue==2)beginif((nian%400)==0)r=29;elseif((nian%4)==0)beginif
6、((nian%100)!=0)r=29;elser=28;endelser=28;endelsebegincase(yue)1:r=31;3:r=31;4:r=30;5:r=31;6:r=30;7:r=31;8:r=31;.专业学习资料.........9:r=30;10:r=31;11:r=30;12:r=31;endcaseendif(shi==1)beginif(q<(r-1))beginq=q+1;endelsebeginq=0;cl=1;end.专业学习资料.........endendendendmod
7、ule改程序可以判断闰年还是平年,大月还是小月。月模块的程序:moduleyue(ri,gdata,ddata,en,cl,clr,oyue);inputri;inputen;inputclr;output[3:0]ddata;output[3:0]gdata;outputcl;output[3:0]oyue;reg[3:0]oyue;reg[3:0]q;regcl;assignddata=(q+1)%10;assigngdata=(q+1)/10;.专业学习资料.........always@(posedgeri
8、orposedgeclr)beginif(clr==1)q=0;elsebeginif(en==1)begincl=0;if(ri==1)beginif(q<11)beginq=q+1;oyue=q+1;endelsebeginq=0;.专业学习资料.........cl=1;endendendendendendmodule年模块的程序:modulenian