Mi circuito se basa en una máquina de estado. Lo verifiqué y funciona bien, el único problema es que infiere un pestillo por flip-flop (la máquina de estado tiene 11 estados y el circuito está activo, por lo que tiene 11 flip-flops, pero también 11 pestillos no deseados) I He revisado todo, pero no puedo encontrar la causa de estos pestillos inesperados. Mi código está en español, creo que esto no debería ser un problema, pero si necesitas que lo traduzca, puedo hacerlo. La única nota importante es que "estado" significa "estado" y "estaprox" significa "próximo estado". Muchas gracias por su ayuda
library IEEE;
use IEEE.std_logic_1164.all;
entity ej13 is
port (
clk_i : in std_logic;
y_i : in std_logic;
sr_i : in std_logic;
z_o : out std_logic);
end entity ej13;
architecture EstaNoAsig of ej13 is
type tipo_estado is (a,b,c,d,e,f,g,h,i,j,k);
signal estado, estaprox : tipo_estado;
begin
Secuencial:
process (clk_i)
begin
if rising_edge (clk_i) then
if sr_i = '1' then
estado <= a;
else
estado <= estaprox;
end if;
end if;
end process Secuencial;
Combinacional:
process (y_i, estado)
begin
case estado is
when a =>
if y_i = '1' then
estaprox <= c;
z_o <= '1';
else
estaprox <= b;
z_o <= '0';
end if;
when b =>
if y_i = '1' then
estaprox <= e;
z_o <= '1';
else
estaprox <= d;
z_o <= '0';
end if;
when c =>
if y_i = '1' then
estaprox <= e;
z_o <= '0';
else
estaprox <= d;
z_o <= '1';
end if;
when d =>
if y_i = '1' then
estaprox <= g;
z_o <= '1';
else
estaprox <= f;
z_o <= '0';
end if;
when e =>
if y_i = '1' then
estaprox <= g;
z_o <= '0';
else
estaprox <= f;
z_o <= '1';
end if;
when f =>
if y_i = '1' then
estaprox <= i;
z_o <= '1';
else
estaprox <= h;
z_o <= '0';
end if;
when g =>
if y_i = '1' then
estaprox <= i;
z_o <= '0';
else
estaprox <= h;
z_o <= '1';
end if;
when h =>
if y_i = '1' then
estaprox <= k;
z_o <= '1';
else
estaprox <= j;
z_o <= '0';
end if;
when i =>
if y_i = '1' then
estaprox <= k;
z_o <= '0';
else
estaprox <= j;
z_o <= '1';
end if;
when j =>
if y_i = '1' then
estaprox <= a;
z_o <= '1';
else
estaprox <= a;
z_o <= '0';
end if;
when k =>
if y_i = '1' then
estaprox <= a;
z_o <= '0';
else
estaprox <= a;
z_o <= '1';
end if;
when others =>
z_o <= '0';
estaprox <= a;
end case;
end process Combinacional;
end architecture EstaNoAsig;
Debe agregar algunas asignaciones predeterminadas:
process (y_i, estado)
begin
--default assignments
estaprox <= estado; -- stay in the current state, unless the case statement calculates a 'jump'
z_o <= '0'; -- assign all outputs with a default value to prevent latches
-- next state calculations
case estado is
when a =>
if y_i = '1' then
estaprox <= c;
z_o <= '1';
[...]
end case;
end process Combinacional;
Tres consejos adicionales:
signal estado : tipo_estado := a;
Puedes acortar algunos estados, si quieres :)
when j =>
estaprox <= a;
z_o <= y_i;
when k =>
estaprox <= a;
z_o <= not y_i;
cventu
Paebbels
cventu