EDA课程设计万年历_第1页
EDA课程设计万年历_第2页
EDA课程设计万年历_第3页
EDA课程设计万年历_第4页
EDA课程设计万年历_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、目录一、设计任务和要求1二、总体框图1三、选择器件2四、功能模块341日模块34.2月模块54.3年模块74.4星期模块84.5扫描模块94.6数码管模块114.7三八译码器124.8分频器模块14五总体电路设计图和硬件实现145.1程序仿真电路145.2硬件实现18六设计中存在的问题21七、深入研究21八、心得体会21简易万年历的设计一、设计任务和要求1.用七个七段数码管显示年的低两位,月,日和星期,并具有闰年判断功能;2.可以手动调整年,月,日,星期;3.在quartus ii 6.0中编写vhdl程序实现年,月,日星期各模块的功能;4.编写顶层程序将各模块连接起来实现万年历调时功能。二、

2、总体框图图1 总体框图上图为总体设计框图,主要有计数模块、年月日模块、分频模块和扫描译码显示模块组成。分频模块在外部时钟信号的作用下实现分频后将其分频信号分别输出给计数模块和扫描模块。在分频信号(日脉冲)作用下计数模块实现计数功能实现年月日计数功能,但其计数功能是在以bcd码形式所记录的。这就需要扫描电路去扫描计数模块所输出的时间在500hz脉冲下经过译码器将其译成共阴数码管所对应的二进制数进行显示,最终显示的为年月日。外部时间控制信号可控制时间的校验。三、选择器件1、pc机一台。2、cpld/fpga适配器板:标准配置epf10k10lc84-4接口板,下载接口是数字芯片的下载接口(digi

3、tal jtag),主要用于cpld/fpga芯片的数据下载。3、实验箱:装有七段数码管及蜂鸣器等,七段数码管真值表及字型如下表1 七段数码管真值表输入输出字型dcba00001111110000101100000010110110100111111001010001100110101101101101101011111011111100001000111111110011111011七段数码管字形如下:图2 数码管字型图四、功能模块41日模块1.模块图图3 日模块图2.仿真图 图4 日模块仿真图clk:输入脉冲;pan:输入月的判断信号,0表示大月为31天,1表示小月30天,2表示平月为28

4、天,3表示闰月为29天;t1:日的个位;t2:日的十位;cout:进位信号,当pan=0的时候t2t1=31时产生进位,cout=1,当pan=1的时候t2t1=30时产生进位信号,cout=1,当pan=2的时候t2t1=28时产生进位,cout=1,当pan=3的时候t2t1=29时产生进位,cout=1。3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity tian is port(clk:in std_logic; pan: in std_logic_vector(1 do

5、wnto 0); t1,t2:out std_logic_vector(3 downto 0); cout:out std_logic); end;architecture one of tian issignal q1,q2:std_logic_vector(3 downto 0);signal ab:std_logic_vector(1 downto 0);begin process (clk,pan) begin if (clkevent and clk=1 )then 检测时钟上升沿 q1=q1+1; q1开始计数 if (q1=9 )then q1=0000; q2=q2+1; q1

6、=9时,q2开始计数且q1清零 end if; -abif (q2=3 )and q1=1 then q2=0000;q1=0000;cout=1; 当pan=00时,如果q2=3,q1=1,q2清零,q1从1开始计数并输出进位信号else coutif q2=3 and q1=0 then q2=0000;q1=0001;cout=1; 当pan=01时,如果q2=3,q1=0,q2清零,q1从1开始计数并输出进位信号else coutif q2=2 and q1=8 then q2=0000;q1=0001;cout=1; 当pan=10时,如果q2=2,q1=9,q2清零,q1从1开始计

7、数并输出进位信号elsif q2=2 and q1=9 then q2=0000;q1=0001;cout=1; 当pan=11时,如果q2=2,q1=8,q2清零,q1从1开始计数并输出进位信号else coutnull;end case;end if;end process;t1=q1;t2=q2;end one;4.2月模块1.模块图图5 月模块图2.仿真图图6 月模块仿真图clk:输入脉冲;pan:输出月的判断信号,1、3、5、7、8、10、12为大月输出pan=00,4、6、9、11为小月输出pan=01,闰年时2月为闰月输出pan=11,否则输出pan=10;y1:月的个位;y2:

