基于fpga的LCD显示万年历..

合集下载

【优秀WORD论文】基于FPGA的全功能万年历电子钟的设计

【优秀WORD论文】基于FPGA的全功能万年历电子钟的设计

基于FPGA的全功能万年历电子钟的设计提要本文主要介绍了基于FPGA的万年历电子钟的设计方案,从而介绍了可编程逻辑器件的发展及应用。

基于FPGA的电子钟的设计与实现介绍了基于FPGA芯片的系统设计,并对系统的软硬件构成、FPGA内部逻辑设计工作原理等进行了详细说明。

论文第一部分对FPGA进行概述,讲述了可编程逻辑器件的发展与应用及论文题目的意义、目的和内容编排;第二部分:叙述了系统设计方案,介绍了FPGA应用的特点和电子钟的方案概述及实现语言和调试平台MAX+plusⅡ开发工具;第三部分:叙述了基于FPGA的电子钟系统的设计的硬件设计和软件设计;第四部分:对系统实现的外围电路进行概述。

第五部分:再次说明本设计的系统方案和得到的结论。

目录第一章序论 (1)1.1研究目的和意义: (1)1.2可编程逻辑器件的发展与应用: (1)1.2.1可编程逻辑单元CLB (3)1.2.2输入/输出模块IOB (3)1.2.3可编程内部连线PI (4)1.2.4 FPGA芯片的特点 (4)1.3FPGA国内外的发展状况及应用 (5)1.4本课题所能实现的功能: (8)第二章总体方案的设计 (9)2.1万年历电子钟的设计原理: (9)2.2FPGA的设计方法 (11)2.2.1 FPGA的器件设计流程 (11)2.2.2 MAX+plusⅡ开发工具 (13)2.2.3 VHDL语言 (17)2.3系统设计方案 (18)第三章系统的硬件设计与实现 (19)3.1功能模块设计 (19)3.2系统功能实现 (21)3.2.1底层元件设计 (22)3.2.2顶层元件设计 (32)3.3芯片的选择 (41)第四章设计应用电路 (45)4.1整体电路 (45)4.2电源电路 (46)4.3键盘部分 (49)4.4主动配置电路 (53)第五章总结 (61)5.1概述: (61)5.2设计方案: (62)参考文献 (64)致谢 (67)摘要 (I)ABSTRACT (II)第一章序论1.1研究目的和意义:通过对FPGA的了解,我们要应用FPGA来设计全功能万年历的设计,主要实现电子钟的所有功能,万年历是一种应用非常广泛的日常计时工具,具有时分秒计时功能,还有日历、年历功能,涉及计数、显示、参数输入技术,能够实时显示年、月、日和时间,并具有校准和闹铃等功能。

基于FPGA的液晶电子日历

基于FPGA的液晶电子日历

2021/8/6
13
十、展望
1.代码的优化 2.本设计没有闹铃功能,可以加入闹铃功
能 3.本设计的计数时钟是通过系统时钟分频
得到,不够精确所以可以用专门的时钟芯 片如ds1302来进行时间的计数,然后用 fpga读取数据,处理在液晶屏上显示
2021/8/6
14
1.引脚配置如图所示主要包括时钟端口 (50M),4个按键,蜂鸣器和液晶的端口
2021/8/6
11
八、设计实况
1.主要功能基本实现,包括显示,可调, 润/平年判断,倒计时功能
2.存在的问题 (1)调整时选择位跳动不规律 (2)因为计数时钟是通过系统时钟分频得
到,所以时钟走的不怎么精确。 (3)部分代码存在问题 (4)仿真波形没出来
度最弱,接地电源时对比度最高,对比度过高时会产生 “鬼影”,使用时可以通过一个10K的电位器调整对比度 第4脚:RS为寄存器选择,高电平时选择数据寄存器、低 电平时选择指令寄存器。
第5脚:R/W为读写信号线,高电平时进行读操作,低电 平时进行写操作。当RS和RW共同为低电平时可以写入指 令或者显示地址,当RS为低电平RW为高电平时可以读忙 信号,当RS为高电平RW为低电平时可以写入数据。
基于FPGA的液晶电子日 历
2021/8/6
1
电子信息工程A1121
许江南
江晓东
2021/8/6
2
一、设计功能
1.在试验箱上的1602液晶显示屏显示
2.具有基本的显示功能,能显示秒,分, 时,星期,天,月,年
3.时间显示位12进制,能显示上下午。
4.具有闰年/平年判断功能
5.具有可调功能,能对分,时,星期,天, 月 ,年分别调整。

基于FPGA的多功能电子万年历

基于FPGA的多功能电子万年历

论文题目:基于FPGA的多功能电子万年历专业:电子信息工程学生:周勉签名:_______指导老师:王静签名:_______摘要多功能电子万年历能够显示年、月、日、星期、时、分、秒,能够全面的提供时间信息并能独立校对,还具有整点报时以及闹钟功能,具有功能全面、计时准确、使用方便等优点,电子万年历在家庭日常生活中已逐渐成为最主要的计时产品。

本文重点介绍了基于FPGA的多功能电子万年历的功能及实现。

本设计通过利用QUARTUS II软件来设计实现,使用verilog HDL语言进行编程设计。

论文主要对计年、计月、计日、计星期、计时、计分、计秒、整点报时以及闹钟等关键模块的设计及仿真分析进行了介绍。

此外。

基于开发板进行了下载测试,多种功能的测试结果表明了本设计的正确性。

【关键词】FPGA,QUARTUS II,verilog HDL,万年历【论文类型】应用型Title: Multi function electronic calendar based on FPGAMajor: Electronic Information EngineeringName:Mian Zhou Signature :_______ Supervisor: Jing Wang Signature :_______ABSTRACTMulti function electronic calendar can display year, month, day, week, hours, minutes and seconds, time can provide comprehensive information and independent proof, also with the whole point timekeeping, alarm clock function, has the function of comprehensive, accurate timing, convenient use, electronic calendar in daily life at home has gradually become the main the timing of product.This paper focuses on the function and implementation of multi-functional electronic calendar based on FPGA. The design through the use of QUARTUS II software design and implementation, using Verilog HDL programming language design. The paper mainly introduces the design and simulation analysis of the key modules such as year, month, day, week, time, score, seconds, clock, alarm clock and so on. Besides. The download test is carried out based on the development board, and the test results of several functions show the correctness of the design.【Key words】FPGA,QUARTUS II,verilog HDL,calendar【Type of Thesis】Applied目录摘要 (I)ABSTRACT (II)目录 (III)1 绪论 (1)1.1课题研究背景 (1)1.2 EDA及FPGA技术介绍 (1)1.2.1 EDA 技术介绍及现状 (1)1.2.2 FPGA技术简介 (2)1.3 Quartus II开发环境概述 (3)1.4 硬件描述语言Verilog HDL简介 (3)1.5论文内容简介 (4)2 多功能电子万年历的总体设计方案 (5)2.1系统主要功能 (5)2.2 系统设计方案与步骤 (5)2.3主要器件 (6)2.4系统整体框图 (8)3 各模块设计方案与波形仿真 (9)3.1 分频器模块 (9)3.2 时分秒模块 (9)3.3 年月日星期模块 (10)3.4 闹钟模块 (11)3.5蜂鸣器模块 (13)3.6 主控制模块 (13)3.7校时选择模块 (14)3.8 显示选择模块 (15)3.9 数码管显示模块 (16)4 硬件检测及调试 (17)总结与展望 (21)致谢 (22)附录 (23)参考文献 (36)1 绪论1.1课题研究背景进入21世纪以来,电子技术在人们的日常生活、生产中,扮演着越来越重要的角色。

【2019年整理】基于FPGA的日历、时间、闹铃系统

【2019年整理】基于FPGA的日历、时间、闹铃系统

基于FPGA的日历、时间、闹铃系统前言:由于本人刚刚入门,只用了最基本的设计思维,所以可能浪费了许多芯片资源,要是哪位高手能帮忙把系统优本人定然感激不尽。

系统功能:显示当前日期,时间,到点报时。

可通过按键来调整日期时间,并且设置闹铃时间,闹铃响后,必须手动模块说明:系统的顶层模块如下图所示,该系统由六个模块组成,分别为分频模块,按键模块,计数模块,LCD液晶除法器模块,以及铃声模块。

皆为可综合模块,可综合为门级网表,并在FPG必片上验证了其正确性。

由于涉及版严禁用于商业目的,违者必究!按键示意图:l|hhpljM—■;~~L H—*gMdJL I M■dqK- i Ji;I .At1,、分频器: module div_1hz(clk,clock);output reg clock;input clk;// 外部50MHZ寸钟输入reg[24:0] i;always@(posedge clk)begini=i+1;if(i==25'h17d7840)begin i=0;clock=~clock; // 产生1HZ频率信号。

