基于VHDL任意进制计数器(100以内)设计.doc

上传人:聆听****声音 文档编号:1880653 上传时间:2023-05-02 格式:DOC 页数:12 大小:17.47MB
下载 相关 举报
基于VHDL任意进制计数器(100以内)设计.doc_第1页
第1页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第2页
第2页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第3页
第3页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第4页
第4页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第5页
第5页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第6页
第6页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第7页
第7页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第8页
第8页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第9页
第9页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第10页
第10页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第11页
第11页 / 共12页
基于VHDL任意进制计数器(100以内)设计.doc_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

基于VHDL任意进制计数器(100以内)设计.doc

《基于VHDL任意进制计数器(100以内)设计.doc》由会员分享,可在线阅读,更多相关《基于VHDL任意进制计数器(100以内)设计.doc(12页珍藏版)》请在冰点文库上搜索。

基于VHDL任意进制计数器(100以内)设计.doc

VHDL课程设计

选题:

任意进制计数器(100以内)设计

班级:

学号:

11200134

姓名:

2014/5/23

12

目录

1、设计选题:

任意进制计数器(100以内)设计 3

2、设计要求 3

3、设计原理分析 3

4、程序编写、调试及仿真 4

4.1程序编写 4

4.11、n进制计数器顶层程序:

4

4.12、10进制计数器程序:

5

4.13、LED译码器程序:

6

4.14、50M分频器程序:

6

4.15、5分频程序:

7

4.16、10分频程序:

8

4.2功能仿真和芯片时序仿真 9

4.21、5分频仿真波形 9

4.22、50分频仿真波形() 9

4.23、10进制计数器仿真波形 9

4.24、LED译码器仿真波形 10

4.25、78进制计数器仿真波形 10

4.3、芯片引脚设定 10

4.4、适配下载结果 11

5、设计总结 11

1、设计选题:

任意进制计数器(100以内)设计

2、设计要求

(1)计数基数由输入确定,并采用按键所存,即按键每按下一次,存储计数基数(20—100之间),计数基数采用8421BCD码表示,否则改变开关输入无效。

(2)计数频率要求为每秒计数1次(仿真时可以调整为每10us计数1次);

(3)计数值用共阴数码管静态显示(实验板上自带);

(2)设计中系统时钟采用验证电路板上的50MHz晶振作为基准,且设计成同步电路;

(4)程序设计尽可能考虑模块化、参数化设计思想,并遵循基本的格式规范,添加适当的注释及文档说明;

(5)采用模块化设计方式,底层模块必须进行功能仿真;

(6)下载调试并编写设计总结报告。

3、设计原理分析

先对50MHz时钟信号分频得到1Hz,然后调用两个10进制计数器,计数到所输入的计数周期n后回到初始0的计数状态,每个10进制计数的计数结果通过显示译码送到两位数码管上显示。

判断计数器(20-100之间)是否计满计数周期的方式是:

