1、计数器及数码显示综合设计北华航天工业学院EDA技术综合设计课程设计报告作者姓名:指导教师姓名:崔瑞雪完成时间:内容摘要在quatrusll 中 利用VHDL语言编写数码管显示程序,然后进行功能仿真,然 后进行锁定引脚,然后硬件进行下载,调试。关键词:VHDL,数码管显示,quatrusll ,时序仿真图。内容摘要 课程设计任务书 一、 实验目的 二、 硬件要求 三、 方案论证 四、 模块说明 1.计数器(COUnter60) .2.计数器(COUnter16) .3.计数器(COUnter12) .4.计数器(COUnter10) .6.译码器(deled) 7.分频器(div) 8.顶层文件
2、 五、 图7计数显示的整体连接图六、 实验步骤 七、 实验结果 八、 总结 九、 参考文献 IIIII.191111121212课程设计任务书总体设计要求和技术要点利用VHDL进行数字钟设计,主要完成以下功能:一、 实验目的1、 设计一个带使能输入、进位输出及同步清 0的增1十进制计数器。2、 设计一个带使能输入及同步清 0的增1十二进制计数器。3、 设计一个带使能输入及同步清 0的六十进制同步加法计数器。4、 设计一个四位二进制可逆计数器。7位数码管动态刷新5、 设计一个共阴7段数码管控制接口,要求:在时钟信号的控制下,使 显示上述计数器的计数结果。工作内容及时间进度安排课程设计成果实验目的
3、二、硬件要求1.主芯片 EPF10K10LC84-42.7个八段扫描共阴极数码显示管。3.三个按键开关(使能端,清零端,可逆端)三、方案论证本次设计中将任务分成几个部来完成分别是:分频部分、十进制计数器、十二进制计数器、十六进制可逆计数器、六十进制计数器、译码部分、时间扫描模块和顶层文件。分频部分:在这个部分里,接受20mhz的频率,然后分出1hz的计数频率和lOOhz的扫描频率。十进制计数器、十二进制计数器、六十进制计数器:在这个部分中要实现带使能输入、同步清0的增1十进制、十二进制、六十进制的计数器计数功能。使能端 en高电平有效计数器开始计数,高电平停止计数,清零端 CLR高电平清零低电
4、平正常计数。十六进制可逆计数器:在这个部分中要实现带使能输入、同步清 0的增1十六进制的可逆计数器计数功能。计数部分分为计数的个位和十位,使能端en高电平有效计数器开始计数,低电平停止计数,清零端 rst高电平清零低电平计数,可逆计数器的控制端plus_sub低电平实现加法计数器的功能,高电平实现减法计数器的功能。分时扫描及译码部分:在这个部分需设计一个共阴 7段数码管控制接口,在时钟信号的控制下,分时选择数码管显示相应计数器的计数脉冲,使 7位数码管动态刷新显示4个计数器的计数结果,并将送来的计数器的计算值转换为相应的段码在数码管上显示计数脉冲的个数。顶层文件:在这一部分确定上述几个部分中相
5、应输入输出端口的连接关系。四、模块说明计数器及数码显示的设计共化分为 3个模块:计数器,扫描电路(seltime ),译码电路(deled )。下面具体分析各个模块的原理、内容和功能。1.计数器(counter60)能够实现60进制循环计数,带有清零端clr ,受时钟上升沿信号控制,其文本语言(文件名:count60er.vhd )为底层文本,图1为计数器的仿真波形图。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;en tity coun ter60 isp ort(e n,clr,clk
6、:in std_logic;ql,qh:buffer std_logic_vector(3 dow nto 0);end coun ter60;architecture behave of coun ter60 is beginpro cess(e n, clr,clk)beginif(en=1)the n if(clkeve nt and clk=1)then if(clr=1)the nql0); qh0); elsif(ql=9)the n if(qh=5)the n qh=0000; ql=0000;elseqh=qh+1; ql=0000; end if;else ql=ql+1;e
7、nd if;end if;end if;end pro cess; end behave;V总1打电370. 0 ns 450. 0 ns 53口. D ns GIO. 0 nsIlli15.03*0elkB -VLnnmwLRRRrLRrLrLnRrLrLJumrwLRnTLrLrclrB :1 1 1 1电nB(1 1 1 11 1 1 - 1 1 1 . . 参3S qhH t3 右 一 * ; 一 X: i 5一 Xi0 11H I11 1 i r 1i .1 1 1 1 t 11 1 1 11 1 1 11 1 1 丨 11 1 1 1 11 1 r 1 - f - 1 -1 1 1
8、 11 1 11 1 III1 1 .1 r 11 r - 1 图1. 六十进制秒计数器的仿真波形2.计数器(counter16)能够实现16进制可逆循环计数,带有清零端 clr ,受时钟上升沿信号控制,其文本 语言(文件名:count16er.vhd )为底层文本,图2为计数器的仿真波形图。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;en tity coun ter16 isp ort(e n,clr,clk:i n std_logic;plu s_sub:i n std_logic;
9、ql,qh:buffer std_logic_vector(3 dow nto 0); end coun ter16;architecture behave of coun ter16 isbeginpro cess(e n, clr,clk ,pl us_sub)beginif(en=1)the nif(clkeve nt and clk=1)the nif(clr=1)the nql0);qh0);elsif( plu s_sub=1)the nif(qh=1 and ql=5)the nql=0000;qh=0000;elsif(ql=9)the n qh=0001; ql=0000;
10、else ql=ql+1; end if; elsif( plus_sub=O)the n if(qh=O and ql=O)then ql=0101; qh=0001; elsif(ql=O)the n ql=1001; qh=0000;elseql=ql-1; end if;end if;end if;end if;end pro cess;endbehave|N卯eValue15.03Leo, 口 ns 20. 0 ns 60. 0 ns 300. 0 ns 340.0 ns 390. 0 ns 42L1 1 1 1 1 pelkB :T_TrL_rT_L_rT_rTjrLr1 1 1
11、11 1 1 1 11 1 1 11 1 1 1AlclrB :eiiB :1 1 11 1 1 11 1 11 1 1A3._siibB :; i i1 1 1 1掰斗0 qhH t0 X 1 X40 QlH(,1 X. 8 X 0 X 1 X 2 X 3 X 4 X S X 0 X 1 it 2 X1 1 1 11 1 11 1 11 1 1 1i 11 1 11 1 1 11 1 11 1 1 -1 1 1 11图2. 十六进制分计数器的仿真波形3.计数器(counter12)能够实现12进制循环计数,带有清零端clr ,受时钟上升沿信号控制,其文本语言 (文件名:count12er.v
12、hd )为底层文本,图3为计数器的仿真波形图。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;en tity coun ter12 isp ort(e n,clr,clk:in std_logic;ql,qh:buffer std_logic_vector(3 dow nto 0);end coun ter12;architecture behave of coun ter12 isbeginp rocess(e n, clr,clk)beginif(en=1)the nif(clkeve
13、nt and clk=1)the nif(clr=1)the nql0); qhv=(others二0);elsif(qh=1 and ql=1)the n ql=0000; qh=0000; elsif(ql=9)the n qh=0001; ql=0000;elseql0); elsif(q=9)the nq=0000;elseq=q+1;end if;end if;end if;end p rocess;end behave;5.扫面器(seltime)此模块能够实现分别对前边的数值进行扫描,有清零段,复位段,以及上升沿有效, 其文本语言(文件名:seltime.vhd )为底层文本,图
14、5为计数器的仿真波形图。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;use ieee.std_logic_arith.all;en tity seltime isport(clk1,ret:i n std_logic;q10,q12l,q12h,q16l,q16h,q60l,q60h:in std_logic_vector(3 dow nto 0);q:out std_logic_vector(3 dow nto 0);sel:out std_logic_vector( 2 dow nt
15、o 0);end seltime;architecture behave of seltime issig nal coun t:std_logic_vector(2 dow nto 0);beginsel=co unt;p rocess(clk1,ret)beginif(ret=1)the ncou ntv=001;elsif(clk1eve nt and clk1-1)then if(coun t=7)the n coun t=001;elsecoun tqv=q16h;whe n010=qv=q16l;whe n011=qv=q60h;whe n100=qv=q60l;whe n101=
16、qv=q12h;whe n110=qv=q12l;whe n111=qv=q10;whe n others=nu II;end case;end p rocess;end behave;6.译码器(deled)此模块能够实现分别对前边的数值进行扫描,有清零段,复位段,以及上升沿有效, 其文本语言(文件名:deled.vhd )为底层文本,图6为计数器的仿真波形图。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;en tity deled isport(nu m:i n std_logic_v
17、ector(3 dow nto 0);led:out std_logic_vector(6 dow nto 0); end deled;architecture behave of deled is beg in led=1111110whe n num=0000else 0110000when num=0001else 1101101whe n num=0010else 1111001whe n num=0011else 0110011whe n num=0100else 1011011whe n num=0101else 1011111whe n nu m=0110else 1110000
18、when num=0111else 1111111whe n num=1000else 1111011whe n num=1001else 1110111whe n num=1010else 0011111whe n num=1011else 1001110whe n num=1100else 0111101whe n num=1101else 1001111whe n num=1110else 1000111when num=1111;end behave;半V ftl 11斗LI. 05D 015 03国numB 00iToTjf1001X1110Y0000昴5 ledE ainlooiy
19、11110111001111X1111110图6. 译码器的仿真波形7.分频器(div)此模块能够实现对接受的20mhz的频率进行分频,分别得到1hz的计数频率,和lOOhz的 扫描频率。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_ un sig ned.all;en tity div isport(clk:in std_logic;fclk100:buffer std_logic;fclk1:buffer std_logic);end div;architecture behave of div issig nal
20、c0 :std_logic_vector(25 dow nto 0); sig nal c1 :std_logic_vector(25 dow nto 0); beg inp rocess(clk)beginif(clkeve nt and clk=1)the nif(c0=20000000)the n c0=00000000000000000000000000; fclk1=not fclk1;elsec0=c0+1;end if;end if;if(clkeve nt and clk=1)the n if(c1=200000)then c1=000000000000000000000000
21、00; fclk100=not fclk100;elsec1=c1+1;end if;end if;end p rocess; end behave;8.顶层文件 利用元件例化,对各个模块进行连线。library ieee;use ieee.std_logic_1164.all;en tity over isport(pl us_sub,clk,e n,clr,ret: in std_logic;sel:out std_logic_vector(2 dow nto 0); led:out std_logic_vector(6 dow nto 0); end over;architecture
22、behave of over iscomponent divport(clk:in std_logic;fclk:buffer std_logic); end component;component coun terlO p ort(e n,clr,clk:i n std_logic;q:buffer std_logic_vector(3 dow nto 0);end component;component coun ter12p ort(e n,clr,clk:in std_logic;ql,qh:buffer std_logic_vector(3 dow nto 0); end compo
23、nent;component coun ter60p ort(e n,clr,clk:i n std_logic;ql,qh:buffer std_logic_vector(3 dow nto 0); end component;component coun ter16p ort(e n,clr,clk:i n std_logic;plu s_sub:i n std_logic;ql,qh:buffer std_logic_vector(3 dow nto 0); end component;component seltimeport(clk1,ret: in std_logic;q10,q1
24、2l,q12h,q16l,q16h,q60l,q60h:in std_logic_vector(3 dow nto 0); q:out std_logic_vector(3 dow nto 0);sel:out std_logic_vector( 2 dow nto 0);end component;component deledport(nu m:i n std_logic_vector(3 dow nto 0);led:out std_logic_vector(6 dow nto 0);end component;sig nal fcl_k: std_logic;sig nal q_10:
25、std_logic_vector(3 dow nto 0);sig nal q_12l:std_logic_vector(3 dow nto 0);sig nal q_12h:std_logic_vector(3 dow nto 0);sig nal q_60l:std_logic_vector(3 dow nto 0);sig nal q_60h:std_logic_vector(3 dow nto 0);sig nal q_16l:std_logic_vector(3 dow nto 0);sig nal q_16h:std_logic_vector(3 dow nto 0);sig na
26、l q_q:std_logic_vector(3 dow nto 0);beginu1:co un ter10 port map(en ,clr,fcl_k,q_10);u2:cou nter12 port ma p(e n,clr,fcl_k,q_12l,q_12h);u3:cou nter60 port map(en ,clr,fcl_k,q_60l,q_60h);port ma p(clk,ret,q_10,q_12l,q_12h,q_60l,q_60h,q_16l,q_16h,q_q,sel);port map(q_ q,led);port map (clk,fcl_k);u4:cou nter16 port map (e n,clr,fcl_k, plus_sub,q_16l,q_16h); u5:seltime u6:deled u7:div end behave;五、图7计数显示的整体连接图(1)(2)(3)(4)(5)图7. 计数显示模块连接示意图实验步骤安装quartus n软件,为本项设计建立文件夹。 输入设计项目的各个模块,存盘检查,编译并仿真至无误。调用底层文件的各个模块,连接
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1