endendendmodule 2、按键模块: modulekey(num,keyout,targe,keyout_en,keyin,rst,clk);output reg [3:0] keyout;output [3:0] num;output targe;output reg keyout_en; input rst,clk; input [3:0]keyin; reg [7:0] i; reg [3:0] num; reg [23:0] count; reg [5:0] state,next_state; reg [3:0] keyout_reg,keyin_reg; parameter s0=6'b000001,s1=6'b000010, s2=6'b000100, s3=6'b001000, s4=6'b010000, s5=6'b100000; wire clock; always@(posedge clk or negedge 设置时间阉钟“设计早关闭*确定rst) beginif(!rst)i<=0; else i<=i+1; endassign clock=i[7];always@(posedge clock or negedge rst) begin if(!rst) begin count<=0; keyout_en<=0; end else begin if(keyin!=4'hf) begin if(count<'h4bb3)// 去抖动count<=count+1; else keyout_en<=1; end else if(state[5]||state[0]) begin count<=0;keyout_en<=0; end end endassign targe=(!(state==s0||state==s5))&&(keyin!=4'hf);always@(posedge clock) beginif(targe)beginkeyout_reg<=keyout; keyin_reg<=keyin; endelsebeginkeyout_reg<=keyout_reg;keyin_reg<=keyin_reg; endendalways@(keyout reg or keyin_reg or clock) begincase({keyin_reg,keyout_reg}) 8'b1110_1110: num <= 1 ; 8'b1110_1101: num <= 2 ;8'b1110_1011: num <= 3 ; 8'b1110_0111: num <= 10 ;8'b1101_1110: num <= 4 ;8'b1101_1101: num <= 5 ; 8'b1101_1011: num <= 6 ; 8'b1101_0111: num <= 11 ;8'b1011_1110: num <= 7 ; 8'b1011_1101: num <= 8 ; 8'b1011_1011: num <= 9;8'b1011_0111: num <= 12;8'b0111_1110: num <= 0;8'b0111_1101: num <= 15; 8'b0111_1011: num <= 14; 8'b0111_0111: num <= 13;endcaseendalways@(posedge clock or negedge rst) beginif(!rst)state<=s0;elsestate<=next_state;endalways@(keyin or state or keyout_en) beginkeyout=4'b0000;case(state)s0: beginkeyout=4'b0000;if(keyout_en)next_state=s1;elsenext_state=s0;ends1: beginkeyout=4'b1110;if(keyin!=4'hf)next_state=s5;elsenext_state=s2;ends2: beginkeyout=4'b1101;if(keyin!=4'hf)next_state=s5;elsenext_state=s3;ends3: beginkeyout=4'b1011;if(keyin!=4'hf)next_state=s5;elsenext_state=s4;ends4: beginkeyout=4'b0111;if(keyin!=4'hf)next_state=s5;elsenext_state=s0;ends5: beginkeyout=4'b0000;if(keyin==4'hf)next_state=s0;elsenext_state=s5;enddefault next_state=s0;endcaseendendmodule计数器模块:module jishuqi(out_4,out_400,nian,yue,ri,shi,fen,miao,n,speaker,ns,nf,clk_1hz,yushu1,yushu2,num,keyout_en);//shuzimiaobiao output reg[15:0]nian; output reg[7:0]yue,ri,shi,fen,miao,ns,nf;output [11:0] out_4,out_400;output reg [1:0]n;output reg speaker;input clk_1hz;input [15:0]yushu1,yushu2;input [3:0] num;input keyout_en;reg [3:0]cunt;reg[2:0] cnt;reg [15:0] ni;reg [7:0] y,r,s,f,m;assign out_4='d4;assign out_400='d400;wire [15:0]yushu;assign yushu=!((yushu1==0)||(yushu2==0))?0:1;initial begin ns<=8;speaker<=1;endalways@(posedge clk_1hz)beginif(n==3)begin speaker<=1;endelse if((shi==ns)&&(fen==nf))elsespeaker<=speaker;endalways@(negedge keyout_en)beginif(num=='ha)begin n<=1;cunt<=0;endelse if(num=='hd)beginn<=0;cunt<=0;cnt<=0;endelse if(num=='hb)n<=2;else if(num=='hc)n<=3;elsen<=n;if(n==2)beginif((num==1)||(num==2)||(num==3)||(num==4)||(num==5)||(num==6)||(num==7)||(num==8)||(num==9||num==0))begin cnt<=cnt+1;endelsecnt<=cnt;endif(n==1)beginif((num==1)||(num==2)||(num==3)||(num==4)||(num==5)||(num==6)||(num==7)||(num==8)||(num==9||num==0))begin cunt<=cunt+1;endelsecunt<=cunt;endcase(cnt)0:ns[7:4]<=num;1:ns[3:0]<=num;2:nf[7:4]<=num;3:nf[3:0]<=num;4:cnt<=0;endcasecase(cunt)0:begin ni[15:12]<=num;end1:begin ni[11:8]<=num;end2:begin ni[7:4]<=num;end3:begin ni[3:0]<=num;end5:begin y[3:0]<=num;end6:begin r[7:4]<=num;end7:begin r[3:0]<=num;end8:begin s[7:4]<=num;end9:begin s[3:0]<=num;end10:begin f[7:4]<=num;end11:begin f[3:0]<=num;end12:begin m[7:4]<=num;end13:begin m[3:0]<=num;end14:cunt<=0;endcaseendalways@(posedge clk_1hz)//suan fa shi xian beginif(n!=1)beginmiao<=miao+1;if(yue=='h13)begin yue<=0;nian[3:0]<=nian[3:0]+1;if(nian[3:0]=='d9) begin nian[3:0]<=0;nian[7:4]<=nian[7:4]+1;if(nian[7:4]=='d9)begin nian[7:4]<=0;nian[11:8]<=nian[11:8]+1;if(nian[11:8]=='d9)beginnian[11:8]<=0;nian[15:12]<=nian[15:12]+1;if(nian[15:12]=='d9) nian[15:12]<=0;endendendendif(miao[3:0]==4'd9)beginmiao[3:0]<=0;miao[7:4]<=miao[7:4]+1;if(miao[7:4]==4'd5)beginmiao[7:4]<=0;fen[3:0]<=fen[3:0]+1;if(fen[3:0]==9)beginfen[3:0]<=0;fen[7:4]<=fen[7:4]+1;if(fen[7:4]==4'd5)beginfen[7:4]<=0;shi[3:0]<=shi[3:0]+1;if(shi[3:0]=='d9)beginshi[3:0]<=0;shi[7:4]<=shi[7:4]+1;endif((shi[7:4]==2)&&(shi[3:0]==3)) begin shi[7:4]<=0;shi[3:0]<=0; ri[3:0]<=ri[3:0]+1; if(ri[3:0]=='d9)begin ri[3:0]<=0; ri[7:4]<=ri[7:4]+1;endif(((yue[3:0]==1)&&(yue[7:4]==0) )|| ((yue[3:0]==3)&&(yue[7:4]==0) )|| (yue[3:0]==5)||(yue[3:0]==7)||(=8)11((yue[3:0]==0)&&(yue[7:4]==1))||((yue[3:0]==2)&&(yue[7:4]==1))||((yue[3:0]==3)&&(yue[7:4]==1)) begin if(!((yue[3:0]==3)&&(yue[7:4]==1)))beginif((ri[7:4]==3)&&(ri[3:0]==1))beginri[7:4]<=0;ri[3:0]<=1;yue[3:0]<=yue[3:0]+1;endendif((yue[3:0]==4)||(yue[3:0]==6)||(yue[3:0]==9)||((yue[3:0]==1)&&(yue[7:4]==1))) beginif((ri[7:4]==3)&&(ri[3:0]==0))beginri[7:4]<=0;ri[3:0]<=1;yue[3:0]<=yue[3:0]+1;endendif((yue[3:0]==2)&&(yue[7:4]==0))beginif(yushu==0)beginif((ri[7:4]==2)&&(ri[3:0]==9))beginri[7:4]<=0;ri[3:0]<=1;yue[3:0]<=yue[3:0]+1;endendelsebeginif(ri[7:4]==2&&ri[3:0]==9)beginri[7:4]<=0;ri[3:0]<=1;yue[3:0]<=yue[3:0]+1;endendendif(yue[3:0]=='d10)beginyue[3:0]<=0;yue[7:4]<=yue[7:4]+1;endendendendendendendendif(n==1)beginnian<=ni;yue<=y;ri<=r;shi<=s;fen<=f;miao<=m;endendendmodule4、LCD液晶显示模块:module lcd1602(nian,yue,ri,shi,fen,miao,clk,n,ns,nf,rs,rw,en,dat); function [7:0]data;input [3:0] num;begincase(num)0:begin data=8'h30;end1:data=8'h31;2:data=8'h32;3:data=8'h33;4:data=8'h34;5:data=8'h35;6:data="6";7:data=8'h37;8:data=8'h38;9:data=8'h39;endcaseendendfunctioninput [15:0] nian;input [7:0] yue,ri,shi,fen,miao;input [7:0]ns,nf;input clk;input [1:0] n;output rs,rw,en;output[7:0] dat;reg rs,rw;wire en;reg[7:0] dat;reg[5:0] counter;reg[1:0] state;reg [15:0] count;reg clkr;parameter init=0,write_data=1; assign en=clkr;always @(posedge clk)begincount=count+1;if(count==16'h000f)clkr=~clkr;endalways@(posedge clkr)begincase(state)init:beginrs=0;rw=0;counter=counter+1;case(counter)1:dat='h38;2:dat='h08;3:dat='h01;4:dat='h06;5:dat='h0c;6:begindat='h80;state=write_data;counter=0;enddefault: counter=0;endcaseendwrite_data:beginif(n!=2)begincase(counter)0:begin rs<=0;dat=0+8'h80;end1:begin rs<=1;dat=data(nian[15:12]);end2:begin rs<=0;dat=1+8'h80;end3:begin rs<=1;dat=data(nian[11:8]);end4:begin rs<=0;dat=2+8'h80;end5:begin rs<=1;dat=data(nian[7:4]);end6:begin rs<=0;dat=3+8'h80;end7:begin rs<=1;dat=data(nian[3:0]);end8:begin rs<=0;dat=4+8'h80;end9:begin rs<=1;dat="-";end10:begin rs<=0;dat=5+8'h80;end11:begin rs<=1;dat=data(yue[7:4]);end12:begin rs<=0;dat=6+8'h80;end13:begin rs<=1;dat=data(yue[3:0]);end14:begin rs<=0;dat=7+8'h80;end15:begin rs<=1;dat="-";end16:begin rs<=0;dat=8+8'h80;end17:begin rs<=1;dat=data(ri[7:4]);end18:begin rs<=0;dat=9+8'h80;end19:begin rs<=1;dat=data(ri[3:0]);end20:begin rs<=0;dat=0+8'hc0;end21:begin rs<=1;dat=data(shi[7:4]);end22:begin rs<=0;dat=1+8'hc0;end23:begin rs<=1;dat=data(shi[3:0]);end24:begin rs<=0;dat=2+8'hc0;end25:begin rs<=1;dat=":";end26:begin rs<=0;dat=3+8'hc0;end27:begin rs<=1;dat=data(fen[7:4]);end28:begin rs<=0;dat=4+8'hc0;end29:begin rs<=1;dat=data(fen[3:0]);end30:begin rs<=0;dat=5+8'hc0;end31:begin rs<=1;dat=":";end32:begin rs<=0;dat=6+8'hc0;end33:begin rs<=1;dat=data(miao[7:4]);end34:begin rs<=0;dat=7+8'hc0;end35:begin rs<=1;dat=data(miao[3:0]);end36:beginrs=0; dat='h80;enddefault: counter=0;endcaseif(counter==37) counter=0;else counter=counter+1;endelsebegincase(counter)0:begin rs<=0;dat=0+8'h80;end1:begin rs<=1;dat=data(ns[7:4]);end2:begin rs<=0;dat=1+8'h80;end3:begin rs<=1;dat=data(ns[3:0]);end4:begin rs<=0;dat=2+8'h80;end5:begin rs<=1;dat=":";end6:begin rs<=0;dat=3+8'h80;end7:begin rs<=1;dat=data(nf[7:4]);end 8:begin rs<=0;dat=4+8'h80;end9:begin rs<=1;dat=data(nf[3:0]);end10:begin rs<=0;dat=5+8'h80;end11:begin rs<=1;dat=" ";end12:begin rs<=0;dat=6+8'h80;end13:begin rs<=1;dat=" ";end14:begin rs<=0;dat=7+8'h80;end15:begin rs<=1;dat=" ";end16:begin rs<=0;dat=8+8'h80;end17:begin rs<=1;dat=" ";end18:begin rs<=0;dat=9+8'h80;end19:begin rs<=1;dat=" ";end20:begin rs<=0;dat=0+8'hc0;end21:begin rs<=1;dat=" ";end22:begin rs<=0;dat=1+8'hc0;end23:begin rs<=1;dat=" ";end24:begin rs<=0;dat=2+8'hc0;end25:begin rs<=1;dat=" ";end26:begin rs<=0;dat=3+8'hc0;end27:begin rs<=1;dat=" ";end28:begin rs<=0;dat=4+8'hc0;end29:begin rs<=1;dat=" ";end30:begin rs<=0;dat=5+8'hc0;end31:begin rs<=1;dat=" ";end32:begin rs<=0;dat=6+8'hc0;end33:begin rs<=1;dat=" ";end34:begin rs<=0;dat=7+8'hc0;end35:begin rs<=1;dat=" ";end36: beginrs=0; dat='h80;enddefault:counter<=0;endcaseif(counter==37) counter<=0;else counter<=counter+1;endenddefault: state=init;endcaseendendmodule5、除法器模块,module divider(quotient,remainder,ready,error,word1,word2,start,clock,reset);parameter L_divn=16,L_divr=12,S_idle=0,S_adivr=1,S_adivn=2,S_div=3,S_err=4, L_state=3,L_cnt=4,Max_cnt=L_divn-L_divr; output [L_divn-1:0] quotient,remainder;output ready,error;input [L_divn-1:0] word1;//dividendstart,clock,reset;//0,start,1,resetstate,next_state;Load_words,Subtract,Shif_dividend,Shift_divisor;reg [L_divn-1:0] quotient; reg [L_divn:0] dividend; reg [L_divr-1:0]divisor;num_Shift_dividend,num_Shift_divisor;comparison; wire MSB_divr=divisor[L_divr-1]; wire ready=((state==S_idle)&&reset); wire error=(state==S_err);wire Max=(num_Shift_dividend==Max_cnt+num_Shift_divisor); wiresign_bit=comparison[L_divr];assign remainder=(dividend[L_divn-1:L_divn-L_divr])>num_Shift_divisor;/////////always @(state or dividend or divisor or MSB_divr) case(state) S_adivr: if(MSB_divr==0)comparison=dividend[L_divn:L_divn-L_divr]+{Tb1,~(divisor<<1)}+1'b1; elsecomparison=dividend[L_divn:L_divn-L_divr]+{1'b1,~divisor[L_divr-1:0]} default:comparison=dividend[L_divn:L_divn-L_divr]+{1'b1,~divisor[L_divr-1:0]}+1'b1;endcasealways @(posedge clock or negedge reset) if(!reset) state<=S_idle; else state<=next_state; always @(state or word1 or word2 or start or comparison or sign_bit or Max) beginLoad_words=0;Subtract=0;Shift_dividend=0;Shift_divisor=0;case(state)S_idle:case(!start)0: next_state=S_idle;1:if(word2==0) next_state=S_err;else if(word1) begin next_state=S_adivr;Load_words=1; else next_state=S_idle;endcaseS_adivr:case(MSB_divr)0: if(sign_bit==0) begin next_state=S_adivr;Shift_divisor=1else if(sign_bit==1) next_state=S_adivn; 1: next_state=S_div;endcaseS_adivn:case({Max,sign_bit})2'b00: next_state=S_div;2'b01: begin next_state=S_adivn;Shift_dividend=1; end 2'b10: begin next_state=S_idle;Subtract=1; end 2'b11:next_state=S_idle; endcase S_div:case((Max,sign_bit})input [L_divr-1:0] word2;//divisorinput reg [L_state-1:0]regreg [L_cnt-1:0] reg [L_divr:0]2'b00: begin next_state=S_div;Subtract=1;end2'b01: next_state=S_adivn;2'b10: begin next_state=S_div;Subtract=1;end2'b11: begin next_state=S_div;Shift_dividend=1; endendcasedefault: next_state=S_err;endcaseendalways @(posedge clock or negedge reset)beginif(!reset)begindivisor<=0;dividend<=0;quotient<=0;num_Shift_dividend<=0;num_Shift_divisor<=0;endelse if(Load_words==1)begindividend<=word1;divisor<=word2;quotient<=0;num_Shift_dividend<=0;num_Shift_divisor<=0;endelse if(Shift_divisor)begindivisor<=divisor<<1;num_Shift_divisor<=num_Shift_divisor+1;endelse if(Shift_dividend)begindividend<=dividend<<1;quotient<=quotient<<1;num_Shift_dividend<=num_Shift_dividend+1;endelse if(Subtract)begindividend[L_divn:L_divn-L_divr]<=comparison;quotient[0]<=1;endend endmodule6、铃声模块:module liangzhu(sys_clk,rst_n,sp);input sys_clk,rst_n;output sp;reg sp;reg[3 :0] high,med,low;reg[13:0] divider,origin;reg[7 :0] counter;reg[23:0] clk_cnt;always @ (posedge sys_clk or posedge rst_n) if (rst_n)clk_cnt <= 24'd0;elseclk_cnt <= clk_cnt + 1'b1;wire clk_6mhz = clk_cnt[2];wire clk_4hz = clk_cnt[23];wire carry=(divider==16383);always @(posedge clk_6mhz)beginif(carry)divider=origin;elsedivider=divider+1'b1;endalways@(posedge carry)beginsp =~sp;endalways@(posedge clk_4hz) begincase({high ,med ,low}) 12'b000000000011 12'b000000000101 12'b000000000110 12'b00000000011112'b00000001000012'b00000010000012'b00000011000012'b00000101000012'b00000110000012'b00010000000012'b000000000000default:origin=14'd0;endcaseendalways@(posedge clk_4hz) origin=14'd7281; origin=14'd8730; origin=14'd9565; origin=14'd10310; origin=14'd10647; origin=14'd11272; origin=14'd11831; origin=14'd12556; origin=14'd12974; origin=14'd13516; origin=14'd16383;beginif(counter==8'd50)counter=8'd0;elsecounter=counter+1'b1;case(counter)8'd 0:{high,med,low}=12'b0000_0000_0011;8'd 1:{high,med,low}=12'b0000_0000_0011;8'd 2:{high,med,low}=12'b0000_0000_0011;8'd 3:{high,med,low}=12'b0000_0000_0011;8'd 4:{high,med,low}=12'b0000_0000_0101;8'd 5:{high,med,low}=12'b0000_0000_0101;8'd 6:{high,med,low}=12'b0000_0000_0101;8'd 7:{high,med,low}=12'b0000_0000_0110;8'd 8:{high,med,low}=12'b0000_0001_0000;8'd 9:{high,med,low}=12'b0000_0001_0000;8'd10:{high,med,low}=12'b0000_0001_0000;8'd11:{high,med,low}=12'b0000_0010_0000;8'd12:{high,med,low}=12'b0000_0000_0110;8'd13:{high,med,low}=12'b0000_0001_0000;8'd14:{high,med,low}=12'b0000_0000_0101;8'd15:{high,med,low}=12'b0000_0000_0101;8'd16:{high,med,low}=12'b0000_0101_0000;8'd17:{high,med,low}=12'b0000_0101_0000;8'd18:{high,med,low}=12'b0000_0101_0000;8'd19:{high,med,low}=12'b0001_0000_0000;8'd20:{high,med,low}=12'b0000_0110_0000;8'd21:{high,med,low}=12'b0000_0101_0000;8'd22:{high,med,low}=12'b0000_0011_0000;8'd23:{high,med,low}=12'b0000_0101_0000;8'd24:{high,med,low}=12'b0000_0010_0000;8'd25:{high,med,low}=12'b0000_0010_0000;8'd26:{high,med,low}=12'b0000_0010_0000;8'd27:{high,med,low}=12'b0000_0010_0000;8'd28:{high,med,low}=12'b0000_0010_0000;8'd29:{high,med,low}=12'b0000_0010_0000;8'd30:{high,med,low}=12'b0000_0010_0000;8'd31:{high,med,low}=12'b0000_0010_0000;8'd32:{high,med,low}=12'b0000_0010_0000;8'd33:{high,med,low}=12'b0000_0010_0000;8'd34:{high,med,low}=12'b0000_0010_0000;8'd35:{high,med,low}=12'b0000_0011_0000;8'd36:{high,med,low}=12'b0000_0000_0111;8'd37:{high,med,low}=12'b0000_0000_0111;8'd38:{high,med,low}=12'b0000_0000_0110;8'd39:{high,med,low}=12'b0000_0000_0110;8'd40:{high,med,low}=12'b0000_0000_0101;8'd41:{high,med,low}=12'b0000_0000_0101;8'd42:{high,med,low}=12'b0000_0000_0101;8'd43:{high,med,low}=12'b0000_0000_0110;8'd44:{high,med,low}=12'b0000_0001_0000;8'd45:{high,med,low}=12'b0000_0001_0000;8'd46:{high,med,low}=12'b0000_0010_0000;8'd47:{high,med,low}=12'b0000_0010_0000;default:{high,med,low}=12'd0;endcase//后边乐曲片断此处省略endendmodule后记:本人深深的体会到语法的重要性,一个小小的语法问题有时候可以折磨人几天甚至几个月。

