After being yesterday and today I have managed to solve a few problems but I've gotten stuck again. When doing the counter I have put a loop so that it counts from 1 to 53 and then reset to zero again. The problem appears when to check that it works correctly I start the testbench and the signal is not updated at all.
-- Process incorporated in vhdl
entity semaforo is
Port ( sensor : in STD_LOGIC;
clk : in STD_LOGIC;
rst_n : in STD_LOGIC;
light_highway : out STD_LOGIC_VECTOR (2 downto 0);
light_farm : out STD_LOGIC_VECTOR (2 downto 0));
end semaforo;
architecture Behavioral of semaforo is
signal cuenta: std_logic_vector(6 downto 0):="0000000";
begin
flip_flop: process (clk, rst_n)
begin
if (rst_n='0') then
light_highway <="001";
light_farm <="100";
elsif (clk'event and clk='1') then
if (sensor='1') then
light_highway<="010";
end if;
end if;
end process;
contador : process (clk, rst_n)
begin
if rst_n = '0' then
cuenta <= (others => '0');
elsif rising_edge(clk) then
if sensor = '1' then
if cuenta < 53 then
cuenta <= cuenta + 1;
else
cuenta <= (others => '0');
end if; -- count/wrap
end if; -- clock enable
end if; -- async reset/clock
end process;
end Behavioral;
In the case that you remove the for and simply update the counter directly if it works but I need the counter to start adding up from the first time that sensor = '1' and that once the account started it does not stop (even if the sensor signal) until you reach the limit. Attached also capture of the testbench.