两位十进制计数器VHDL.docx

上传人:b****5 文档编号:27598464 上传时间:2023-07-03 格式:DOCX 页数:10 大小:40.17KB
下载 相关 举报
两位十进制计数器VHDL.docx_第1页
第1页 / 共10页
两位十进制计数器VHDL.docx_第2页
第2页 / 共10页
两位十进制计数器VHDL.docx_第3页
第3页 / 共10页
两位十进制计数器VHDL.docx_第4页
第4页 / 共10页
两位十进制计数器VHDL.docx_第5页
第5页 / 共10页
点击查看更多>>
下载资源
资源描述

两位十进制计数器VHDL.docx

《两位十进制计数器VHDL.docx》由会员分享,可在线阅读,更多相关《两位十进制计数器VHDL.docx(10页珍藏版)》请在冰豆网上搜索。

两位十进制计数器VHDL.docx

两位十进制计数器VHDL

电子科技大学

实验报告

学生姓名:

范仁森学号:

2011032030016指导教师:

杜涛

学生姓名:

李彦龙学号:

2012032030019

学生姓名:

万金山学号:

2011032030030

一、实验室名称:

计算机大楼309

二、实验项目名称:

两位十进制计数器在7段数码管显示的设计

三、实验原理:

用FPGA板上的晶振频率为33.86MHz的时钟进行2的25次方分频作为基准频率,然后用两位十进制计数器计数,计数结果输出至七段数码管显示器的数据端。

再将时钟进行2的19次方分频作为数码管扫描频率,接到数码管的共阴极端。

其中七段数码管由8个(a,b,c,d,e,f,g,dp)按照一定位置排列的发光二极管构成,通常采取共阴极或者共阳极的设计,将8个二极管的同一极接在一起,通过分别控制另外的8个电极的电平,使二极管导通(发光)或截止(不发光)。

  

4、实验目的:

1、掌握七段数码管译码器的工作原理;

 2、掌握设计两位十进制计数器。

3、学会运用波形仿真测试检验程序的正确性。

 

5、实验内容:

用VHDL设计两位十进制计数器在7段数码管显示的设计,并在VHDL描述的测试平台下对译码器进行功能仿真,给出仿真的波形,并在FPGA板上测试。

六、实验器材(设备、元器件):

电脑一台,Active-HDL,30MHzFPGA开发板

七、实验步骤:

程序:

顶层BDE设计

U1部分:

div25:

将晶振信号进行2的25次方分频作为计数基准频率

libraryIEEE;

useIEEE.STD_LOGIC_1164.all;

useieee.std_logic_unsigned.all;

entitydiv25is

port(

clk:

inSTD_LOGIC;

clr:

inSTD_LOGIC;

div_25:

outSTD_LOGIC

);

enddiv25;

architecturediv25ofdiv25is

signalcount:

std_logic_vector(24downto0);----为分频器设置一个中间信号

begin

process(clk,clr)

begin

if(clr='1')then

count<="0000000000000000000000000";----初始化