基于fpga的多功能万年历

基于fpga的多功能万年历

基于FPGA的多功能万年历1. 绪论现代科技在不断进步电子技术在不断发展,电子产品设计复杂程度也在不断增加。

而且电子产品的更新换代也越来越快,现在只靠传统的纯硬件的设计方法已经不能满足现代人们的要求。

EDA就是典型的硬件设计软件化的设计平台。

EDA是一项非常先进的技术,它有许多别的技术没有的优点:像单片机需要先画出硬件图再编写相对应的程序,而EDA是先编好程序再画图的,而且模块化的编程还会在软件中生成相应的封装元件,使最后画原理图变的更加简单;可以编好程序就直接仿真,程序出现错误可以在源文件内部直接改;并且设计好的总系统可以集成在一个体积小、功耗低、可靠性高的芯片上。

本设计采用VHDL语言,VHDL语言是一种全方位的数字系统设计和测试的硬件描述。

它支持原理图输入方法以及传统的文件输入方。

对于前者适用于小规模的数字集成电路,并进行模拟仿真。

而对于大规模的、复杂的系统,如果用纯原理图设计方法的话的,由于种种条件和环境制约,会导致工作效率底而且容易出错的等缺点。

在信息技术的今天,集成电路逐渐的趋向于系统化、微尺寸化、低功耗高集成化,因此,高密度可编程逻辑器件和VHDL越来越得到设计者的青睐。

