He creado un proyecto que tiene un contador "contador" = entero. Necesito aumentar / disminuir un valor entero presionando los botones. El progreso tiene 2 entidades, la entidad 1 debería aumentar. el valor y la entidad 2 deberían disminuir el valor, ¿no puedo hacerlo con el componente cómo hacerlo?
-- component 1 -------------------------------
entity MyCounter is
port(
clock: in std_logic;
KEY: in std_logic;
counter: in integer range 0 to 15;
clk_out: out std_logic
);
end MyCounter;
architecture arch of MyCounter is
component decrease
port(
clock: in std_logic;
KEY: in std_logic;
counter: in integer range 0 to 15;
clk_out: out std_logic
);
end component;
begin
p1: process(clock, KEY)
variable counter : integer;
begin
if KEY = '1' then
counter <= counter + 1;
end if;
end process;
end arch;
-- component 2 -------------------------------
entity decrease is
port(
clock: in std_logic;
KEY: in std_logic;
counter: in integer range 0 to 15;
clk_out: out std_logic
);
end decrease ;
architecture arch of decrease is
begin
p1: process(clock, KEY)
begin
if KEY = '1' then
counter <= counter - 1;
end if;
end process;
end arch;