elsif(clk'eventandclk='1')then----上升延触发

if(count="1111111111111111111111111")then----将时钟频率分频至接近1Hz

count<="0000000000000000000000000";---进位

else

count<=count+1;---计数

endif;

endif;

endprocess;

div_25<=count(24);----输出1Hz信号

enddiv25;

U3部分:

count---十进制的个位计数器

libraryIEEE;

useIEEE.STD_LOGIC_1164.all;

useieee.std_logic_unsigned.all;

entitycountis

port(

clk:

inSTD_LOGIC;

clr:

inSTD_LOGIC;

en:

inSTD_LOGIC;

count_4:

outstd_logic_vector(3downto0);

cin:

outstd_logic

);

endcount;

architecturecountofcountis

signalcount_3:

std_logic_vector(3downto0);----计数十位数需要4位2进制

begin

count_4<=count_3;

process(clk,clr)

begin

if(clr='1')then

count_3<="0000";初始化

cin<='0';初始化

elsif(clk'eventandclk='1')then-----上升沿触发

if(en='1')then

if(count_3="1001")then-----进位

count_3<="0000";----进位

cin<='1';-----输出进位信号

else

count_3<=count_3+1;计数

cin<='0';重置进位信号

endif;

endif;

endif;

endprocess;

endcount;

U4部分:

count十进制的十位计数器

libraryIEEE;

useIEEE.STD_LOGIC_1164.all;

useieee.std_logic_unsigned.all;

entitycountis

port(

clk:

inSTD_LOGIC;

clr:

inSTD_LOGIC;

en:

inSTD_LOGIC;

count_4:

outstd_logic_vector(3downto0);

cin:

outstd_logic

);

endcount;

architecturecountofcountis

signalcount_3:

std_logic_vector(3downto0);

begin

count_4<=count_3;

process(clk,clr)

begin

if(clr='1')then

count_3<="0000";-----初始化

cin<='0';

elsif(clk'eventandclk='1')then

if(en='1')then

if(count_3="1001")then-----十进制计数

count_3<="0000";----进位重置

cin<='1';----输出进位信号

else

count_3<=count_3+1;-----计数

cin<='0';-----进位信号重置

endif;

endif;

endif;

endprocess;

endcount;

U2部分:

div19-----将晶振信号进行2的19次方分频作为扫描频率

libraryIEEE;

useIEEE.STD_LOGIC_1164.all;

useieee.std_logic_unsigned.all;

entitydiv19is

port(

clk:

inSTD_LOGIC;

clr:

inSTD_LOGIC;

div_19:

outSTD_LOGIC

);

enddiv19;

architecturediv19ofdiv19is

signalcount:

std_logic_vector(18downto0);

begin

process(clk,clr)

begin

if(clr='1')then

count<="0000000000000000000";-----初始化

elsif(clk'eventandclk='1')then

if(count="1111111111111111111")then

count<="0000000000000000000";-----进位重置

else

count<=count+1;------计数

endif;

endif;

endprocess;

div_19<=count(18);-----出接近64Hz的扫描信号

enddiv19;

U5部分:

mux2----将两位十进制进行扫描输出

libraryIEEE;

useIEEE.STD_LOGIC_1164.all;

entitymux2is

port(

a:

inSTD_LOGIC;

counter1:

inSTD_LOGIC_VECTOR(3downto0);

counter2:

inSTD_LOGIC_VECTOR(3downto0);

dout:

outSTD_LOGIC_VECTOR(3downto0)

);

endmux2;

architecturertlofmux2is

begin

process(a,counter1,counter2)

begin

if(a='0')then

dout<=counter1;----输出个位

elsif(a='1')then

dout<=counter2;------输出十位

endif;

endprocess;

endrtl;

U6部分:

decoder-----将两位十进制的数转换为七段显示码输出至显示管

libraryIEEE;

useIEEE.STD_LOGIC_1164.all;

entitydecoder7is

port(

din:

inSTD_LOGIC_VECTOR(3downto0);

dout:

outSTD_LOGIC_VECTOR(6downto0)

);

enddecoder7;

architecturertlofdecoder7is

signalindata:

std_logic_vector(3downto0);

begin

indata<=din;----载入数据

process(indata)

begin

caseindatais

when"0000"=>dout<="1111110";------输出0

when"0001"=>dout<="0110000";-----输出1

when"0010"=>dout<="1101101";-----输出2

when"0011"=>dout<="1111001";-----输出3

when"0100"=>dout<="0110011";----输出4

when"0101"=>dout<="1011011";-----输出5

when"0110"=>dout<="0011111";-----输出6

when"0111"=>dout<="1110000";-----输出7

when"1000"=>dout<="1111111";-----输出8

when"1001"=>dout<="1111011";-----输出9

whenothers=>dout<="0000000";-----输出0

endcase;

endprocess;

endrtl;

仿真:

 

在ise上FPGA板上I/O接口选择

clkP79,clrP109,enP114,com1P135,com2P133,

dout1P138,dout2P139,dout3P140,dout4P141,

dout5P143,dout6P144,dout7P146.

在ise上继续编译,

最后program下载进FPGA。

操作FPGA板:

按住s20右端键位,七段数码管显示0--99的数字。

按住s19左端键位,七段数码管归零。

8.实验结论及心得体会

通过两位十进制计数器的VHDL设计与ISE软件的实现,更加深了对七段数码管显示数字的功能的理解,为以后的学习奠定基础。

 

报告评分:

指导教师签字:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 可爱清新

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1