它具有极强的描述能力,支持结构、数据流、行为三种描述形式的混合的设计方式,描覆盖面广、抽象能力强。

它能支持系统行为级、逻辑门级和寄存器传输级三个不同层次的设计。

在本设计中用到的FPGA是特殊的ASIC芯片,ASIC是一种带有逻辑处理的加速处理器的专用的系统集成电路。

它具有功耗低、速度快、集成度、设计制造成本低等优点。

本设计是研究基于FPGA的多功能万年历的设计,主要实现以下功能:能够显示年、月、日、时、分、秒,时间采用24小时制。

当时间不准确时还可以手动校准。

本系统还能实时的显示当前的温度,扩展了万年历的功能。

我采用的是数字温度传感器DS18B20和FPGA组成的温度采集系统,此系统具有硬件电路简单,抗干扰能力强等优点。

基于FPGA电子万年历的设计与实现

基于FPGA电子万年历的设计与实现

本科毕业设计(论文)论文题目:基于FPGA的公农历显示系统设计系所:电子工程系专业:学生姓名:学生学号:指导教师:导师职称:讲师完成日期:2013年5月2日基于FPGA的公农历显示系统设计摘要万年历是采用数字电路实现对、时、分、秒数字显示的计时装置,由于数字集成电路的发展和石英晶体振荡器的广泛应用,使得数字钟的精度,远远超过老式钟表, 钟表的数字化给人们生产生活带来了极大的方便,而且大大地扩展了钟表原先的功能。

万年历具有读取方便、显示直观、功能多样、成本低廉等诸多优点,符合电子仪器仪表的发展趋势,具有广阔的市场前景。

本设计基于FPGA 芯片,系统集成化程度高,精度高,采用Verilog HDL语言程,用软件的方式设计硬件,灵活性好,方便以后的产品升级。

设计过程先对万年历进行系统分析确定需要的主要功能。

然后对电子万年历进行系统分析,画出每个模块的流程图、数据通道等,最后对每个模块进行代码编写。

本论文分别介绍八个模块:电子万年历核心控制模块、时间计时及其调整模块、时间显示动态位选模块、数码管显示模块、秒表模块、日期计时与调整模块、闹钟模块、分频模块。

在系统分析章节对整体设计的概况以及对每个模块进行描述,在系统实现章节每个模块具有单独的系统流程图,以及功能模块图。

在系统测试章节有对每个模块的测试后的波形图。

关键词:FPGA芯片,Verilog HDL语言,电子万年历Design of Calendar and Traditional Chinese Calendar System Based on FPGAAbstractThis calendar is the timing device that use of digital circuit to achieve, display the hours, minutes, seconds on digital display screen as well. Because of digital integrated circuit development and wide application of quartz crystal oscillators, the digital clock has become more accurate than the old-fashioned clocks. The digitalization of the clocks has brought great convenience to people, and also greatly expanded the original clock function. Calendar has plenty of advantages such as easy to read, displayed with intuition, low cost and so on. The calendar meet the nowadays' development trend of electronic instrumentation, and has a broad market prospect.The design is based on FPGA chip with a high degree of system integration and precision. This design uses Verilog HDL, so it can be flexible and easy to update in the future. The first step of design process is analysis system and determine the system's main function. Then we should draw flow charts of each module and data channels of the system. Finally write the code for each module.This thesis will introduce eight modules of the calendar system individually. Including electronic calendar center control module, Timing and adjustment module,dynamic time display selection module, LED display module, the stopwatch module, date and adjustment module, alarm module and frequency module. The chapter of systems analysis including the overall design of the profile and the description of each module. The chapter of system implementation has a separate section for each module system flowchart and functional block diagram. The chapters of system test will show the test waveform of each module.Key words: FPGA chip , Verilog HDL language , Electronic Calendar目录摘要 (II)第1章绪论 (1)1.1选题原因 (1)1.2国内外产品研究综述 (1)第2章关键技术介绍 (3)2.1电子万年历的发展 (3)2.2FPGA简介 (3)2.3电子万年历的工作原理 (3)第3章系统分析 (5)3.1计时流程 (5)3.2功能按键 (5)3.3功能框架 (6)第4章系统设计 (8)4.1时钟问题 (8)4.2电子万年历的控制系统 (9)4.3主控制模块MAINCONTROL (9)4.4时间及其设置模块TIME_AUTO_AND_SET (9)4.5时间数据与时间设置数据多路选择模块TIME_MUX (10)4.6时间显示动态位选模块TIME_DISP_SELECT (11)4.7显示模块DISP_DATA_MUX (11)4.8日期显示与设置模块DA TE_MAIN (12)4.9闹钟模块ALARMCLOCK (12)4.10分频模块FDIV (12)第5章系统实现 (14)5.1电子万年历的控制系统 (14)5.2主控制模块MAINCONTROL (14)5.3时间及其设置模块TIME_AUTO_AND_SET (15)5.3.1时间模块timepiece_main (15)5.3.2时间设置模块timeset (16)5.4时间数据与时间设置数据多路选择模块TIME_MUX (17)5.5时间显示动态位选模块TIME_DISP_SELECT (18)5.6显示模块DISP_DATA_MUX (18)5.7闹钟模块ALARMCLOCK (19)5.8分频模块FDIV (20)第6章系统测试 (21)6.1主控制模块MAINCONTROL (21)6.2时间及其设置模块TIME_AUTO_AND_SET (21)6.3时间设置模块TIMESET (22)6.4时间数据与时间设置数据多路选择模块TIME_MUX (22)6.5时间显示动态位选模块TIME_DISP_SELECT (22)6.6显示模块DISP_DATA_MUX (23)6.7秒表模块STOPWATCH (24)6.8日期显示与设置模块DA TE_MAIN (24)6.9闹钟模块ALARMCLOCK (24)6.10分频模块FDIV (25)第7章结论 (26)参考文献 (27)致谢 (28)第1章绪论1.1选题原因万年历给人们日常生活带来极大的方便,而且扩展了原先的报时功能,例如日期提醒,整点报时等。

