Hi all! Iam having a problem to compile my vhdl code in quartus II, it just stuck and I have to end task. If someone find the problem in the code below, I would be thankful.
Some points: Im brazilian, so some words are in portuguese. Its just a semaphore (semaforo) that have some time to change colors. I could just put some delay and change output, but I have to do this using fsm. The clock is set to 1hz, so T=1s per clock. Verm=red color, amar=yellow color and verde=green color.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity semaforo is
port (clock,resetn: in std_logic;
verm,amar,verde: out std_logic);
end;
architecture circuito of semaforo is
type estado is (red,yellow,green);
signal atual,proximo: estado;
begin
process (clock,resetn)
begin
if (resetn='0') then
atual<=red; --begin in red color
elsif (clock'event and clock='1') then
atual<=proximo; --actual receive next
end if;
end process;
process (atual)
variable count: integer:=0;
begin
case (atual) is
when red =>
verm<='1';
amar<='0';
verde<='0';
--wait for 5sec; it would works if wasnt process sensitive
--proximo<=green;
count:=0;
while (count<5) loop
IF (clock'event and clock='1') then
count:=count+1;
end if;
end loop;
if (count=5) then
proximo<=green;
else
proximo<=atual;
end if;
when green =>
verm<='0';
amar<='0';
verde<='1';
count:=0;
while (count<7) loop
IF (clock'event and clock='1') then
count:=count+1;
end if;
end loop;
if (count=7) then
proximo<=yellow;
else
proximo<=atual;
end if;
when yellow =>
verm<='0';
amar<='1';
verde<='0';
count:=0;
while (count<2) loop
IF (clock'event and clock='1') then
count:=count+1;
end if;
end loop;
if (count=2) then
proximo<=red;
else
proximo<=atual;
end if;
end case;
end process;
end circuito;
When I put loop off it works (not works, just compile)
Some points: Im brazilian, so some words are in portuguese. Its just a semaphore (semaforo) that have some time to change colors. I could just put some delay and change output, but I have to do this using fsm. The clock is set to 1hz, so T=1s per clock. Verm=red color, amar=yellow color and verde=green color.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity semaforo is
port (clock,resetn: in std_logic;
verm,amar,verde: out std_logic);
end;
architecture circuito of semaforo is
type estado is (red,yellow,green);
signal atual,proximo: estado;
begin
process (clock,resetn)
begin
if (resetn='0') then
atual<=red; --begin in red color
elsif (clock'event and clock='1') then
atual<=proximo; --actual receive next
end if;
end process;
process (atual)
variable count: integer:=0;
begin
case (atual) is
when red =>
verm<='1';
amar<='0';
verde<='0';
--wait for 5sec; it would works if wasnt process sensitive
--proximo<=green;
count:=0;
while (count<5) loop
IF (clock'event and clock='1') then
count:=count+1;
end if;
end loop;
if (count=5) then
proximo<=green;
else
proximo<=atual;
end if;
when green =>
verm<='0';
amar<='0';
verde<='1';
count:=0;
while (count<7) loop
IF (clock'event and clock='1') then
count:=count+1;
end if;
end loop;
if (count=7) then
proximo<=yellow;
else
proximo<=atual;
end if;
when yellow =>
verm<='0';
amar<='1';
verde<='0';
count:=0;
while (count<2) loop
IF (clock'event and clock='1') then
count:=count+1;
end if;
end loop;
if (count=2) then
proximo<=red;
else
proximo<=atual;
end if;
end case;
end process;
end circuito;
When I put loop off it works (not works, just compile)