Luis Daniel Bolaños
Member level 2
- Joined
- Apr 4, 2014
- Messages
- 47
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 8
- Activity points
- 342
Hey guys,
I am doing a Simon Says memory game with a Finite State Machine, but I keep getting these warnings about "Inferring latch(es)" in Quartus II. I need to get a clean synthesis without latches.
Please, have a look at my code.
ERROR
CODE
After the error, it also mentions "unsafe behaviour for the latch"
Thank you all :-D
I am doing a Simon Says memory game with a Finite State Machine, but I keep getting these warnings about "Inferring latch(es)" in Quartus II. I need to get a clean synthesis without latches.
Please, have a look at my code.
ERROR
Warning (10631): VHDL Process Statement warning at simon_fsm.vhd(63): inferring latch(es) for signal or variable "color", which holds its previous value in one or more paths through the process
Warning (10631): VHDL Process Statement warning at simon_fsm.vhd(63): inferring latch(es) for signal or variable "nivel", which holds its previous value in one or more paths through the process
Warning (10631): VHDL Process Statement warning at simon_fsm.vhd(63): inferring latch(es) for signal or variable "global", which holds its previous value in one or more paths through the process
Warning (10631): VHDL Process Statement warning at simon_fsm.vhd(63): inferring latch(es) for signal or variable "aux", which holds its previous value in one or more paths through the process
Warning (10631): VHDL Process Statement warning at simon_fsm.vhd(63): inferring latch(es) for signal or variable "input", which holds its previous value in one or more paths through the process
Warning (10631): VHDL Process Statement warning at simon_fsm.vhd(63): inferring latch(es) for signal or variable "nx_state", which holds its previous value in one or more paths through the process
CODE
Code:
library IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity simon_fsm is
port
(
reset, clk, verde_in, rojo_in, amarillo_in, azul_in, start : in std_logic;
secuencia: in std_logic_vector(44 downto 0);
color : out std_logic_vector(2 downto 0)
);
end entity;
architecture rtl of simon_fsm is
-- Construir el tipo estado
type estado is (s0, s1, s2, s3, s4, s5, s6);
-- Registro para almacenar los estados de la FSM
signal pr_state, nx_state : estado;
-- Convecion de Colores para VGA
constant azul : std_logic_vector(2 downto 0) := "001";
constant rojo : std_logic_vector(2 downto 0) := "100";
constant amarillo : std_logic_vector(2 downto 0) := "110";
constant verde : std_logic_vector(2 downto 0) := "010";
constant negro : std_logic_vector(2 downto 0) := "000";
constant blanco : std_logic_vector(2 downto 0) := "111";
signal global, nivel, aux: integer;
signal input: std_logic_vector(2 downto 0);
function sec_to_color(s: std_logic_vector(2 downto 0))
return std_logic_vector is
begin
case s is
when "000" => return azul;
when "001" => return azul;
when "010" => return verde;
when "011" => return verde;
when "100" => return rojo;
when "101" => return rojo;
when "110" => return azul;
when others => return verde;
end case;
end sec_to_color;
begin
-- Logica Secuencial
process (clk, reset)
begin
if reset = '1' then
pr_state <= s0;
elsif (rising_edge(clk)) then
pr_state <= nx_state;
end if;
end process;
-- Logica Combinacional
process (pr_state, start, nivel, global, aux, input, secuencia, verde_in, rojo_in, amarillo_in, azul_in)
begin
case pr_state is
when s0 =>
color <= blanco;
nivel <= 1;
global <= 0;
aux <= 0;
input <= "000";
if start = '1' then
nx_state <= s1;
end if;
when s1 =>
color <= sec_to_color(secuencia(44-3*global downto 42-3*global));
if global < nivel then
global <= global + 1;
else
global <= 0;
input <= "000";
nx_state <= s2;
end if;
when s2 =>
if aux = 0 then
color <= blanco;
aux <= 1;
else
color <= negro;
aux <= 0;
nx_state <= s3;
end if;
when s3 =>
if verde_in = '1' then
input <= verde;
elsif rojo_in = '1' then
input <= rojo;
elsif azul_in = '1' then
input <= azul;
elsif amarillo_in = '1' then
input <= amarillo;
else
input <= "000";
end if;
if input /= "000" then
nx_state <= s4;
end if;
when s4 =>
if input = sec_to_color(secuencia(44-3*aux downto 42-3*aux)) then
color <= input;
if aux >= nivel then
aux <= 0;
nivel <= nivel + 1;
nx_state <= s5;
elsif aux < nivel then
aux <= aux + 1;
nx_state <= s3;
elsif aux > 14 then
nx_state <= s6;
end if;
else
nx_state <= s0;
end if;
when s5 =>
if aux = 0 then
color <= negro;
aux <= 1;
elsif aux = 1 then
color <= blanco;
aux <= 2;
else
color <= negro;
aux <= 0;
nx_state <= s1;
end if;
when s6 =>
if aux = 0 then
color <= verde;
aux <= 1;
elsif aux = 1 then
color <= azul;
aux <= 2;
elsif aux = 2 then
color <= rojo;
aux <= 3;
elsif aux = 3 then
color <= amarillo;
aux <= 4;
elsif aux = 4 then
color <= verde;
aux <= 5;
elsif aux = 5 then
color <= azul;
aux <= 6;
elsif aux = 6 then
color <= rojo;
aux <= 7;
elsif aux = 7 then
color <= amarillo;
aux <= 8;
elsif aux = 8 then
color <= verde;
aux <= 9;
else
color <= negro;
aux <= 0;
nx_state <= s0;
end if;
end case;
end process;
end rtl;
After the error, it also mentions "unsafe behaviour for the latch"
Thank you all :-D