FPGA万年历报告

FPGA万年历报告

FPGA-CPLD原理及应用课程设计报告题目:基于SOPC设计万年历一、摘要设计从系统硬件出发,由CPU、总线、RAM、外接设备等构成SOPC Builder 的硬件系统,通过Nios II DE2开发的嵌入式软件编写并嵌入SOPC Builder的硬件中实现万年历的整体开发。

通过应用SoPC Builder开发工具,设计者可以摆脱传统的、易于出错的软硬件设计细节,从而达到加快项目开发、缩短开发周期、节约开发成本的目的并具有高集成度、设计灵活和可移植性较好。

关键词:万年历SOPC SOPC Builder Nios II DE2二、设计要求用Nios II DE2 开发板的LCD显示电子钟的日期和时间。

LCD分两行显示,第1行显示年、月、日;第2行显示时、分、秒。

用输入BUTTON[0]来控制LCD 行的修改,同时让Nios II DE2开发板上的绿色发光二极管亮灭来表示这个选择。

当BUTTON[0]按一下后,LEDG3亮,可以修改年、月和日的数字;再按一下BUTTON[0]后,LEDG3灭,可以修改时、分和秒的数字。

另外用输入按钮BUTTON[3]来控制日期和时间的修改,当处于日期修改方式时,每次按动一次BUTTON[3],依次更换“年”、“月”和“日”的修改。

当处于时间修改方式时,每次按动一次BUTTON[3],依次更换“时”、“分”和“秒”的修改。

修改对象被选中后,按动BUTTON[2]输入按钮可以增加显示的数字;按动BUTTON[1]输入按钮可以减少显示的数字。

三、设计内容1、按键信息BUTTON[3]:“年”、“月”、“日”或“时”、“分”、“秒”切换键BUTTON[2]:+键BUTTON[1]:-键BUTTON[0]:“年”、“月”、“日”与“时”、“分”、“秒”切换键显示信息LCD_Line1:显示“年”、“月”、“日”LCD_Line1:显示“时”、“分”、“秒”2、SOPC Builder 硬件建立SOPC Builder是在Quartus II里的SOPC Builder进行的,先建立工程,在SOPC Builder里添加硬件,包括CPU ,jtag_uart ,RAM,LCD,PIO,按键,LED,以及LCD_ON。

基于FPGA的多功能电子万年历

基于FPGA的多功能电子万年历

基于FPGA的多功能电子万年历电子万年历可以显示日期、星期、时间以及其他的一些信息。

近几年,随着FPGA技术的发展,基于FPGA的电子万年历已经被广泛使用。

基于FPGA的电子万年历除了具备传统电子万年历的基本功能外,还具有诸多的优点。

采用FPGA做万年历,集成度高、抗电磁干扰性能好、可编程性强,且易于扩展。

本文将主要讲述基于FPGA的多功能电子万年历的设计原理、实现细节以及相关应用。

设计原理基于FPGA的多功能电子万年历主要由FPGA芯片、时钟模块、数码管显示模块以及按键扫描模块组成。

1.FPGA芯片:大体上分为输入、输出、内存和运算4个部分。

通过采用FPGA芯片可以实现逻辑门的优化布局和资源分配,从而实现万年历的多种功能。

2.时钟模块:利用时钟模块产生震荡脉冲,驱动万年历的各种操作。

时钟模块还可以产生各种频率的时钟信号,如秒钟、分频、时钟、日历等,从而实现多种功能。

3.显示模块:显示模块主要通过数码管来显示日期、星期、时间等信息。

具体实现方法是将数码管的数码码表和时序参数存储在内存中,通过编程控制数码管的显示方式,实现数据的输出。

4.按键扫描模块:按键扫描模块主要通过扫描键盘来接受用户的输入,并根据用户的操作控制万年历的功能。

实现细节基于FPGA的多功能电子万年历的实现细节主要包括万年历的功能实现、按键扫描和电路部署。

1.万年历的功能实现多功能电子万年历主要支持年、月、日的日期显示、星期显示、时间显示、时钟多种功能。

具体实现方法是每秒读取系统时间,并将时间转换成5V逻辑电平数据,然后通过编程控制数码管的显示方式,实现数据的输出。

2.按键扫描按键扫描模块主要通过接收按下按键后输出电平并进行数值编码,与计算机进行数值比对,然后根据用户的操作控制万年历的功能。

比如,按下设置键后,进入设置模式,按一次将秒数置零,按2次进行月日年设置,按3次进行时间设置,按4次重新返回当前时间界面。

3.电路部署电路部署主要包括FPGA芯片与其他模块、模块与模块之间的连接。

数字电路课程设计---基于1602液晶屏的数字万年历(Verilog版)

数字电路课程设计---基于1602液晶屏的数字万年历(Verilog版)

大连理工大学数字电路课程设计院 系: 电子科学与技术学院 专 业: 集成电路设计与集成系统 班 级: 电集1001 姓 名: 陈朝吉 学 号: 201081086总结报告大连理工大学本科实验报告题目:基于1602液晶屏的数字万年历(Verilog版)课程名称:数字电路课程设计学院(系):电子科学与技术学院专业:集成电路设计与集成系统班级:电集1001学生姓名:陈朝吉学号:201081086完成日期:2012年12月22日成绩:题目:基于1602液晶屏的数字万年历(Verilog版)一.设计要求1.基本功能➢设计一个数字钟,能够显示当前时间,分别用6个数码管显示小时、分钟、秒钟的时间,秒针的计数频率为1Hz,可由系统脉冲分频得到。

➢在整点进行提示,可通过LED闪烁实现,闪烁频率及花型可自己设计。

➢能够调整小时和分钟的时间,调整的形式为通过按键进行累加。

➢具有闹钟功能,闹钟时间可以任意设定(设定的形式同样为通过按键累加),并且在设定的时间能够进行提示,提示同样可以由LED闪烁实现。

2.扩展功能➢设计模式选择计数器,通过计数器来控制各个功能之间转换。

➢调整当前时间以及闹钟时间,在按键累加的功能不变的基础上,增加一个功能,即当按住累加键超过3秒,时间能够以4Hz的频率累加。

➢用LCD液晶屏来显示当前时间及功能模式。

二.设计分析及系统方案设计1.要求分析:◆基于FPGA实际并发处理的特点,对于实现数字万历年系统,相比于任何嵌入式处理器而言,其特点和优势将得以更加全面体现。

◆数字万年历中所有模块都将基于基准时钟源进行处理,结合FPGA本身的特点,在时钟源下可进行精确计数,可轻易而产生十分精确的万年历时间。

◆基础部分:万年历可包括以下时间处理模块:基于秒时钟计数器进行判断处理。

①秒,分,时。

②星期,上/下午。

③日,月,年。

④闹钟◆功能部分:①时间设定:使用四个按键进行控制,分别是:设置复位按键,设置移位键,功能“加”键,功能“减”键。

万年历VHDL实现

万年历VHDL实现

基于FPGA万年历程序设计方案一.秒显示程序说明LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY MAIN ISPORT(clk,clr:in std_logic;co:out std_logic;UNIT:OUT STD_LOGIC_VECTOR(9 DOWNTO 0);TEN: OUT STD_LOGIC_VECTOR(5 DOWNTO 0));END MAIN;ARCHITECTURE ONE OF MAIN ISSIGNAL cnt1,cnt0:std_logic_vector(3 downto 0);BEGINP0: PROCESS(clk,clr)BEGINIF clr='1' THENcnt1<="0000";cnt0<="0000";ELSIF clk'event and clk='1'THENIF cnt1="0101" and cnt0="1000"THENco<='1';cnt0<="1001";ELSif CNT0<"1001"THENCNT0<=CNT0+1;ELSECNT0<="0000";IF CNT1<"0101"THENCNT1<=CNT1+1;ELSECNT1<="0000";CO<='0';END IF;END IF;END IF;END PROCESS P0;P2:PROCESS(CNT1,CNT0)BEGINCASE CNT0 ISWHEN "0000" => unit<="1000000000";WHEN "0001" => unit<="010*******";WHEN "0010" => unit<="0010000000";WHEN "0011" => unit<="0001000000";WHEN "0100" => unit<="0000100000";WHEN "0101" => unit<="0000010000";WHEN "0110" => unit<="0000001000";WHEN "0111" => unit<="0000000100";WHEN "1000" => unit<="0000000010";WHEN "1001" => unit<="0000000001";WHEN others => unit<="1111111111";END CASE;CASE CNT1 ISWHEN "0000" => ten<="011111";WHEN "0001" => ten<="101111";WHEN "0010" => ten<="110111";WHEN "0011" => ten<="111011";WHEN "0100" => ten<="111101";WHEN "0101" => ten<="111110";WHEN others => ten<="111111";END CASE;END PROCESS P2;END ONE;二.各模块说明:年(两位)、月、日、星期、小时、分钟、控制、分频器、位选、显示1、分频器:通过晶振引入计数脉冲后,利用分频器得到秒信号,主要通过程序编写计数器。

基于FPGA的万年历程序

基于FPGA的万年历程序

