计数器的VHDL设计.docx

上传人:b****6 文档编号:13053792 上传时间:2023-06-10 格式:DOCX 页数:12 大小:109.08KB
下载 相关 举报
计数器的VHDL设计.docx_第1页
第1页 / 共12页
计数器的VHDL设计.docx_第2页
第2页 / 共12页
计数器的VHDL设计.docx_第3页
第3页 / 共12页
计数器的VHDL设计.docx_第4页
第4页 / 共12页
计数器的VHDL设计.docx_第5页
第5页 / 共12页
计数器的VHDL设计.docx_第6页
第6页 / 共12页
计数器的VHDL设计.docx_第7页
第7页 / 共12页
计数器的VHDL设计.docx_第8页
第8页 / 共12页
计数器的VHDL设计.docx_第9页
第9页 / 共12页
计数器的VHDL设计.docx_第10页
第10页 / 共12页
计数器的VHDL设计.docx_第11页
第11页 / 共12页
计数器的VHDL设计.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

计数器的VHDL设计.docx

《计数器的VHDL设计.docx》由会员分享,可在线阅读,更多相关《计数器的VHDL设计.docx(12页珍藏版)》请在冰点文库上搜索。

计数器的VHDL设计.docx

计数器的VHDL设计

计数器的VHDL设计

实验名称:

计数器的VHDL设计

一、带高电平使能信号,低电平清零信号,低电平置数信号的十进制计数器的VHDL设计

1.实体框图

2.程序设计

①编译前的程序

Libraryieee;

Useieee.std_logic_1164.all;

Useieee.std_logic_unsigned.all;

Entitycnt10is

Port(clk,RST,SET,EN:

instd_logic;

CQ:

outstd_logic_vector(3downto0);

Cout:

outstd_logic);

Endcnt10;

Architectureoneofcnt10is

Begin

Process(clk,RST,SET,EN)

VariableCQ1:

std_logic_vector(3downto0);

Begin

ifRST='0'ThenCQ1:

=(others=>'0');

elsifclk'eventandclk='1'then

ifSET='0'ThenCQ1:

=(others=>'1');

elsifEN='1'Then

ifCQ1<9ThenCQ1:

=CQ1+1;

elseCQ1:

=(others=>'0');

endif;

endif;

endif;

ifCQ1=9Thencout<='1';

elsecout<='0';

endif;

CQ<=CQ1;

Endprocess;

Endone;

②程序编译错误情况

错误:

Error(10500):

VHDLsyntaxerrorat/cnt10.vhd(12)neartext"?

;expecting":

",or","

标点符号格式输入不对引起的,切换到英文输入模式重新输入即可

③正确的程序

Libraryieee;

Useieee.std_logic_1164.all;

Useieee.std_logic_unsigned.all;

Entitycnt10is

Port(clk,RST,SET,EN:

instd_logic;

CQ:

outstd_logic_vector(3downto0);

Cout:

outstd_logic);

Endcnt10;

Architectureoneofcnt10is

Begin

Process(clk,RST,SET,EN)

VariableCQ1:

std_logic_vector(3downto0);

Begin

ifRST='0'ThenCQ1:

=(others=>'0');

elsifclk'eventandclk='1'then

ifSET='0'ThenCQ1:

=(others=>'1');

elsifEN='1'Then

ifCQ1<9ThenCQ1:

=CQ1+1;

elseCQ1:

=(others=>'0');

endif;

endif;

endif;

ifCQ1=9Thencout<='1';

elsecout<='0';

endif;

CQ<=CQ1;

Endprocess;

Endone;

3.仿真波形图

4.仿真波形分析

当低电平清零信号有效时,计数器清零;当低电平置数信号有效时,计数器置数

使能信号为高电平且脉冲上升沿有效时,计数器开始计数(从0到9)为十进制计数

一、64进制的二进制计数器的VHDL设计

1.实体框图

2.程序设计

①编译前的程序

Libraryieee;

Useieee.std_logic_1164.all;

Useieee.std_logic_unsigned.all;

Entitycnt64is

Port(clk:

instd_logic;

D:

instd_logic_vector(5downto0);

Q:

outstd_logic_vector(5downto0));

Endcnt64;

Architecturetwoofcnt64is

SignalQ1:

std_logic_vector(5downto0);

Begin

Process(clk)

Begin

ifclk'eventandclk='1'Then

if(Q1="011111")ThenQ1<="000000";

elseQ1<=Q1+1;

endif;

Endprocess;

Q<=Q1;

Endtwo;

②程序编译错误情况

Error(10500):

VHDLsyntaxerroratcnt64.vhd(18)neartext"process";expecting"if";

