Professional Documents
Culture Documents
INTRODUCCIÓN
En los sistemas secuenciales la salida Z en un determinado instante de
tiempo ti depende de X (la entrada) en ese mismo instante de tiempo ti y en
todos los instantes temporales anteriores. Para ello es necesario que el
sistema disponga de elementos de memoria que le permitan recordar la
situación en que se encuentra (estado)
Asignación de estados
1
EJEMPLO 2. CODIFICACIÓN EN VHDL
Suponga que se presenta el siguiente diagrama de estados, con su
correspondiente tabla de transición y se solicita su codificación en VHDL
Entrada
X
0
Estado 0 1 0
S0/ Actual
1 0 1 S0 S0 S1 0
0 S1 S1 S2 0
S3/ S1/ S2 S2 S3 0
1 0
S3 S3 S0 1
0 Próximo Salida
S2/ estado
1
1 0
0
library IEEE; when s1=> y <='0';
use IEEE.STD_LOGIC_1164.ALL; if x='1' then
use IEEE.STD_LOGIC_ARITH.ALL; proximo <= s2;
use IEEE.STD_LOGIC_UNSIGNED.ALL; else
proximo <= actual;
end if;
entity maquina is
when s2=> y <='0';
port( x, ck, reset : in bit; if x='1' then
y: out bit proximo <= s3;
); else
end maquina; proximo <= actual;
end if;
when s3=> y <='1';
architecture Behavioral of maquina is if x='1' then
proximo <= s0;
type estados is(s0, s1, s2, s3); else
signal actual, proximo : estados; proximo <= actual;
end if;
end case;
Begin
end process;
futur_estado: process(actual, x)
begin cambio_estado:process
case actual is begin
when s0=> y <='0'; wait until ck'event and ck='1';
if reset='1' then
if x='1' then
actual<=s0;
proximo <= s1; else
else actual<=proximo;
proximo <= actual; end if;
end if; end process;
end Behavioral;
CONTADOR BCD
S0 S1 S7 000
S1 S2 S0 001
S2 S3 S1 010
S3 S4 S2 011
S4 S5 S3 100
S5 S6 S4 101
S6 S7 S5 110
S7 S0 S6 111
library IEEE; process (estado_pr,x)
use IEEE.STD_LOGIC_1164.ALL; begin
use IEEE.STD_LOGIC_ARITH.ALL; case estado_pr is
use IEEE.STD_LOGIC_UNSIGNED.ALL; when s0=>
if x='1' then
entity counter is cuenta<="0000";
port (clk, reset, x: in std_logic; sig_estado<=s1;
cuenta:out std_logic_vector(3 downto 0) else
); cuenta<="0000";
end counter; sig_estado<=s7;
end if;
architecture Behavioral of counter is when s1=>
type estados is (s0, s1, s2, s3, s4, s5, s6, s7); if x='1' then
signal estado_pr, sig_estado: estados; cuenta<="0001";
begin sig_estado<=s2;
process (clk, reset) else
begin cuenta<="0001";
if(reset='1') then sig_estado<=s0;
estado_pr<=s0; end if;
elsif(clk'event and clk='1') then when s2=>
estado_pr<=sig_estado; if x='1' then
end if; cuenta<="0010";
end process; sig_estado<=s3;
else else
cuenta<="0010"; cuenta<="0101";
sig_estado<=s1; sig_estado<=s4;
end if; end if;
when s3=> when s6=>
if x='1' then if x='1' then
cuenta<="0011"; cuenta<="0110";
sig_estado<=s4; sig_estado<=s7;
else else
cuenta<="0011"; cuenta<="0110";
sig_estado<=s2; sig_estado<=s5;
end if; end if;
when s4=> when s7=>
if x='1' then if x='1' then
cuenta<="0100"; cuenta<="0111";
sig_estado<=s5; sig_estado<=s0;
else else
cuenta<="0100"; cuenta<="0111";
sig_estado<=s3; sig_estado<=s6;
end if; end if;
when s5=> end case;
if x='1' then end process;
cuenta<="0101"; end Behavioral;
sig_estado<=s6;
EJERCICIO
Implemente un circuito de control para un
display de 7 segmentos, utilizando como entrada
los switches de la tarjeta.
16
entity segmentos is
port(
clk : in std_logic; -- Señal de reloj principal.
rst_n : in std_logic; -- Señal de reset asíncrona.
BCD_data : in std_logic_vector(3 downto 0); -- Datos de entrada
(microswitches).
display : out std_logic_vector(7 downto 0) -- Display de 7 segmentos.
);
end segmentos;
begin
17
case BCD_data is when "1001" =>
when "0000" => display <= "01100111";
when others =>
display <= "00111111";
display <= "00000000";
when "0001" => end case;
display <= "00000110"; end process;
when "0010" =>
end Behavioral;
display <= "01011011";
when "0011" =>
display <= "01001111";
when "0100" =>
display <= "01100110";
when "0101" =>
display <= "01101101";
when "0110" =>
display <= "01111101";
when "0111" =>
display <= "00000111";
18
when "1000" =>
display <= "01111111";