实验五 计数器设计
实验目的:计数器是实际中最为实用的时序电路模块之一,本实验的主要目的是
掌握使用 HDL 描述计数器类型模块的基本方法。
实验器材:EDA 开发软件(一套),微机(一台),实验开发系统(一台),其他
器件与材料(若干)
实验说明:计数器是数字电路系统中最基本的功能模块之一,设计时可采用原理
图或 HDL 语言完成。下载验证时的计数时钟可选用连续或单脉冲,并
用数码管显示计数值。
实验结果:
源程序:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count is
port( en:in std_logic;
re:in std_logic;
clk:in std_logic;
b:out std_logic_vector(3 downto 0);
co:out std_logic);
end count;
architecture one of count is
begin
process(en,re,clk)
variable qq:
begin
std_logic_vector(3 downto 0);
if re='0' then
if en='1' then
if clk='1' and clk'event then
if qq<"1001" then
qq:=qq+1;
else qq:="0000";
end if;
else qq:=qq;
end if;
else qq:=qq;
end if;
else qq:="0000";
end if;
if qq="1001" then co<='1';
else co<='0';
end if;
b<=qq;
end process;
end architecture;
波形图: