[an error occurred while processing this directive]
|
Вот пример аккумулятора.
library ieee,work;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.pack.all;
entity p_accumulator is
generic
(
width : INTEGER := 5
);
port
(
clk : in STD_LOGIC;
reset : in STD_LOGIC;
enable : in STD_LOGIC;
data : in STD_LOGIC_VECTOR (width-1 downto 0);
result : out STD_LOGIC_VECTOR (width-1 downto 0)
);
end p_accumulator;
architecture first of p_accumulator is
signal result_reg : STD_LOGIC_VECTOR (width-1 downto 0);
begin
process (clk, reset, enable, data)
begin
if (reset = '1') then
result_reg <= (others =>'0');
elsif rising_edge(clk) then
if (enable = '1') then
result_reg <= STD_LOGIC_VECTOR(UNSIGNED(data) + UNSIGNED(result_reg));
end if;
end if;
end process;
result <= result_reg;
end first;
E-mail: info@telesys.ru