求一个EDA高手帮我设计一个四位二进制计数器带复位的 谢谢 急~~~~

如题所述

第1个回答  2010-12-16
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt is
port(clk ,rst,ena: in std_logic;
q : out std_logic_vector(3 downto 0);
cout:out std_logic);
end cnt;
architecture one of cnt is
signal cqi : std_logic_vector(3 downto 0):="0000";
begin
p_reg:process(clk,rst,ena)
begin
if rst='1' then cqi<="0000";
elsif clk' event and clk='1' then
if ena='1' then --
if cqi<"1111" then
cqi<=cqi+1;
else cqi<="0000";
end if;
end if;
end if;

end process p_reg;
q<=cqi;
cout<=not(cqi(0)and cqi(1)and cqi(2)and cqi(3));
end one;本回答被网友采纳