use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity wannianli isport(rst:in std_logic;--2012-1-11-00-00-00clk:in std_logic;--系统时钟50Mclr:in std_logic;display_mode: in std_logic;--显示年或时inc:in std_logic;--增加按键dec:in std_logic;mode:in std_logic;seg8:out std_logic_vector(7 downto 0);--数码管段码scan:out std_logic_vector(7 downto 0);--数码管位码led:out std_logic_vector(3 downto 0) );end;architecture one of wannianli is--signal state:std_logic_vector(2 downto 0);--signal dis_mode:std_logic_vector(1 downto 0);signal state:integer range 0 to 7;--0为正常显示,1.2.3.4.5.6.分别对应修改时分秒年月日signal dis_mode:integer range 0 to 3;--signal qhh,qhl,qmh,qml,qsh,qsl,qy1,qy2,qy3,qy4,qm1,qm2,qd1,qd2:std_logic_vector(3 downto 0);signal qhh,qhl,qmh,qml,qsh,qsl,qy1,qy2,qy3,qy4,qmonl,qmonh,qdl,qdh:integer range 0 to 15; signal data:integer range 0 to 15 ;signal cnt:integer range 0 to 7;signal clk1khz,clk1hz,clk2hz,clk5ms:std_logic;--signal blink:std_logic_vector(2 downto 0);--signal inc_reg:std_logic;signal sec,min:integer range 0 to 59;signal hour:integer range 0 to 23;signal year:integer range 1 to 9999;signal month:integer range 1 to 12;signal day,day_limit:integer range 1 to 31;beginprocess(clk)variable count:integer range 0 to 30000;beginif clk'event and clk='1' thenif count=25000 then clk1khz<=not clk1khz;count:=0;else count:=count+1;end if;end if;end process;-------------------------------------------------------variable cnte:integer range 0 to 30000000;beginif clk'event and clk ='1' thenif cnte=25000000 then clk1hz<=not clk1hz; cnte:=0;else cnte:=cnte+1;end if ;end if ;end process ;-----------------------------------------------------process (clk)variable cnt2:integer range 0 to 25000000;beginif clk'event and clk='1' thenif cnt2=12500000 then clk2hz<=clk2hz;cnt2:=0;else cnt2:=cnt2+1;end if ;end if ;end process;-----------------------------------------------------process(clk)variable cnnt:integer range 0 to 600000;beginif clk'event and clk='1' thenif cnnt=500000 then clk5ms<=clk5ms;cnnt:=0;else cnnt:=cnnt+1;end if ;end if ;end process;-----------------------------------------------------------------------------------------process(display_mode , clk1hz)beginif display_mode'event and display_mode='0' then dis_mode<=dis_mode+1;if dis_mode=1 thendis_mode<=0;end if;end if;end process;-------------------------------------------beginyear<=year;month<= month;day<=day;hour<=hour;min<=min;sec<=sec;end process;-----------------------------------------process(mode , clr,clk1hz)beginif clr='0' thenstate<=0;elsif mode'event and mode='0' thenstate<=state+1;if state=6 thenstate<=0;end if;end if ;end process;-----------------------------------------------------------------------------------process(clk1hz,state,dis_mode,inc,dec,clr,hour,sec,min,rst,year,month,day) beginif rst='0' thenyear<=2012;month<=1;day<=11;hour<=0;min<=0;sec<=0;--state<=0;--dis_mode<=0;elsif clr='0' thenhour<=23;min<=59;sec<=55;year<=2013;month<=1;day<=12;elsif clk1hz'event and clk1hz='1' thencase state iswhen 0 =>led<="0000";if((month=1)or(month=3)or(month=5)or(month=7)or(month=8)or(month=10)or(month=12)) thenday_limit<=31;end if;if month=2 then----if((year%4==0&&year%100!=0)||(year%400==0))if ((((year rem 4)=0) and ((year rem 100)/=0)) or ((year rem 400=0))) thenday_limit<=29;elseday_limit<=28;end if;end if;if((month=4)or(month=6)or(month=9)or(month=11)) thenday_limit<=30;end if;sec<=sec+1;if sec=59 thensec<=0;min<=min+1;if min=59 thenmin<=0;hour<=hour+1;if hour =23 thenhour<=0;day<=day+1;if day=day_limit thenday<=1;month<=month+1;if month=12 thenmonth<=1;year<=year+1;if year=9999 thenyear<=1;end if;end if;end if;end if;end if;end if;--if sec=59 then sec<=0;--if min=59 then min<=0;--if hour=23 then hour<=0;--else--hour<=hour+1;--end if;--else--min<=min+1;--end if;--else--sec<=sec+1;--end if;when 1=> led<="0001";if inc='0' thenif hour=23 thenhour<=0;else hour<=hour+1;end if;elsif dec='0' thenif hour=0 thenhour<=23;else hour<=hour-1;end if;end if;when 2=>led<="0010" ;if inc='0' thenif min=59 thenmin<=0;elsemin<=min+1;end if;elsif dec='0' thenif min=0 thenmin<=59;elsemin<=min-1;end if;end if;when 3=>led<="0011" ;if inc='0' thenif sec=59 thensec<=0;elsesec<=sec+1;end if;elsif dec='0' thenif sec=0 thensec<=59;elsesec<=sec-1;end if;end if;when 4 =>led<="0100";if inc='0' thenif year=9999 thenyear<=1;elseyear<=year+1;end if;elsif dec='0' thenif year=1990 thenyear<=2020;elseyear<=year-1;end if;end if;when 5=> led <="0101";if inc='0' thenif month=12 thenmonth<=1;elsemonth<=month+1;end if;elsif dec='0' thenif month=0 thenmonth<=12;elsemonth<=month-1;end if;end if;when 6 =>led <="0110";if inc='0' thenif day=day_limit thenday<=1;elseday<=day+1;end if;elsif dec='0' thenif day=0 thenday<=day_limit;elseday<=day-1;end if;end if;when others =>null;end case;end if;--end if;end process;----------------------------------------------------------------------process(sec)begincase sec iswhen 0|10|20|30|40|50 => qsl<=0;when 1|11|21|31|41|51 => qsl<=1;when 2|12|22|32|42|52 => qsl<=2;when 3|13|23|33|43|53 => qsl<=3;when 4|14|24|34|44|54 => qsl<=4;when 5|15|25|35|45|55 => qsl<=5;when 6|16|26|36|46|56 => qsl<=6;when 7|17|27|37|47|57 => qsl<=7;when 8|18|28|38|48|58 => qsl<=8;when 9|19|29|39|49|59 => qsl<=9;when others =>null;end case;case sec iswhen 0|1|2|3|4|5|6|7|8|9 => qsh<=0;when 10|11|12|13|14|15|16|17|18|19 => qsh<=1;when 20|21|22|23|24|25|26|27|28|29 => qsh<=2;when 30|31|32|33|34|35|36|37|38|39 => qsh<=3;when 40|41|42|43|44|45|46|47|48|49 => qsh<=4;when 50|51|52|53|54|55|56|57|58|59 => qsh<=5;when others =>null;end case;end process;--------------------------------------------------------------------process(min)begincase min iswhen 0|10|20|30|40|50 => qml<=0;when 1|11|21|31|41|51 => qml<=1;when 2|12|22|32|42|52 => qml<=2;when 3|13|23|33|43|53 => qml<=3;when 4|14|24|34|44|54 => qml<=4;when 5|15|25|35|45|55 => qml<=5;when 6|16|26|36|46|56 => qml<=6;when 7|17|27|37|47|57 => qml<=7;when 8|18|28|38|48|58 => qml<=8;when 9|19|29|39|49|59 => qml<=9;when others =>null;end case;case min iswhen 0|1|2|3|4|5|6|7|8|9 => qmh<=0;when 10|11|12|13|14|15|16|17|18|19 => qmh<=1;when 20|21|22|23|24|25|26|27|28|29 => qmh<=2;when 30|31|32|33|34|35|36|37|38|39 => qmh<=3;when 40|41|42|43|44|45|46|47|48|49 => qmh<=4;when 50|51|52|53|54|55|56|57|58|59 => qmh<=5;when others =>null;end case;end process;-----------------------------------------------------------------------process(hour)begincase hour iswhen 0|10|20 => qhl<=0;when 1|11|21 => qhl<=1;when 2|12|22 => qhl<=2;when 3|13|23 => qhl<=3;when 4|14 => qhl<=4;when 5|15 => qhl<=5;when 6|16 => qhl<=6;when 7|17 => qhl<=7;when 8|18 => qhl<=8;when 9|19 => qhl<=9;when others =>null;end case;case hour iswhen 0|1|2|3|4|5|6|7|8|9 => qhh<=0;when 10|11|12|13|14|15|16|17|18|19 => qhh<=1;when 20|21|22|23 => qhh<=2;when others => null;end case;end process;---------------------------------------------------------------process(year)beginqy1<=year/1000;qy2<=(year rem 1000)/100;qy3<=((year rem 1000)rem 100)/10;qy4<=((year rem 1000)rem 100) rem 10;--qy1<=year/1000;--qy2<=(year rem 1000)/100;--qy3<=((year-(year/1000)*1000)-((year-(year/1000)*1000)/100)*100)/10;--qy4<=((year rem 1000)rem 100)rem 10;end process;----------------------------------------------------------------process(month)beginqmonh<=month/10;qmonl<=month rem 10;end process;-----------------------------------------------------------------process(day)beginqdh<=day/10;qdl<=day rem 10;end process;----------------------------------------------------------------process(clk1khz)beginif clk1khz'event and clk1khz='1' thenif cnt=7 thencnt<=0;else cnt<=cnt+1;end if;end if;end process;----------------------------------------------------------process (cnt,qhh,qhl,qmh,qml,qsh,qsl,dis_mode)begincase dis_mode iswhen 0 => case cnt iswhen 0 => data<=qsl; scan<="11111110";when 1 => data<=qsh; scan<="11111101";when 2 => data<=15 ; scan<="11111111";when 3 => data<=qml; scan<="11110111";when 4 => data<=qmh; scan<="11101111";when 5 => data<=15; scan<="11111111";when 6 => data<=qhl; scan<="10111111";when 7 => data<=qhh; scan<="01111111";when others => null;end case;when 1=> case cnt iswhen 0 => data<=qdl; scan<="11111110";when 1 => data<=qdh; scan<="11111101";when 2 => data<=qmonl ; scan<="11111011";when 3 => data<=qmonh; scan<="11110111";when 4 => data<=qy4; scan<="11101111";when 5 => data<=qy3; scan<="11011111";when 6 => data<=qy2; scan<="10111111";when 7 => data<=qy1; scan<="01111111";when others =>null;end case;when others => null;end case;end process;----------------------------------------------------------------------------------process(data)begincase data iswhen 0 =>seg8<="11000000";when 1 =>seg8<="11111001";when 2 =>seg8<="10100100";when 3 =>seg8<="10110000";when 4 =>seg8<="10011001";when 5 =>seg8<="10010010";when 6 =>seg8<="10000010";when 7 =>seg8<="11111000";when 8 =>seg8<="10000000";when 9 =>seg8<="10010000";when others =>seg8<="11111111";end case ;end process;end;。

基于FPGA的多功能电子万年历毕业设计说明

基于FPGA的多功能电子万年历毕业设计说明

毕业设计中期报告题目名称:基于FPGA的万年历设计院系名称:电气学院班级:应电学号:0832100589学生:梁启超指导教师:金凤2011年06月目录一、多功能电子万年历及FPGA简介 (1)1.1电子万年历的发展 (1)1.2 FPGA简介 (1)1.3 电子万年历的工作原理 (2)二、多功能电子万年历各功能模块实现 (4)2.1 时钟问题 (4)2.1.1 全局时钟 (4)2.1.2 门控时钟 (4)2.1.3 多级逻辑时钟 (5)2.1.4 波动式时钟 (5)2.2 电子万年历的控制系统 (6)2.3 主控制模块 maincontrol (7)2.4 时间及其设置模块 time_auto_and_set (8)2.2.1 时间模块 timepiece_main (8)2.2.2 时间设置模块 timeset (9)2.2.3 时间数据与时间设置数据多路选择模块 time_mux (11)2.3 时间显示动态位选模块 time_disp_select (13)2.4 显示模块 disp_data_mux (14)2.5 秒表模块 stopwatch (15)2.6 日期显示与设置模块 date_main (16)2.6.1 日期自动工作模块 autodate (17)2.6.2 日期设置模块 setdate (17)2.7 闹钟模块alarmclock (18)2.8 分频模块 fdiv (19)2.9 顶层模块图 (21)三、附录 (23)电子万年历系统的Verilog HDL语言程序设计部分代码 (23)3.1主控制模块 (23)3.2秒自动计时子模块 (25)3.3时间自动工作控制 (25)3.4时间数据与时间设置数据多路选择模块 (26)3.5时间及其设置模块 (27)3.6时间显示动态位选模块 (28)3.7秒表模块 (29)3.8分频模块 (29)参考文献 (31)1 引言1.1 选题意义钟表的数字化给人们生产生活带来了极大的方便,而且大扩展了钟表原先的报时功能,诸如定时自动报警、按时自动打铃、时间程序自动控制、定时广播、定时启闭路灯等。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

接着我的上一篇博文,终于完善好了,前几天太忙了,没有及时上传,呵呵,今天晚上刚比较早刚好凌晨,及时上传一下,实现了从0000---9999年的时钟,其实万年历和十万年历,都是差不多,等到地球能转到9999年再改代码也不迟,哈哈!!我这里有顶层和底层文件,顶层主要是调用模块和做按键处理,具体按键防抖动原理,参见偶的以前的博文,我写完这个万年历的代码,还没来得及优化,占用了太多了逻辑门,可以进一步优化。

大致思路是:第一次按下KEY1 的时候,所有计时停止,再按KEY1,年就闪烁,按下KEY2和KEY3 进行加减。

再按KEY1,月就闪烁,按下KEY2和KEY3 进行加减........依次为调年-月-日-星期-时分秒,再次按一下KEY1,进入正常运行模式。

