I have create project witch has an "counter" counter = Integer. I need to increase/decrease an integer value by pressing the buttons. the progress has 2 entitys, entity 1 should increase the value and entity 2 should decrease the value, Im not allow to do so with component how to do this?
-- 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;