计数器的vhdl设计

上传人:F****n 文档编号:105079621 上传时间:2019-10-11 格式:DOC 页数:9 大小:138KB
返回 下载 相关 举报
计数器的vhdl设计_第1页
第1页 / 共9页
计数器的vhdl设计_第2页
第2页 / 共9页
计数器的vhdl设计_第3页
第3页 / 共9页
计数器的vhdl设计_第4页
第4页 / 共9页
计数器的vhdl设计_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《计数器的vhdl设计》由会员分享,可在线阅读,更多相关《计数器的vhdl设计(9页珍藏版)》请在金锄头文库上搜索。

1、实验名称: 计数器的VHDL设计 一、带高电平使能信号,低电平清零信号,低电平置数信号的十进制计数器的VHDL设计1.实体框图2.程序设计编译前的程序Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity cnt10 isPort(clk,RST,SET,EN:in std_logic;CQ:out std_logic_vector(3 downto 0);Cout:out std_logic);End cnt10;Architecture one of cnt10 isBeginProce

2、ss(clk,RST,SET,EN)Variable CQ1:std_logic_vector(3 downto 0);Begin if RST=0 Then CQ1:=(others=0); elsif clkevent and clk=1 then if SET=0 Then CQ1:=(others=1); elsif EN=1 Then if CQ10); end if; end if; end if;if CQ1=9 Then cout=1; else cout=0;end if;CQ0); elsif clkevent and clk=1 then if SET=0 Then CQ

3、1:=(others=1); elsif EN=1 Then if CQ10); end if; end if; end if;if CQ1=9 Then cout=1; else cout=0;end if;CQ=CQ1;End process;End one;3.仿真波形图4.仿真波形分析当低电平清零信号有效时,计数器清零;当低电平置数信号有效时,计数器置数使能信号为高电平且脉冲上升沿有效时,计数器开始计数(从0到9)为十进制计数一、64进制的二进制计数器的VHDL设计1.实体框图2.程序设计编译前的程序Library ieee;Use ieee.std_logic_1164.all;Us

4、e ieee.std_logic_unsigned.all;Entity cnt64 isPort( clk:in std_logic; D:in std_logic_vector(5 downto 0); Q:out std_logic_vector(5 downto 0);End cnt64;Architecture two of cnt64 is Signal Q1: std_logic_vector(5 downto 0);BeginProcess(clk) Begin if clkevent and clk=1 Then if(Q1=) Then Q1=; else Q1=Q1+1;

5、 end if; End process;Q=Q1;End two;程序编译错误情况Error (10500): VHDL syntax error at cnt64.vhd(18) near text process; expecting if;Error (10500): VHDL syntax error at cnt64.vhd(20) near text two; expecting if经过检查,发现原程序少了END IF,加上即可;正确的程序Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.a

6、ll;Entity cnt64 isPort( clk:in std_logic; D:in std_logic_vector(5 downto 0); Q:out std_logic_vector(5 downto 0);End cnt64;Architecture two of cnt64 is Signal Q1: std_logic_vector(5 downto 0);BeginProcess(clk) Begin if clkevent and clk=1 Then if(Q1=) Then Q1=; else Q1=Q1+1; end if; end if; End proces

7、s;Q=Q1;End two;3.仿真波形图4.仿真波形分析当脉冲信号为上升沿时,计数器开始计数(0到63),为64进制的二进制计数器一、64进制的高四位、低四位的BCD码设计1.实体框图2.程序设计编译前的程序Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity CDU_64 isPort( clk:in std_logic;Q:out std_logic_vector(7 downto 0);End CDU_64 ;Architecture three of CDU_64 is Sig

8、nal cout2,cout1: std_logic_vector(3 downto 0);BeginProcess(clk) Begin if clkevent and clk=1 Then if(cout2=6 and cout1=3) Then cout2=0000; cout1=0000; else if (cout1=9)then cout2=cout2+1;cout1=0000; else cout2=cout2;cout1=cout1+1; end if; end if; end if; End process;Q=cout2 & cout1;End three;程序编译错误情况

9、无正确的程序Library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_unsigned.all;Entity CDU_64 isPort( clk:in std_logic;Q:out std_logic_vector(7 downto 0);End CDU_64 ;Architecture three of CDU_64 is Signal cout2,cout1: std_logic_vector(3 downto 0);BeginProcess(clk) Begin if clkevent and clk=1 Then if(

10、cout2=6 and cout1=3) Then cout2=0000; cout1=0000; else if (cout1=9)then cout2=cout2+1;cout1=0000; else cout2=cout2;cout1=cout1+1; end if; end if; end if; End process;Q=cout2 & cout1;End three;3.仿真波形图4.仿真波形分析64进制的BCD码设计:分为高四位和低四位,当低四位从0到9时,高四位进1,直到低四位从0到9,使得高四位从0到6,最后一次低四位计数到3为止,实现64进制的BCD码计数功能一、8位左移

11、计数器的VHDL设计1.实体框图2.程序设计编译前的程序Library ieee;Use ieee.std_logic_1164.all;Entity shfrt isPort( clk,load:in std_logic; DIN:in std_logic_vector(7 downto 0); QB:out std_logic);End shfrt;Architecture four of shfrt is Beginprocess(clk,Load)variable REG8:std_logic_vector(7 downto 0); Begin if clkevent and clk=1 Then if load=1 Then REG8:=DIN; else REG8(7 downto 1):=REG8(6 downto 0) REG8(0):=1; end if;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号