counter3.vhd

来自「vhdl code for GIF Image Viewer」· VHDL 代码 · 共 36 行

VHD
36
字号
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity counter3 is
	 generic ( size : integer := 16);
    Port (cop: IN std_logic_vector(1 downto 0);
	 			reset: IN std_logic;
				clk: IN std_logic;
				outdata: OUT std_logic_vector(size-1 downto 0)
	 );
end counter3;

architecture Behavioral of counter3 is

begin

PROCESS (clk)
variable output: integer;
begin

if (clk'EVENT and clk='1') THEN
	if (reset = '1') THEN output := 0; END IF;
    if (cop = "00") THEN output := output; END IF;
	if (cop = "01") THEN output := output + 1; END IF;
	if (cop = "10") THEN output := output - 1; END IF;


end if;

outdata <= conv_std_logic_vector(output, size);
end process;

end Behavioral;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?