8、月的十位;cout:进位信号,当y2y1等于12时输出cout=1;run:输入闰年信号,run=1时表示闰年,run=0时表示不是闰年。3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity yue is port(clk,run:in std_logic; cout:out std_logic; pan: out std_logic_vector(1 downto 0); y1,y2: out std_logic_vector(3 downto 0); end;architect

9、ure one of yue issignal q1,q2:std_logic_vector(3 downto 0);signal q3:std_logic_vector(7 downto 0);begin process (clk,run) begin if (clkevent and clk=1 )then 检测时钟上升沿 q1=q1+1; q1开始计数 if (q1=9 )then q1=0000; q2=q2+1; q1=9时,q2开始计数且q1清零 end if; if q1=2 and q2=1 then q1=0001;q2=0000;cout=1; q1=2,q2=1时,q2清

10、零,q1从1开始计数并输出进位信号 else cout=0; end if; end if; q3panif run=1 then pan=11;else panpanpanpanpanpanpanpanpanpanpanpan=00;end case;end process;y1=q1;y2=q2;end one;4.3年模块1.模块图图7 年模块图2.仿真图图8 年模块仿真图clk:输入脉冲;n1:年的个位;n2:年的十位;run:闰年信号输出,run=1时表示闰年,run=0时表示不是闰年,从n2n1=00开始,每4年输出一个闰年信号run=1。3.程序library ieee;use

11、ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity nian is port(clk:in std_logic; n1,n2:out std_logic_vector(3 downto 0); run:out std_logic); end;architecture one of nian issignal q1,q2,q3:std_logic_vector(3 downto 0);begin process (clk,q1,q2) begin if (clkevent and clk=1 )then 检测时钟上升沿 q

12、1=q1+1; q3=q3+1; if (q1=9 )then q1=0000; q2=q2+1; q1=9时,q2开始计数且q1清零 end if; if q3=3 then q3=0000; run=1; else run=0; end if; if q2=9 and q1=9 then q1=0000; q2=0000; end if;end if; end process;n1=q1;n2=q2;end one;4.4星期模块1模块图图9 星期模块图2仿真图图10 星期模块仿真图clk:输入脉冲;q1:从1到7变化;3程序library ieee;use ieee.std_logic_

13、1164.all;use ieee.std_logic_unsigned.all;entity xingqi is port(clk:in std_logic; q1:out std_logic_vector(3 downto 0);end xingqi;architecture one of xingqi is signal cq1:std_logic_vector(3 downto 0);beginprocess(clk) begin if clkevent and clk=1then 检测时钟上升沿 cq1=cq1+1; q1开始计数 if cq1=7 then cq1=0001; en

14、d if; end if;end process; q1=cq1; end;4.5扫描模块1.模块图图11 扫描模块该模块的功能是对输入信号依次进行扫描显示,产生对数码管的选择信号。reset为复位信号低电平有效。时钟信号clk1为1ns脉冲信号,依次扫描星期年月日输出,但速度十分快,可以看作是同时输出。daout输出依次是星期年月日输出,每位输出都为bcd码,sel为bcd码。2.仿真图图12 扫描模块仿真图3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_log

15、ic_arith.all;entity seltime is port( clk1,reset:in std_logic; nian1,nian2,yue1,yue2,tian1,tian2:in std_logic_vector(3 downto 0); xingqi:in std_logic_vector(3 downto 0); daout:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0);end seltime;architecture fun of seltime is - signal co

16、unt:std_logic_vector(2 downto 0);signal count:std_logic_vector(2 downto 0);begin sel=count; process(clk1,reset) begin if(reset=0)then 复位信号有效,输出为零 count=110)then count=000; else countdaoutdaoutdaoutdaoutdaoutdaoutdaout=xingqi(3 downto 0); - daout(1 downto 0)=xingqi(3 downto 0); end case; end process;

17、end fun; 4.6数码管模块1.模块图图13 数码管模块该模块的功能是将输入bcd码数转换为七段数码管需要的数据。将num中的bcd码编译到共阴数码管,显示为具有年月日的简易万年历。表2 数码管真值表numled000011111100001011000000101101101001111110010100011001101011011011011010111110111111000010001111111100111110111010111011110110011111110010011101101011110111101001111111110001112.仿真图图14 数码管模块仿

18、真图3.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity deled is port(num:in std_logic_vector(3 downto 0); led:out std_logic_vector(6 downto 0);end deled;architecture fun of deled isbegin led=1111110when num=0000else 0110000when num=0001else 1101101when num=0010else 111

19、1001when num=0011else 0110011when num=0100else 1011011when num=0101else 1011111when num=0110else 1110000when num=0111else 1111111when num=1000else 1111011when num=1001else 1000111when num=1111;end fun;4.7三八译码器1.模块图图15 三八译码器模块图该模块的功能是将输入bcd码数转换为七段数码管需要的数据,将seltime中的bcd码编译到共阴数码管,显示为具有年月日功能的简易万年历。2.仿真图

20、 图16 三八译码器仿真图表3 三八译码器真值表sel q011111110111111101211111011311110111411101111511011111610111111others111111113.程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity decode3_8 is port(sel:in std_logic_vector(2 downto 0); q:out std_logic_vector(7 downto 0) );end decode3_8;arch

21、itecture a of decode3_8 isbegin q=11111110when sel=0 else 11111101when sel=1 else 11111011when sel=2 else 11110111when sel=3 else 11101111when sel=4 else 11011111when sel=5 else 10111111when sel=6 else 11111111;end a;4.8分频器模块1.模块图图17 分频器模块图 该模块实现的功能是分频,clk_in 输入一个100mhz的脉冲信号,经过分频器后得到一个1hz的秒脉冲的脉冲信号。其

22、中是为扫描模块提供时钟信号。2.程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity div_clk is port(clk_in:in std_logic; div_out:out std_logic);end div_clk;architecture a of div_clk issignal fre_n:integer range 0 to 10;signal clk_tmp:std_logic;begin div_out=9 then fre_n=0; clk_tmp=not

23、 clk_tmp; else fre_n=fre_n+1; end if; end if; end process;end a;五总体电路设计图和硬件实现5.1程序仿真电路1.总电路图图18 总仿真电路图100mhz脉冲作为天计数信号输入使天计数,通过pan判断大小月及制计数,满进制后进位,进位信号作为月信号时钟使月以十二进制计数,满十二后进位,进位信号作为年时钟使年计数。同时100mhz脉冲还作为星期的计数信号,使星期以七进制循环。扫描电路有时间信号进来后在1000mhz时钟下进行快速扫描,经过译码器和七段数码管显示时间。2.仿真图图19 总体仿真图在clk信号为10ns,clkdsp信号为

24、1ns,reset高电平1无效时,出现正确的年月日循环,三八译码器可以正确编码。3.管脚分配图图20 管脚分配图4.总程序library ieee;use ieee.std_logic_1164.all;entity wannianli isport(clk:in std_logic;k1,k2:in std_logic;o1,o2,o3,o4,o5,o6,o7:out std_logic_vector(6 downto 0);d1,d2:out std_logic);end entity;architecture one of wannianli iscomponent tianport(c

25、lk:in std_logic;pan:in std_logic_vector(1 downto 0);t1,t2:out std_logic_vector(3 downto 0);cout:out std_logic);end component;component xingqi port(clk:in std_logic; q1:out std_logic_vector(3 downto 0);end component;component yueport(clk,run:in std_logic;cout:out std_logic;pan:out std_logic_vector(1

26、downto 0);y1,y2:out std_logic_vector(3 downto 0);end component;component nianport(clk:in std_logic;n1,n2:out std_logic_vector(3 downto 0);run:out std_logic);end component;component tiaoshiport(k1,k2:in std_logic;m1,m2:in std_logic;n1,n2:out std_logic;d1,d2:out std_logic);end component;component ledp

27、ort(ledi:in std_logic_vector(3 downto 0);ledo:out std_logic_vector(6 downto 0);end component;signal y1,y2,y3,y4,y5,y6,y7: std_logic_vector(3 downto 0);signal p: std_logic_vector(1 downto 0);signal c1,c2: std_logic;signal r: std_logic;signal ck1,ck2: std_logic;beginu1:tian port map(clk,p,y1,y2,c1);u2

28、:xingqi port map(clk,y7);u3: yue port map(ck1,r,c2,p,y3,y4);u4:nian port map(ck2,y5,y6,r);u5:tiaoshi port map(k1,k2,c1,c2,ck1,ck2,d1,d2);u6:led port map(y1,o1);u7:led port map(y2,o2);u8:led port map(y3,o3);u9:led port map(y4,o4);u10:led port map(y5,o5);u11:led port map(y6,o6);u12:led port map(y7,o7);end;5.2硬件实现 连线:用一根导线连clk与io3。经硬件测试,启动电源,数码管有正确的数字显示,即年月日、星期在实验箱上按正确的进制计数。1.总电路图:图21 总电路图2.实物图图22 02年8月22日 周一图23 12年12月31日 周二六设计中存在的问题1.程序在编写过程中不够细心,出现errors,最终根据提示一一改正;2.各个模块在单独仿真时能出现

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论