好了先上顶层模块module LCD(rst,clk,rw,rs,en,data,key1,key2,key3);input clk,rst;input key1,key2,key3;output rs,en,rw;output [7:0] data;reg key1_out,key2_out,key3_out;wire clk,rst;wire rs,en,rw;wire [7:0] data;disp U1(.clk(clk),.rst(rst),.rs(rs),.en(en),.rw(rw),.data(data),.key1(key1_out),.key2(key2_out),.key3(key3_out));//=============key1,key2,key3 按键防抖动================// reg key1_reg1,key1_reg2;reg key2_reg1,key2_reg2;reg key3_reg1,key3_reg2;reg [31:0] count;always @(posedge clk)begincount<=count+1;if(count==500000)begincount<=0;key1_reg1<=key1;key2_reg1<=key2;key3_reg1<=key3;endkey1_reg2<=key1_reg1;key2_reg2<=key2_reg1;key3_reg2<=key3_reg1;key1_out <= key1_reg2 & (!key1_reg1);key2_out <= key2_reg2 & (!key2_reg1);key3_out <= key3_reg2 & (!key3_reg1);endendmodule底层模块:module disp(rst,clk,rw,rs,en,data,key1,key2,key3);input clk,rst;input key1,key2,key3;output rs,en,rw;output [7:0] data;reg rs,en_sel;reg [7:0] data;reg [14:0] year;reg [7:0] shi,fen,miao,month,dat;reg [31:0]count,count1; //LCD CLK 分频计数器reg lcd_clk;//2行32个数据寄存器reg [7:0]one_1,one_2,one_3,one_4,one_5,one_6,one_7,one_8,one_9,one_10,one_11,one_12,on e_13,one_14,one_15,one_16;reg [7:0]two_1,two_2,two_3,two_4,two_5,two_6,two_7,two_8,two_9,two_10,two_11,two_12,two_ 13,two_14,two_15,two_16;reg [7:0] next;parameter state0 =8'h00, //设置8位格式,2行,5*7 8'h38;state1 =8'h01, //整体显示,关光标,不闪烁8'h0C 闪烁8'h0estate2 =8'h02, //设定输入方式,增量不移位8'h06state3 =8'h03, //清除显示8'h01state4 =8'h04, //显示第一行的指令80Hstate5 =8'h05, //显示第二行的指令80H+40Hscan =8'h06,nul =8'h07;parameter data0 =8'h10, //2行32个数据状态data1 =8'h11,data2 =8'h12,data3 =8'h13,data4 =8'h14,data5 =8'h15,data6 =8'h16,data7 =8'h17,data8 =8'h18,data9 =8'h19,data10 =8'h20,data11 =8'h21,data12 =8'h22,data13 =8'h23,data14 =8'h24,data15 =8'h25,data16 =8'h26,data17 =8'h27,data18 =8'h28,data19 =8'h29,data20 =8'h30,data21 =8'h31,data22 =8'h32,data23 =8'h33,data24 =8'h34,data25 =8'h35,data26 =8'h36,data27 =8'h37,data28 =8'h38,data29 =8'h39,data30 =8'h40,data31 =8'h41;initialbegin//第一行显示年-月-日星期//Mon Tue Wed Thur Fri Sat Sunone_1<=" "; one_2<=" "; one_3<=" "; one_4<=" "; one_5<="-"; one_6<=" "; one_7<=" "; one_8<="-";one_9<=" ";one_10<=" ";one_11<=" ";one_12<=" ";one_13<=" ";one_14<="";one_15<=" ";one_16<=" ";//第二行显示Clock:00-00-00two_1<="C"; two_2<="l"; two_3<="o"; two_4<="c"; two_5<="k"; two_6<=":"; two_7<=" "; two_8<=" ";two_9<="-";two_10<=" ";two_11<=" ";two_12<="-";two_13<=" ";two_14<="";two_15<=" ";two_16<=" ";shi<=8'd0;fen<=8'd0;miao<=8'd0;end//======================产生LCD 时序脉冲=========================== always @ (posedge clk ) //获得LCD时钟begincount<=count+1;if(count==32'd50000)begincount<=32'b0;lcd_clk<=~lcd_clk;endend//=====================产生闪烁扫描时钟===========================reg [31:0] count2;reg scan_flag;always @ (posedge clk or negedge rst) //获得校准时间选中闪烁状态beginif(!rst)beginscan_flag<=1'b0;endelsebegincount2<=count2+1;if(count2==32'd1*******)begincount2<=32'b0;scan_flag<=~scan_flag;endendend//====================产生按键标志位================================= reg [3:0] flag;always @ (posedge clk or negedge rst )beginif(!rst)beginflag<=4'b0;endelseif(key1)beginflag<=flag+1'b1;if(flag==4'b1000)flag<=4'b0000;endend//===================计时以及校准=======================================reg[3:0] week;reg[7:0] dat_flag;always @ (posedge clk or negedge rst ) //时钟计数器beginif(!rst)begin //初始化显示第一行2012-05-19 Sat 第二行:Clock:00-00-00 shi<=8'b0;fen<=8'b0;miao<=8'b0;month<=8'd5;dat<=8'd19;year<=16'd2012;week<=4'd5;count1<=1'b0;two_7<= (shi/8'd10)+8'b00110000;two_8<= (shi%8'd10)+8'b00110000;two_10<=(fen/8'd10)+8'b00110000;two_11<=(fen%8'd10)+8'b00110000;two_13<=(miao/8'd10)+8'b00110000;two_14<=(miao%8'd10)+8'b00110000;one_1<=(year/16'd1000)+8'b00110000;one_2<=((year%16'd1000)/16'd100)+8'b00110000;one_3<=((year%16'd100)/8'd10)+8'b00110000;one_4<=(year%8'd10)+8'b00110000;one_6<=(month/8'd10)+8'b00110000;one_7<=(month%8'd10)+8'b00110000;one_9<=(dat/8'd10)+8'b00110000;one_10<=(dat%8'd10)+8'b00110000;endelsebegintwo_7<= (shi/8'd10)+8'b00110000;two_8<= (shi%8'd10)+8'b00110000;two_10<=(fen/8'd10)+8'b00110000;two_11<=(fen%8'd10)+8'b00110000;two_13<=(miao/8'd10)+8'b00110000;two_14<=(miao%8'd10)+8'b00110000;one_1<=(year/16'd1000)+8'b00110000;one_2<=((year%16'd1000)/16'd100)+8'b00110000;one_3<=((year%16'd100)/8'd10)+8'b00110000;one_4<=(year%8'd10)+8'b00110000;one_6<=(month/8'd10)+8'b00110000;one_7<=(month%8'd10)+8'b00110000;one_9<=(dat/8'd10)+8'b00110000;one_10<=(dat%8'd10)+8'b00110000;// 判断是否为31天的月份if(month==8'd1||month==8'd3||month==8'd5||month==8'd7||month==8'd8||month==8'd10|| month==8'd12)dat_flag<=8'd31;// 判断是否为30天的月份else if(month==8'd4||month==8'd6||month==8'd9||month==8'd11)dat_flag<=8'd30;// 判断是否为闰年和平年else if(month==8'd2)beginif(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)dat_flag<=28;else dat_flag<=27;endcase (week)//星期//Mon Tue Wed Thu Fri Sat Sun4'b0000 : //1beginone_13<="M";one_14<="o";one_15<="n";end4'b0001 : //2beginone_13<="T";one_14<="u";one_15<="e";end4'b0010 : //3beginone_13<="W";one_14<="e";one_15<="d"; end4'b0011 : //4beginone_13<="T";one_14<="h";one_15<="u"; end4'b0100 : //5beginone_13<="F";one_14<="r";one_15<="i"; end4'b0101 : //6beginone_13<="S";one_14<="a";one_15<="t"; end4'b0110 : //7beginone_13<="S";one_14<="u";one_15<="n"; endendcasecase(flag)4'b0000 :beginen_sel<=1'b1;count1<=count1+1'b1;if(count1==32'd4*******)begincount1<=1'b0;miao<=miao+1'b1;if(miao==8'd59)beginmiao<=1'b0;fen<=fen+1'b1;if(fen==8'd59)beginfen<=1'b0;shi<=shi+1'b1;if(shi==8'd23)beginshi<=1'b0;dat<=dat+1'b1;week<=week+1'b1;if(week==4'b0110)week<=1'b1;if(dat==dat_flag)begindat<=8'd1;month<=month+1'b1;if(month==8'd12)beginmonth<=8'd1;year<=year+1'b1;if(year==16'd9999)year<=16'd0; //可以计1万年endendendendendendend4'b0001 :begincount1<=32'b0;//shi<=shi;fen<=fen;miao<=miao;year<=year;month<=month;dat<=dat;week<=week;end4'b0010 : //调年begincase(scan_flag)1'b0:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;one_1<=8'd20;one_2<=8'd20;one_3<=8'd20;one_4<=8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endendcaseif(key2) //加数beginyear<=year+1'b1;if(year==16'd9999)year<=16'd0;endif(key3) //减数beginyear<=year-1'b1;if(year==16'd0)year<=16'd9999;endend4'b0011 : //调月begincase(scan_flag)1'b0:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;one_6<=8'd20;one_7<=8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endcaseif(key2) //加数beginmonth<=month+1'b1;if(month==8'd12)month<=8'd0;endif(key3) //减数beginmonth<=month-1'b1;if(month==8'd0)month<=8'd12;endend4'b0100 : //调日begincase(scan_flag)1'b0:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;one_9<=8'd20;one_10<=8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endendcaseif(key2) //加数begindat<=dat+1'b1;if(dat==dat_flag)dat<=8'd0;endif(key3) //减数dat<=dat-1'b1;if(dat==8'd0)dat<=dat_flag;endend4'b0101 : //调星期begincase(scan_flag)1'b0:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;one_13<=8'd20;one_14<=8'd20;one_15<=8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endendcaseif(key2) //加数beginweek<=week+1'b1;if(week==4'd6)week<=4'd0;endif(key3) //减数beginweek<=week-1'b1;if(week==4'd0)week<=4'd7;endend4'b0110 : //调时begincase(scan_flag)begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;two_7<= 8'd20;two_8<= 8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endendcaseif(key2) //加数beginshi<=shi+8'b00000001;if(shi==8'd23)shi<=8'b0;endif(key3) //减数beginshi<=shi-8'b00000001;if(shi==8'b0)shi<=23;endend4'b0111 : //调分begincase(scan_flag)1'b0:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;two_10<=8'd20;two_11<=8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endendcaseif(key2) //加数beginfen<=fen+8'b00000001;if(fen==8'd59)fen<=8'b0;endif(key3) //减数beginfen<=fen-8'b00000001;if(fen==8'b0)fen<=59;endend4'b1000 : //调秒begincase(scan_flag)1'b0:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;two_13<=8'd20;two_14<=8'd20;end1'b1:begincount1<=32'b0; //shi<=shi;fen<=fen;miao<=miao;endendcaseif(key2) //加数beginmiao<=miao+8'b00000001;if(miao==8'd59)miao<=8'b0;endif(key3) //减数beginmiao<=miao-8'b00000001;if(miao==8'b0)miao<=59;endendendcaseendendalways @(posedge lcd_clk )begincase(next)state0 :begin rs<=1'b0; data<=8'h38; next<=state1; endstate1 :begin rs<=1'b0; data<=8'h0e; next<=state2; endstate2 :begin rs<=1'b0; data<=8'h06; next<=state3; endstate3 :begin rs<=1'b0; data<=8'h01; next<=state4; endstate4 :begin rs<=1'b0; data<=8'h80; next<=data0; end //显示第一行data0 :begin rs<=1'b1; data<=one_1; next<=data1 ; enddata1 :begin rs<=1'b1; data<=one_2; next<=data2 ; enddata2 :begin rs<=1'b1; data<=one_3; next<=data3 ; enddata3 :begin rs<=1'b1; data<=one_4; next<=data4 ; enddata4 :data5 :begin rs<=1'b1; data<=one_6; next<=data6 ; enddata6 :begin rs<=1'b1; data<=one_7; next<=data7 ; enddata7 :begin rs<=1'b1; data<=one_8; next<=data8 ; enddata8 :begin rs<=1'b1; data<=one_9; next<=data9 ; enddata9 :begin rs<=1'b1; data<=one_10; next<=data10 ; enddata10 :begin rs<=1'b1; data<=one_11; next<=data11 ; enddata11 :begin rs<=1'b1; data<=one_12; next<=data12 ; enddata12 :begin rs<=1'b1; data<=one_13; next<=data13 ; enddata13 :begin rs<=1'b1; data<=one_14; next<=data14 ; enddata14 :begin rs<=1'b1; data<=one_15; next<=data15 ; enddata15 :begin rs<=1'b1; data<=one_16; next<=state5 ; endstate5:begin rs<=1'b0;data<=8'hC0; next<=data16; end //显示第二行data16 :begin rs<=1'b1; data<=two_1; next<=data17 ; enddata17 :begin rs<=1'b1; data<=two_2; next<=data18 ; enddata18 :begin rs<=1'b1; data<=two_3; next<=data19 ; enddata19 :begin rs<=1'b1; data<=two_4; next<=data20 ; enddata20 :data21 :begin rs<=1'b1; data<=two_6; next<=data22 ; enddata22 :begin rs<=1'b1; data<=two_7; next<=data23 ; enddata23 :begin rs<=1'b1; data<=two_8; next<=data24 ; enddata24 :begin rs<=1'b1; data<=two_9; next<=data25 ; enddata25 :begin rs<=1'b1; data<=two_10; next<=data26 ; end data26 :begin rs<=1'b1; data<=two_11; next<=data27 ; end data27 :begin rs<=1'b1; data<=two_12; next<=data28 ; end data28 :begin rs<=1'b1; data<=two_13; next<=data29 ; end data29 :begin rs<=1'b1; data<=two_14; next<=data30 ; end data30 :begin rs<=1'b1; data<=two_15; next<=data31 ; end data31 :begin rs<=1'b1; data<=two_16; next<=scan ; endscan : //交替更新第一行和第二行数据beginnext<=state4;enddefault: next<=state0;endcaseendassign en=lcd_clk && en_sel;assign rw=1'b0;endmodule。

相关文档
最新文档