将计数基数采用两个8421BCD码表示,分别为ge[3:

0]、shi[3:

0],将两个计数器计数产生的中间结果分别用“按位异或”(每位使用“(not(cont_tmp10(3)xorshi(3))”的方式实现)分别比对,当ge、shi每位都相同时,则说明计数完毕,重新载入初值”0000”,同时产生进位信号en_out,之后进入下一次计数周期,并以此循环。

结构框图如下:

4、程序编写、调试及仿真

(芯片型号:

MAXⅡ系列EPM1270T144C5)

4.1程序编写

4.11、n进制计数器顶层程序:

libraryieee;

useieee.std_logic_1164.all;

entitycount_nis

port(clk,rst,en:

instd_logic;

ge,shi:

instd_logic_vector(3downto0);

count_data10,count_data1:

outstd_logic_vector(6downto0);

en_out:

outstd_logic

);

endcount_n;

architecturertlofcount_nis

componentdivide_50Mport(clk,rst:

instd_logic;en_out:

outstd_logic);

endcomponent;

componentcount_10port(clk,rst,en_in,ld:

instd_logic;

data_in:

instd_logic_vector(3downto0);

data_out:

outstd_logic_vector(3downto0);

en_out:

outstd_logic);

endcomponent;

componentdecodeport(data_in:

instd_logic_vector(3downto0);

dis_num:

outstd_logic_vector(6downto0));

endcomponent;

signalcont_tmp10,cont_tmp1,data_in:

std_logic_vector(3downto0);

signalld,ks,sec_en,sec_en10,min_out,fuwei:

std_logic;

begin

data_in<="0000";

ks<=sec_enanden;

ld<=((not(cont_tmp10(3)xorshi(3)))and(not(cont_tmp10

(2)xorshi

(2)))and(not(cont_tmp10

(1)xorshi

(1)))and(not(cont_tmp10(0)xorshi(0)))and(not(cont_tmp1(3)xorge(3)))and(not(cont_tmp1

(2)xorge

(2)))and(not(cont_tmp1

(1)xorge

(1)))and(not(cont_tmp1(0)xorge(0))));

en_out<=ld;

U0:

divide_50Mportmap(clk,rst,sec_en);

U1:

count_10portmap(clk,rst,ks,ld,data_in,cont_tmp1,sec_en10);

U2:

count_10portmap(clk,rst,sec_en10,ld,data_in,cont_tmp10,min_out);

U3:

decodeportmap(cont_tmp1,count_data1);

U4:

decodeportmap(cont_tmp10,count_data10);

endrtl;

4.12、10进制计数器程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entitycount_10is

port(clk,rst,en_in,ld:

instd_logic;

data_in:

instd_logic_vector(3downto0);

data_out:

outstd_logic_vector(3downto0);

en_out:

outstd_logic

);

endcount_10;

architecturertlofcount_10is

signalcont_tmp:

std_logic_vector(3downto0);

begin

en_out<=en_inandcont_tmp(3)andcont_tmp(0);

data_out<=cont_tmp;

process(clk,rst)

begin

if(rst='0')then

cont_tmp<="0000";

elsif(clk'eventandclk='1')then

if(ld='1')then

cont_tmp<=data_in;

elsif(en_in='1')then

if(cont_tmp="1001")then

cont_tmp<="0000";

else

cont_tmp<=cont_tmp+'1';

endif;

endif;

endif;

endprocess;

endrtl;

4.13、LED译码器程序:

libraryieee;

useieee.std_logic_1164.all;

entitydecodeis

port(data_in:

instd_logic_vector(3downto0);

dis_num:

outstd_logic_vector(6downto0)

);

enddecode;

architecturertlofdecodeis

begin

withdata_inselect

dis_num<="0111111"WHEN"0000",

"0000110"WHEN"0001",

"1011011"WHEN"0010",

"1001111"WHEN"0011",

"1100110"WHEN"0100",

"1101101"WHEN"0101",

"1111101"WHEN"0110",

"0000111"WHEN"0111",

"1111111"WHEN"1000",

"1100111"WHEN"1001",

"0000000"WHENothers;

endrtl;

4.14、50M分频器程序:

libraryieee;

useieee.std_logic_1164.all;

entitydivide_50Mis

port(clk,rst:

instd_logic;

en_out:

outstd_logic

);

enddivide_50M;

architecturertlofdivide_50Mis

componentdivide_5port(clk,rst,en_in:

instd_logic;

en_out:

outstd_logic

);

endcomponent;

componentdivide_10port(clk,rst,en_in:

instd_logic;

en_out:

outstd_logic

);

endcomponent;

signalen0,en1,en2,en3,en4,en5,en6,en7:

std_logic;

begin

en_out<=en7;

U0:

divide_5portmap(clk,rst,'1',en0);

U1:

divide_10portmap(clk,rst,en0,en1);

U2:

divide_10portmap(clk,rst,en1,en2);

U3:

divide_10portmap(clk,rst,en2,en3);

U4:

divide_10portmap(clk,rst,en3,en4);

U5:

divide_10portmap(clk,rst,en4,en5);

U6:

divide_10portmap(clk,rst,en5,en6);

U7:

divide_10portmap(clk,rst,en6,en7);

endrtl;

4.15、5分频程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entitydivide_5is

port(clk,rst,en_in:

instd_logic;

en_out:

outstd_logic

);

enddivide_5;

architecturertlofdivide_5is

signalcont_tmp:

std_logic_vector(2downto0);

begin

en_out<=en_inandcont_tmp

(2);

process(clk,rst)

begin

if(rst='0')then

cont_tmp<="000";

elsif(clk'eventandclk='1')then

if(en_in='1')then

if(cont_tmp="100")then

cont_tmp<="000";

else

cont_tmp<=cont_tmp+'1';

endif;

endif;

endif;

endprocess;

endrtl;

4.16、10分频程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

useieee.std_logic_arith.all;

entitydivide_10is

port(clk,rst,en_in:

instd_logic;

en_out:

outstd_logic

);

enddivide_10;

architecturertlofdivide_10is

signalcont_tmp:

std_logic_vector(3downto0);

begin

en_out<=en_inandcont_tmp(3)andcont_tmp(0);

process(clk,rst)

begin

if(rst='0')then

cont_tmp<="0000";

elsif(clk'eventandclk='1')then

if(en_in='1')then

if(cont_tmp="1001")then

cont_tmp<="0000";

else

cont_tmp<=cont_tmp+'1';

endif;

endif;

endif;

endprocess;

endrtl;

4.2功能仿真和芯片时序仿真

4.21、5分频仿真波形

4.22、50分频仿真波形()

因为要有个大数据量,仿真不容易进行,所以在此我们改编仿真50分频的波形。

4.23、10进制计数器仿真波形

4.24、LED译码器仿真波形

4.25、78进制计数器仿真波形

4.3、芯片引脚设定

4.4、适配下载结果

5、设计总结

本设计实现了n进制(20-100之间)计数器的功能设计,涉及到了分频器、译码器、10进制计数器的设计以及从元件例化,然后到调用的层次化、结构化系统设计的方法,整个程序层次清晰,易于理解和实现。

实验结构层次如下:

在具体设计过程中,系统时钟采用验证电路板上的50MHz晶振作为基准,对50MHz时钟信号分频得到1Hz,然后调用两个10进制计数器,计数到所输入的计数周期n后回到初始0的计数状态,每个10进制计数的计数结果经过显示译码后送到两位数码管上显示。

判断计数器(20-100之间)是否计满计数周期的方式是:

将计数基数采用两个8421BCD码表示,分别为ge[3:

0]、shi[3:

0],将两个计数器计数产生的中间结果cont_tmp10[3:

0])、cont_tmp1[3:

0])分别用“按位异或”(每位使用“(not(cont_tmp10(x)xorshi(x))”的方式实现)分别比对,当ge、shi每位都相同时,则说明计数完毕,重新载入初值”0000”,同时产生进位信号en_out,之后进入下一次计数周期,并以此循环。

启动计数的时候通过一个使能端en,使用语句ks<=sec_enanden;(其中sec_en是50M分频的信号输出端)进行组合,之后将ks信号接到各位10进制计数器的使能端,从能来控制计数的开始和停止。

在输入计数基数的时候(20-100之间),因为计数是对应于计数状态的个数多少,又初始状态为零,为了使程序简单,先将计数基数减1后再送入到所对应的输入信号端ge[3:

0]、shi[3:

0],之后再启动计数。

通过本次“任意进制计数器(100以内)设计”的整个设计过程,熟悉QuartusII的开发环境、熟练掌握了编程开发流程,初步掌握了数字系统中层次化、结构化、模块化的VHDL设计思想,为以后完成更加复杂的数字系统奠定了一定的基础。

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

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2