Error(10500):

VHDLsyntaxerroratcnt64.vhd(20)neartext"two";expecting"if"经过检查,发现原程序少了ENDIF,加上即可;

③正确的程序

Libraryieee;

Useieee.std_logic_1164.all;

Useieee.std_logic_unsigned.all;

Entitycnt64is

Port(clk:

instd_logic;

D:

instd_logic_vector(5downto0);

Q:

outstd_logic_vector(5downto0));

Endcnt64;

Architecturetwoofcnt64is

SignalQ1:

std_logic_vector(5downto0);

Begin

Process(clk)

Begin

ifclk'eventandclk='1'Then

if(Q1="011111")ThenQ1<="000000";

elseQ1<=Q1+1;

endif;

endif;

Endprocess;

Q<=Q1;

Endtwo;

3.仿真波形图

4.仿真波形分析

当脉冲信号为上升沿时,计数器开始计数(0到63),为64进制的二进制计数器

 

一、64进制的高四位、低四位的BCD码设计

1.实体框图

2.程序设计

①编译前的程序

Libraryieee;

Useieee.std_logic_1164.all;

Useieee.std_logic_unsigned.all;

EntityCDU_64is

Port(clk:

instd_logic;

Q:

outstd_logic_vector(7downto0));

EndCDU_64;

ArchitecturethreeofCDU_64is

Signalcout2,cout1:

std_logic_vector(3downto0);

Begin

Process(clk)

Begin

ifclk'eventandclk='1'Then

if(cout2=6andcout1=3)Then

cout2<="0000";cout1<="0000";

elseif(cout1=9)then

cout2<=cout2+1;cout1<="0000";

elsecout2<=cout2;cout1<=cout1+1;

endif;

endif;

endif;

Endprocess;

Q<=cout2&cout1;

Endthree;

②程序编译错误情况

③正确的程序

Libraryieee;

Useieee.std_logic_1164.all;

Useieee.std_logic_unsigned.all;

EntityCDU_64is

Port(clk:

instd_logic;

Q:

outstd_logic_vector(7downto0));

EndCDU_64;

ArchitecturethreeofCDU_64is

Signalcout2,cout1:

std_logic_vector(3downto0);

Begin

Process(clk)

Begin

ifclk'eventandclk='1'Then

if(cout2=6andcout1=3)Then

cout2<="0000";cout1<="0000";

elseif(cout1=9)then

cout2<=cout2+1;cout1<="0000";

elsecout2<=cout2;cout1<=cout1+1;

endif;

endif;

endif;

Endprocess;

Q<=cout2&cout1;

Endthree;

3.仿真波形图

4.仿真波形分析

64进制的BCD码设计:

分为高四位和低四位,当低四位从0到9时,高四位进1,直到低四位从0到9,使得高四位从0到6,最后一次低四位计数到3为止,实现64进制的BCD码计数功能

一、8位左移计数器的VHDL设计

1.实体框图

2.程序设计

①编译前的程序

Libraryieee;

Useieee.std_logic_1164.all;

Entityshfrtis

Port(clk,load:

instd_logic;

DIN:

instd_logic_vector(7downto0);

QB:

outstd_logic);

Endshfrt;

Architecturefourofshfrtis

Begin

process(clk,Load)

variableREG8:

std_logic_vector(7downto0);

Begin

ifclk'eventandclk='1'Then

ifload='1'ThenREG8:

=DIN;

elseREG8(7downto1):

=REG8(6downto0)

REG8(0):

='1';

endif;

endif;

QB<=REG8(7);

Endprocess;

Endfour;

②程序编译错误情况

错误Error(10500):

VHDLsyntaxerroratshfrt.vhd(16)neartext"REG8";expecting";"

发现原程序中少了一个分号,添加后即可。

③正确的程序

Libraryieee;

Useieee.std_logic_1164.all;

Entityshfrtis

Port(clk,load:

instd_logic;

DIN:

instd_logic_vector(7downto0);

QB:

outstd_logic_vector(7downto0));

Endshfrt;

Architecturefourofshfrtis

Begin

process(clk,Load)

variableREG8:

std_logic_vector(7downto0);

Begin

ifclk'eventandclk='1'Then

ifload='1'ThenREG8:

=DIN;

elseREG8(7downto1):

=REG8(6downto0);

REG8(0):

='1';

endif;

endif;

QB<=REG8;

Endprocess;

Endfour;

3.仿真波形图

4.仿真波形分析

当load=1且为下降沿时开始左移移位,最低位补‘1’,输出端为8位同时输出,即实现了并行输出的功能。

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

当前位置:首页 > PPT模板 > 动态背景

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

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