急求VHDL带异步清零和同步使能功能的四位加法计数器的源程序清单,谢谢~

2025年03月24日 04:02
有1个网友回答
网友(1):

VHDL语言设计一个带异步清零和同步使能的4位二进制加法计数器源程序如下,程序仿真结果如图所示

LIBRARY ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_unsigned.all;

--*-------------------------------------------------------*--

ENTITY counter4 IS                                       

PORT(clk    : in std_logic;                   

           clr    : in std_logic;

       enable : in std_logic;

              Q  : out std_logic_vector(3 downto 0));                     

End counter4;                                           

--*------------------------------------------------------*--

ARCHITECTURE arch OF counter4 IS

signal dout : std_logic_vector(3 downto 0);

begin

P1 :  process(clk,clr)

begin

if clr='0' then

dout <= "0000";

elsif clk'event and clk='1' then

if enable='1' then

dout <= dout+1;

elsif enable='0' then

dout <= dout;

end if;

end if;

end process P1;

P2 :  process(dout)

    begin 

Q <= dout;

end process P2;

end arch;

--*-------------------------------------------------------*--