计数器及数码显示综合设计.docx
《计数器及数码显示综合设计.docx》由会员分享,可在线阅读,更多相关《计数器及数码显示综合设计.docx(21页珍藏版)》请在冰豆网上搜索。
![计数器及数码显示综合设计.docx](https://file1.bdocx.com/fileroot1/2023-2/1/4f265a8b-4d02-4c87-9835-462b135248fd/4f265a8b-4d02-4c87-9835-462b135248fd1.gif)
计数器及数码显示综合设计
北华航天工业学院
《EDA技术综合设计》
课程设计报告
作者姓名:
指导教师姓名:
崔瑞雪
完成时间:
内容摘要
在quatrusll中利用VHDL语言编写数码管显示程序,然后进行功能仿真,然后进行锁定引脚,然后硬件进行下载,调试。
关键词:
VHDL,数码管显示,quatrusll,时序仿真图。
内容摘要
课程设计任务书
一、实验目的
二、硬件要求
三、方案论证
四、模块说明
1.计数器(COUnter60).....
2.计数器(COUnter16).....
3.计数器(COUnter12).....
4.计数器(COUnter10).....
6.译码器(deled)
7.分频器(div)
8.顶层文件
五、图7计数显示的整体连接图
六、实验步骤
七、实验结果
八、总结
九、参考文献
II
III
.1
9
11
11
12
12
12
课程设计任务书
总体设计要求和技术要点
利用VHDL进行数字钟设计,主要完成以下功能:
一、实验目的
1、设计一个带使能输入、进位输出及同步清0的增1十进制计数器。
2、设计一个带使能输入及同步清0的增1十二进制计数器。
3、设计一个带使能输入及同步清0的六十进制同步加法计数器。
4、设计一个四位二进制可逆计数器。
7位数码管动态刷新
5、设计一个共阴7段数码管控制接口,要求:
在时钟信号的控制下,使显示上述计数器的计数结果。
工作内容及时间进度安排
课程设计成果
实验目的
二、硬件要求
1.主芯片EPF10K10LC84-4
2.7个八段扫描共阴极数码显示管。
3.三个按键开关(使能端,清零端,可逆端)
三、方案论证
本次设计中将任务分成几个部来完成分别是:
分频部分、十进制计数器、十二进
制计数器、十六进制可逆计数器、六十进制计数器、译码部分、时间扫描模块和顶层
文件。
分频部分:
在这个部分里,接受20mhz的频率,然后分出1hz的计数频率和lOOhz
的扫描频率。
十进制计数器、十二进制计数器、六十进制计数器:
在这个部分中要实现带使能
输入、同步清0的增1十进制、十二进制、六十进制的计数器计数功能。
使能端en
高电平有效计数器开始计数,高电平停止计数,清零端CLR高电平清零低电平正常计
数。
十六进制可逆计数器:
在这个部分中要实现带使能输入、同步清0的增1十六进
制的可逆计数器计数功能。
计数部分分为计数的个位和十位,使能端en高电平有效计
数器开始计数,低电平停止计数,清零端rst高电平清零低电平计数,可逆计数器的
控制端plus_sub低电平实现加法计数器的功能,高电平实现减法计数器的功能。
分时扫描及译码部分:
在这个部分需设计一个共阴7段数码管控制接口,在时钟
信号的控制下,分时选择数码管显示相应计数器的计数脉冲,使7位数码管动态刷新
显示4个计数器的计数结果,并将送来的计数器的计算值转换为相应的段码在数码管
上显示计数脉冲的个数。
顶层文件:
在这一部分确定上述几个部分中相应输入输出端口的连接关系。
四、模块说明
计数器及数码显示的设计共化分为3个模块:
计数器,扫描电路(seltime),译码电路
(deled)。
下面具体分析各个模块的原理、内容和功能。
1.计数器(counter60)
能够实现60进制循环计数,带有清零端clr,受时钟上升沿信号控制,其文本语言
(文件名:
count60er.vhd)为底层文本,图1为计数器的仿真波形图。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycounter60is
port(en,clr,clk:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0));
endcounter60;
architecturebehaveofcounter60isbegin
process(en,clr,clk)
begin
if(en='1')thenif(clk'eventandclk='1')thenif(clr='1')then
ql<=(others=>'0');qh<=(others=>'0');elsif(ql=9)thenif(qh=5)thenqh<="0000";ql<="0000";
else
qh<=qh+1;ql<="0000";endif;
elseql<=ql+1;
endif;
endif;
endif;
endprocess;endbehave;
V总1打电
370.0ns450.0ns53口.DnsGIO.0ns
Illi
15.03
*0
elk
B-
VLnnmwLRRRrLRrLrLnRrLrLJumrwLRnTLrLr
clr
B:
1111
电n
B(
1111
111-11
■1■.■.■
参3
Sqh
Ht
…3「右一*;一X:
'i「5一「Xi
0<11
HI
1
11ir1
i.
1111't1
1111
11■11
111丨1
11111
11r1-[f-1-
1111
1■11
11III
11■.
1r1
1r-1■
图1.六十进制秒计数器的仿真波形
2.计数器(counter16)
能够实现16进制可逆循环计数,带有清零端clr,受时钟上升沿信号控制,其文本语言(文件名:
count16er.vhd)为底层文本,图2为计数器的仿真波形图。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycounter16is
port(en,clr,clk:
instd_logic;
plus_sub:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0));endcounter16;
architecturebehaveofcounter16is
begin
process(en,clr,clk,plus_sub)
begin
if(en='1')then
if(clk'eventandclk='1')then
if(clr='1')then
ql<=(others=>'0');
qh<=(others=>'0');
elsif(plus_sub='1')then
if(qh=1andql=5)then
ql<="0000";
qh<="0000";
elsif(ql=9)thenqh<="0001";ql<="0000";elseql<=ql+1;endif;elsif(plus_sub='O')thenif(qh=Oandql=O)thenql<="0101";qh<="0001";elsif(ql=O)thenql<="1001";qh<="0000";
else
ql<=ql-1;endif;
endif;
endif;
endif;
endprocess;
endbehave|
N卯e
Value
15.03
Leo,口ns2£0.0ns£60.0ns300.0ns340.0ns390.0ns42L
11111p
elk
B:
T_^T^rL_^_^_rT_^^L_rT_rTjrLr
1111
11111
1111
1111
Al
clr
B:
eii
B:
111
1111
111
111
A3
..._siib
B:
;ii
1111
掰斗
0qh
Ht
0■■X1■X
4
0Ql
H(
1X.8X0X1X2X3X4XSX0X1it2X
1111
111
111
1111
i1
111
1111
111
111-
1111
1
图2.十六进制分计数器的仿真波形
3.计数器(counter12)
能够实现12进制循环计数,带有清零端clr,受时钟上升沿信号控制,其文本语言(文件名:
count12er.vhd)为底层文本,图3为计数器的仿真波形图。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycounter12is
port(en,clr,clk:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0));
endcounter12;
architecturebehaveofcounter12is
begin
process(en,clr,clk)
begin
if(en='1')then
if(clk'eventandclk='1')then
if(clr='1')then
ql<=(others=>'0');qhv=(others二>'0');
elsif(qh=1andql=1)thenql<="0000";qh<="0000";elsif(ql=9)thenqh<="0001";ql<="0000";
else
ql<=ql+1;
endif;
endif;
endif;
endbehave;
Value
15.03
b
Name
elk
B:
B:
clr
B:
0qh
E00
a肛
E00
endprocess;
30.0ns90.0ns130.0ns170.0ns210.0nsE50.0ns
图3.十二进制分计数器的仿真波形
4.计数器(counter10)
能够实现10进制循环计数,带有清零端clr,受时钟上升沿信号控制,其文本语言(文件名:
count10er.vhd)为底层文本,图4为计数器的仿真波形图。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycounter10is
port(en,clr,clk:
instd_logic;
q:
bufferstd_logic_vector(3downto0));
endcounter10;
architecturebehaveofcounter10is
begin
process(clr,clk,en)
begin
if(en='1')then
if(clk'eventandclk='1')then
if(clr='1')then
qv=(others二>'0');elsif(q=9)then
q<="0000";
else
q<=q+1;
endif;
endif;
endif;
endprocess;
endbehave;
5.扫面器(seltime)
此模块能够实现分别对前边的数值进行扫描,有清零段,复位段,以及上升沿有效,其文本语言(文件名:
seltime.vhd)为底层文本,图5为计数器的仿真波形图。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
useieee.std_logic_arith.all;
entityseltimeis
port(
clk1,ret:
instd_logic;
q10,q12l,q12h,q16l,q16h,q60l,q60h:
instd_logic_vector(3downto0);
q:
outstd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0));
endseltime;
architecturebehaveofseltimeis
signalcount:
std_logic_vector(2downto0);
begin
sel<=count;
process(clk1,ret)
begin
if(ret='1')then
countv="001";
elsif(clk1'eventandclk1-1')thenif(count=7)thencount<="001";
else
count<=count+1;
endif;
endif;
casecountis
when"001"=>qv=q16h;
when"010"=>qv=q16l;
when"011"=>qv=q60h;
when"100"=>qv=q60l;
when"101"=>qv=q12h;
when"110"=>qv=q12l;
when"111"=>qv=q10;
whenothers=>nuII;
endcase;
endprocess;
endbehave;
6.译码器(deled)
此模块能够实现分别对前边的数值进行扫描,有清零段,复位段,以及上升沿有效,其文本语言(文件名:
deled.vhd)为底层文本,图6为计数器的仿真波形图。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitydeledis
port(
num:
instd_logic_vector(3downto0);
led:
outstd_logic_vector(6downto0));enddeled;
architecturebehaveofdeledisbeginled<="1111110"whennum="0000"else"0110000"whennum="0001"else"1101101"whennum="0010"else"1111001"whennum="0011"else"0110011"whennum="0100"else"1011011"whennum="0101"else"1011111"whennum="0110"else"1110000"whennum="0111"else"1111111"whennum="1000"else"1111011"whennum="1001"else"1110111"whennum="1010"else"0011111"whennum="1011"else"1001110"whennum="1100"else"0111101"whennum="1101"else"1001111"whennum="1110"else"1000111"whennum="1111";
endbehave;
•半
Vftl11^
斗LI.0
5D0
1503
国num
B00
iToTjf
1001
X
1110
Y
0000
昴5
□led
Eain
looiy
1111011
1001111
X
1111110
图6.译码器的仿真波形
7.分频器(div)
此模块能够实现对接受的20mhz的频率进行分频,分别得到1hz的计数频率,和lOOhz的扫描频率。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitydivis
port(
clk:
instd_logic;
fclk100:
bufferstd_logic;
fclk1:
bufferstd_logic);
enddiv;
architecturebehaveofdivis
signalc0:
std_logic_vector(25downto0);signalc1:
std_logic_vector(25downto0);begin
process(clk)
begin
if(clk'eventandclk='1')then
if(c0=20000000)thenc0<="00000000000000000000000000";fclk1<=notfclk1;
else
c0<=c0+1;
endif;
endif;
if(clk'eventandclk='1')thenif(c1=200000)thenc1<="00000000000000000000000000";fclk100<=notfclk100;
else
c1<=c1+1;
endif;
endif;
endprocess;endbehave;
8.顶层文件利用元件例化,对各个模块进行连线。
libraryieee;
useieee.std_logic_1164.all;
entityoveris
port(plus_sub,
clk,en,clr,ret:
instd_logic;
sel:
outstd_logic_vector(2downto0);led:
outstd_logic_vector(6downto0));endover;
architecturebehaveofoveris
componentdiv
port(
clk:
instd_logic;
fclk:
bufferstd_logic);endcomponent;
componentcounterlOport(en,clr,clk:
instd_logic;
q:
bufferstd_logic_vector(3downto0));
endcomponent;
componentcounter12
port(en,clr,clk:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0));endcomponent;
componentcounter60
port(en,clr,clk:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0));endcomponent;
componentcounter16
port(en,clr,clk:
instd_logic;
plus_sub:
instd_logic;
ql,qh:
bufferstd_logic_vector(3downto0));endcomponent;
componentseltime
port(
clk1,ret:
instd_logic;
q10,q12l,q12h,q16l,q16h,q60l,q60h:
instd_logic_vector(3downto0);q:
outstd_logic_vector(3downto0);
sel:
outstd_logic_vector(2downto0));
endcomponent;
componentdeled
port(
num:
instd_logic_vector(3downto0);
led:
outstd_logic_vector(6downto0));
endcomponent;
signalfcl_k:
std_logic;
signalq_10:
std_logic_vector(3downto0);
signalq_12l:
std_logic_vector(3downto0);
signalq_12h:
std_logic_vector(3downto0);
signalq_60l:
std_logic_vector(3downto0);
signalq_60h:
std_logic_vector(3downto0);
signalq_16l:
std_logic_vector(3downto0);
signalq_16h:
std_logic_vector(3downto0);
signalq_q:
std_logic_vector(3downto0);
begin
u1:
counter10portmap(en,clr,fcl_k,q_10);
u2:
counter12portmap(en,clr,fcl_k,q_12l,q_12h);
u3:
counter60portmap(en,clr,fcl_k,q_60l,q_60h);
portmap(clk,ret,q_10,q_12l,q_12h,q_60l,q_60h,q_16l,q_16h,q_q,sel);
portmap(q_q,led);
portmap(clk,fcl_k);
u4:
counter16portmap(en,clr,fcl_k,plus_sub,q_16l,q_16h);u5:
seltimeu6:
deledu7:
divendbehave;
五、图7计数显示的整体连接图
(1)
(2)
(3)
(4)
(5)
图7.计数显示模块连接示意图
实验步骤
安装quartusn软件,为本项设计建立文件夹。
输入设计项目的各个模块,存盘检查,编译并仿真至无误。
调用底层文件的各个模块,连接