Beruflich Dokumente
Kultur Dokumente
MAESTRA EN INGENIERA
ESPECIALIDAD: MECATRNICA
REPORTE DE PRCTICA: 03
DESARROLLO Para implementar una FSM en un nivel estructural es necesario definir el nmero de estados y la tabla de transiciones. Debido a que se requiere controlar seis contadores, se disearn seis mquinas de estado, interconectadas para formar la macro mquina de estados. Se generar un conteo de reloj del tipo HH:MM:SS, y por opt por nombrar a cada cantidad como: S0 = Unidades de segundo S1 = Decenas de segundo M0 = Unidades de minuto M1 = Decenas de minuto H0 = Unidades de hora H1 = Decenas de hora Adems de utilizar la siguiente nomenclatura en los diagramas, tablas y cdigo fuente de los programas: S = segundos M = minutos H = horas U = unidades D = decenas
Cada mquina de estado diseada proporcionar una salida o requerir de una entrada generada por otra para poder trabajar en conjunto. Los diagramas de estado se muestran en la siguiente figura.
(a)
(b)
(c)
(d)
(e) (f) Figura 1. Diagramas de estado de las FSM utilizadas. a) Decenas de hora. b) Unidades de hora. c) Decenas de minuto. d) Unidades de minuto. e) Decenas de segundo. f) Unidades de segundo.
Para realizar el diseo a nivel estructural, se defini un total de 45 estados y a partir de stos, se elabor la tabla de transiciones simblica para cada mquina (tablas 1 a 6).
Tabla 1. Tabla de transiciones simblica para la FSM de unidades de segundo
Estado Actual Entrada Estado Siguiente Salidas 0 SU9 0, 0 SU0 1 SU1 0, 1 0 SU0 1, 0 SU1 1 SU2 1, 0 0 SU1 2, 0 SU2 1 SU3 2, 0 0 SU2 3, 0 SU3 1 SU4 3, 0 0 SU3 4, 0 SU4 1 SU5 4, 0 0 SU4 5, 0 SU5 1 SU6 5, 0 0 SU5 6, 0 SU6 1 SU7 6, 0 0 SU6 7, 0 SU7 1 SU8 7, 0 0 SU7 8, 0 SU8 1 SU9 8, 0 0 SU8 9, 1 SU9 1 SU0 9, 0
Estado Actual Entrada Estado Siguiente Salidas 0 SD5 0, 0 SD0 1 SD1 0, 1 0 SD0 1, 0 SD1 1 SD2 1, 0 0 SD1 2, 0 SD2 1 SD3 2, 0 0 SD2 3, 0 SD3 1 SD4 3, 0 0 SD3 4, 0 SD4 1 SD5 4, 0 0 SD4 5, 1 SD5 1 SD0 5, 0 Estado Actual Entrada Estado Siguiente Salidas 0 MU9 0, 0 MU0 1 MU1 0, 1 0 MU0 1, 0 MU1 1 MU2 1, 0 0 MU1 2, 0 MU2 1 MU3 2, 0 0 MU2 3, 0 MU3 1 MU4 3, 0 0 MU3 4, 0 MU4 1 MU5 4, 0 0 MU4 5, 0 MU5 1 MU6 5, 0 0 MU5 6, 0 MU6 1 MU7 6, 0 0 MU6 7, 0 MU7 1 MU8 7, 0 0 MU7 8, 0 MU8 1 MU9 8, 0 0 MU8 9, 1 MU9 1 MU0 9, 0 Estado Actual Entrada Estado Siguiente Salidas 0 MD5 0, 0 MD0 1 MD1 0, 1 0 MD0 1, 0 MD1 1 MD2 1, 0 0 MD1 2, 0 MD2 1 MD3 2, 0 0 MD2 3, 0 MD3 1 MD4 3, 0 0 MD3 4, 0 MD4 1 MD5 4, 0 0 MD4 5, 1 MD5 1 MD0 5, 0
Estado Actual Entradas Estado Siguiente Salidas 0, 0 HU9 0, 0 HU0 0, 1 HU3 0, 1 1, X HU1 0, 1 0, X HU0 1, 0 HU1 1, X HU2 1, 0 0, X HU1 2, 0 HU2 1, X HU3 2, 0 0, X HU2 3, 0 HU3 1, 0 HU4 3, 0 1, 1 HU0 3, 0 0, X HU3 4, 0 HU4 1, X HU5 4, 0 0, X HU4 5, 0 HU5 1, X HU6 5, 0 0, X HU5 6, 0 HU6 1, X HU7 6, 0 0, X HU6 7, 0 HU7 1, X HU8 7, 0 0, X HU7 8, 0 HU8 1, X HU9 8, 0 0, X HU8 9, 1 HU9 1, X HU0 9, 0
Estado Actual Entrada Estado Siguiente Salidas 0 MD2 0, 1 HD0 1 MD1 0, 0 0 MD0 1, 0 HD1 1 MD2 1, 0 0 MD1 2, 0 HD2 1 MD0 2, 0
A partir de las tablas de transiciones simblicas, se obtuvieron las tablas de estados codificadas (tablas 7 a 10) para cada mquina, permitiendo as disear las estructuras necesarias para la implementacin completa del circuito, adems de generar la lgica y funciones necesarias para la correspondencia entre estados, estados siguientes, entradas y salidas.
Tabla 7. Tabla de estados codificada para la FSM de unidades de segundo. Equivalente a la de unidades de minuto
Estado Actual Entrada Estado Siguiente Salidas 0 1001 0000, 0 0000 1 0001 0000, 1 0 0000 0001, 0 0001 1 0010 0001, 0 0 0001 0010, 0 0010 1 0011 0010, 0 0 0010 0011, 0 0011 1 0100 0011, 0 0 0011 0100, 0 0100 1 0101 0100, 0 0 0100 0101, 0 0101 1 0110 0101, 0 0 0101 0110, 0 0110 1 0111 0110, 0 0 0110 0111, 0 0111 1 1000 0111, 0 0 0111 1000, 0 1000 1 1001 1000, 0 0 1000 1001, 1 1001 1 0000 1001, 0
Tabla 8. Tabla de estados codificada para la FSM de decenas de segundo. Equivalente a la de decenas de minuto
Estado Actual Entrada Estado Siguiente Salidas 0 0101 0000, 0 0000 1 0001 0000, 1 0 0000 0001, 0 0001 1 0010 0001, 0 0 0001 000, 0 0010 1 0011 0010, 0 0 0010 0011, 0 0011 1 0100 0011, 0 0 0011 0100, 0 0100 1 0101 0100, 0 0 0100 0101, 1 0101 1 0000 0101, 0
Estado Actual Entradas Estado Siguiente Salidas 0, 0 1001 0000, 0 0000 0, 1 0011 0000, 1 1, X 0001 0000, 1 0, X 0000 0001, 0 0001 1, X 0010 0001, 0 0, X 0001 0010, 0 0010 1, X 0011 0010, 0 0, X 0010 0011, 0 0011 1, 0 0100 0011, 0 1, 1 000 0011, 0 0, X 0011 0100, 0 0100 1, X 0101 0100, 0 0, X 0100 0101, 0 0101 1, X 0110 0101, 0 0, X 0101 0110, 0 0110 1, X 0111 0110, 0 0, X 0110 0111, 0 0111 1, X 1000 0111, 0 0, X 0111 1000, 0 1000 1, X 1001 1000, 0 0, X 1000 1001, 1 1001 1, X 0000 1001, 0 Estado Actual Entrada Estado Siguiente Salidas 0 0010 0000, 1 0000 1 0001 0000, 0 0 0000 0001, 0 0001 1 0010 0001, 0 0 0001 0010, 0 0010 1 0000 0010, 0
Fue necesario implementar un contador mdulo N para cada dgito, el cual fue descrito en nivel comportamental, de manera que para su instanciacin en el diseo estructural, requiriera como datos de entrada una seal de reset, un bit para indicar a direccin de la cuenta (ascendente o descendente), una seal de reloj y el valor de N para el mdulo de la cuenta; proporcionando como seales de salida, la cuenta a mostrar para un dgito y una seal para utilizar como dato de entrada en otra instancia y realizar as la interconexin de los seis contadores. A nivel comportamental, se utilizaron mltiples sentencias process definiendo los registros y cambios de estado, y procesos de salida, en base a las tablas anteriores que describen el comportamiento de cada contador. Los contadores tanto de los segundos como de los minutos tienen el mismo mdulo, la cuenta llega hasta 9 en las unidades, y hasta 5 en las decenas. Pero para las horas, fue necesario condicionar la cuenta de las unidades ya sea hasta 9 o a 3 para el caso de 20 a 23 horas. Esto se logr verificando el estado actual de la cuenta de las decenas y la direccin de la cuenta, de manera que en cuenta ascendente, despus de 23 horas pase a 00 horas y no a 24; y en modo descendente, despus de 00 regrese a 23 horas y no a 29.
RESULTADOS Para que la cuenta sea en tiempo real, en su simulacin se ajust la primera seal de reloj a 1 Hz, de tal modo, la salida de la primera cuenta hace un cambio cada segundo. La estimulacin de las otras seales de entrada fue hecha tambin por medio del diseo de un testbench, el cual define datos de entrada, teniendo la opcin de seleccionar el momento en el que se ingresa dicha seal y cambiarla despus de un lapso definido. En la figura 2 se muestra un paso de simulacin, empezando con una seal de reset en alto, lo que pone en 0 cada una de las salidas
Al poner la seal de reset en 0 comienza la cuenta. Para la siguiente simulacin se hizo una cuenta ascendente (D = 1) de 0 a 10 segundos, ms un segundo transcurrido durante la seal de reset.
En la figura 4 ocurre un cambio en el contador de minutos, una vez transcurridos 60 segundos desde el inicio de la cuenta. En la figura 5 se observa un cambio en las decenas de minutos, generado por una cuenta completa en las unidades de minuto.
Ya transcurridos los 60 minutos de iniciada la cuenta, el contador de horas hace su primer cambio de 0 a 1 (figura 6).
En la figura 7 se observa ahora una simulacin de cuenta descendente, pudiendo apreciarse cmo despus del estado inicial (provocado por un pulso de la seal de reset), la cuenta inicia en 23:59:59 y comienza a descender.
Continuando con la cuenta descendente, se hace un cambio en la seal de direccin (D) aplicando un 1 para contar de manera ascendente, lo que se puede observar en la figura 8, que al cambiar la seal de direccin (segundo 15 de la cuenta), cambia el sentido de la cuenta. En la figura tambin se muestra una transicin de todos los contadores, habiendo empezado en 23:59:59 y descendiendo, despus comienza a ascender para cruzar de nuevo por 00:00:00 y seguir aumentando.
CONCLUSIONES La utilizacin de un mismo modelo de testbench tuvo el mismo resultado tanto para el diseo estructural como para el comportamental, con lo que se demuestra que ambos tienen la misma funcionalidad. La definicin de cada registro de estado, cambio de estado y proceso de salida en cada estado permiti una implementacin relativamente sencilla de la macro mquina de estados formada por cada una de las mquinas definidas individualmente. Esto tambin tomando en cuenta y proponiendo la manera en que cada FSM afecta a las otras de forma interdependiente. REFERENCIAS
(1)
Wakerly, John F., S.: Diseo Digital. Principios y Prcticas, Ed. Pearson - Prentice Hall.
Archivo: Contador.vhd
Archivo: SelectorModulo.vhd
library IEEE; use IEEE.STD_LOGIC_1164.all; -- LIBRERIA A UTILIZAR entity SelectorModulo is port( -- DECLARACION DE PUERTOS Clk,D: in STD_LOGIC; H1 : in STD_LOGIC_VECTOR(3 downto 0); H0 : in STD_LOGIC_VECTOR(3 downto 0); Modulo : out STD_LOGIC_VECTOR(3 downto 0) -- MODULO PARA LA CUENTA ); end SelectorModulo; architecture SelectorModulo_arq of SelectorModulo is -- SEALES INTERMEDIAS signal h10, h11, h12, h13,a1,a2,a3,sel,seln, o10,o11,o20,o21,o30,o31,o40,o41: std_logic; signal dn,and1,and2,and3,and4,sel1,sel0,sec: std_logic; begin process (Clk) -- PROCESO SENSIBLE A LA SEAL DE RELOJ begin -- REVISA EL ESTADO ACTUAL DE LAS SEALES H0 Y H1 if ((h1 = "0010" and h0 = "0011" and D = '1') or (h1 = "0000" and h0="0000" and D = '0')) then modulo <= "0011"; -- ESTABLECE EL MODULO A 3 else modulo <= "1001"; -- ESTABLECE EL MODULO A 9 end if; end process; end SelectorModulo_arq;
Archivo: FSM_Estructural.vhd
library IEEE; use IEEE.STD_LOGIC_1164.all; -- LIBRERIA A UTILIZAR use IEEE.STD_LOGIC_UNSIGNED.all; entity FSM_Estructural is port( -- DECLARACION DE PUERTOS Rst : in STD_LOGIC; -- SEAL DE RESET D : in STD_LOGIC; -- DIRECCION DE LA CUENTA. 1 = ASC, 0 = DESC Clk : in STD_LOGIC; -- SEAL DE RELOJ S0 : out STD_LOGIC_VECTOR(3 downto 0); -- 4 BITS PARA CADA DIGITO S1 : out STD_LOGIC_VECTOR(3 downto 0); -- 8 BITS POR UNIDAD H:M:S M0 : out STD_LOGIC_VECTOR(3 downto 0); M1 : out STD_LOGIC_VECTOR(3 downto 0); H0 : out STD_LOGIC_VECTOR(3 downto 0); H1 : out STD_LOGIC_VECTOR(3 downto 0) ); end FSM_Estructural; architecture FSM_Estructural_arq of FSM_Estructural is -- SEALES INTERMEDIAS signal ck1,ck2,ck3,ck4,ck5,ckout: std_logic; signal h1t,h0t, modu: std_logic_vector(3 downto 0); begin -- FSM1. UNIDADES DE SEGUNDO Mq1: entity work.contador (contador_arq) port map (Rst,D,Clk,"1001",S0,ck1);
-- FSM2. DECENAS DE SEGUNDO Mq2: entity work.contador (contador_arq) port map (Rst,D,ck1,"0101",S1,ck2); -- FSM3. UNIDADES DE MINUTO Mq3: entity work.contador (contador_arq) port map (Rst,D,ck2,"1001",M0,ck3); -- FSM4. DECENAS DE MINUTO Mq4: entity work.contador (contador_arq) port map (Rst,D,ck3,"0101",M1,ck4); -- SELECCION DE MODULO PARA LA CUENTA DE UNIDADES DE HORA SL1: entity work.SelectorModulo (SelectorModulo_arq) port map (Clk,D,h1t,h0t,modu); -- FSM5. UNIDADES DE HORA Mq5: entity work.contador (contador_arq) port map (Rst,D,ck4,modu,h0t,ck5); -- FSM6. DECENAS DE HORA Mq6: entity work.contador (contador_arq) port map (Rst,D,ck5,"0010",h1t,ckout); H0 <= h0t; H1 <= h1t; end FSM_Estructural_arq;
Archivo: TestBench.vhd
library IEEE; use IEEE.STD_LOGIC_1164.all; -- LIBRERIA A UTILIZAR entity TestBench is port( Clk : in S0 : out S1 : out M0 : out M1 : out H0 : out H1 : out ); end TestBench; -- DECLARACION DE PUERTOS STD_LOGIC; -- COMO ENTRADA SOLO SE AJUSTA LA SEAL DE RELOJ STD_LOGIC_VECTOR(3 downto 0); STD_LOGIC_VECTOR(3 downto 0); STD_LOGIC_VECTOR(3 downto 0); STD_LOGIC_VECTOR(3 downto 0); STD_LOGIC_VECTOR(3 downto 0); STD_LOGIC_VECTOR(3 downto 0)
architecture TestBench_arq of TestBench is -- SEALES INTERMEDIAS signal reset, d: std_logic; signal x0, x1, x2, x3, x4, x5: std_logic_vector(3 downto 0); begin -- INSTANCIA A LA FSM FSM: entity work.FSM_Estructural (FSM_Estructural_arq) port map (Clk,reset,d,x0,x1,x2,x3,x4,x5); -- DEFINICION DE VALORES DE LAS SEALES QUE SE USARAN COMO PARAMETROS DE ENTRADA -- ESPECIFICANDO EL TIEMPO DE RETARDO PARA SU APLICACION reset <= '1', '0' after 1000 ms, '1' after 500000 ms; d <= '1', '0' after 50000 ms, '1' after 100000 ms, '0' after 200000 ms; -- SE MANDAN A LAS SALIDAS LOS DATOS GUARDADOS EN LAS SEALES INTERMEDIAS S0 <= x0; S1 <= x1; M0 <= x2; M1 <= x3; H0 <= x4; H1 <= x5; end TestBench_arq;
architecture FSM_Mealy_arq of FSM_Mealy is -- DECLARACION DE ESTADOS type state_type is (Su0, Su1, Su2, Su3, Su4, Su5, Su6, Su7, Su8, Su9, Sd0, Sd1, Sd2, Sd3, Sd4, Sd5, Mu0, Mu1, Mu2, Mu3, Mu4, Mu5, Mu6, Mu7, Mu8, Mu9, Md0, Md1, Md2, Md3, Md4, Md5, Hu0, Hu1, Hu2, Hu3, Hu4, Hu5, Hu6, Hu7, Hu8, Hu9, Hd0, Hd1, Hd2); -- SEALES PARA ESTADO ACTUAL Y ESTADO SIGUIENTE signal su_state, su_next_state, sd_state, sd_next_state: state_type; signal mu_state, mu_next_state, md_state, md_next_state: state_type; signal hu_state, hu_next_state, hd_state, hd_next_state: state_type; -- SEALES DE RELOJ INTERMEDIAS signal Clk1, Clk2, Clk3, Clk4, Clk5, h24: std_logic; signal H1t: std_logic_vector (3 downto 0); begin -- REGISTRO DE ESTADO PARA FSM 1. UNIDADES DE SEGUNDO reg_estado_useg: process (Rst,Clk0) begin if (Rst = '1') then su_state <= Su0; elsif (Clk0'event and Clk0='1') then su_state <= su_next_state; end if; end process reg_estado_useg; -- REGISTRO DE ESTADO PARA FSM 2. DECENAS DE SEGUNDO reg_estado_dseg: process (Rst,Clk1) begin if (Rst = '1') then sd_state <= Sd0; elsif (Clk1'event and Clk1='1') then sd_state <= sd_next_state; end if; end process reg_estado_dseg;
-- REGISTRO DE ESTADO PARA FSM 3. UNIDADES DE MINUTO reg_estado_umin: process (Rst,Clk2) begin if (Rst = '1') then mu_state <= Mu0; elsif (Clk2'event and Clk2='1') then mu_state <= mu_next_state; end if; end process reg_estado_umin; -- REGISTRO DE ESTADO PARA FSM 4. DECENAS DE MINUTO reg_estado_dmin: process (Rst,Clk3) begin if (Rst = '1') then md_state <= Md0; elsif (Clk3'event and Clk3='1') then md_state <= md_next_state; end if; end process reg_estado_dmin; -- REGISTRO DE ESTADO PARA FSM 5. UNIDADES DE HORA reg_estado_uhor: process (Rst,Clk4) begin if (Rst = '1') then hu_state <= Hu0; elsif (Clk4'event and Clk4='1') then hu_state <= hu_next_state; end if; end process reg_estado_uhor; -- REGISTRO DE ESTADO PARA FSM 6. DECENAS DE HORA reg_estado_dhor: process (Rst,Clk5) begin if (Rst = '1') then hd_state <= Hd0; elsif (Clk5'event and Clk5='1') then hd_state <= hd_next_state; end if; end process reg_estado_dhor; -- TRANSICIONES DE ESTADO PARA FSM 1 tran_edo_useg: process (su_state,D) begin case su_state is when Su0 => if D = '1' then su_next_state <= Su1; else su_next_state <= Su9; end if; when Su1 => if D = '1' then su_next_state <= Su2; else su_next_state <= Su0; end if; when Su2 => if D = '1' then
su_next_state end if; when Su3 => if D = '1' then su_next_state else su_next_state end if; when Su4 => if D = '1' then su_next_state else su_next_state end if; when Su5 => if D = '1' then su_next_state else su_next_state end if; when Su6 => if D = '1' then su_next_state else su_next_state end if; when Su7 => if D = '1' then su_next_state else su_next_state end if; when Su8 => if D = '1' then su_next_state else su_next_state end if; when Su9 => if D = '1' then su_next_state else su_next_state end if; when OTHERS => end case; end process tran_edo_useg;
else
-- TRANSICIONES DE ESTADO PARA FSM 2 tran_edo_dseg: process (sd_state,D) begin case sd_state is when Sd0 => if D = '1' then sd_next_state <= Sd1; else sd_next_state <= Sd5;
end if; when Sd1 => if D = '1' then sd_next_state else sd_next_state end if; when Sd2 => if D = '1' then sd_next_state else sd_next_state end if; when Sd3 => if D = '1' then sd_next_state else sd_next_state end if; when Sd4 => if D = '1' then sd_next_state else sd_next_state end if; when Sd5 => if D = '1' then sd_next_state else sd_next_state end if; when OTHERS => end case; end process tran_edo_dseg;
-- TRANSICIONES DE ESTADO PARA FSM 3 tran_edo_umin: process (mu_state,D) begin case mu_state is when Mu0 => if D = '1' then Mu_next_state <= Mu1; else Mu_next_state <= Mu9; end if; when Mu1 => if D = '1' then mu_next_state <= Mu2; else mu_next_state <= Mu0; end if; when Mu2 => if D = '1' then mu_next_state <= Mu3; else mu_next_state <= Mu1; end if; when Mu3 => if D = '1' then
mu_next_state end if; when Mu4 => if D = '1' then mu_next_state else mu_next_state end if; when Mu5 => if D = '1' then mu_next_state else mu_next_state end if; when Mu6 => if D = '1' then mu_next_state else mu_next_state end if; when Mu7 => if D = '1' then mu_next_state else mu_next_state end if; when Mu8 => if D = '1' then mu_next_state else mu_next_state end if; when Mu9 => if D = '1' then mu_next_state else mu_next_state end if; when OTHERS => end case; end process tran_edo_umin;
else
-- TRANSICIONES DE ESTADO PARA FSM 4 tran_edo_dmin: process (md_state,D) begin case md_state is when Md0 => if D = '1' then md_next_state <= Md1; else md_next_state <= Md5; end if; when Md1 => if D = '1' then md_next_state <= Md2; else md_next_state <= Md0;
end if; when Md2 => if D = '1' then md_next_state else md_next_state end if; when Md3 => if D = '1' then md_next_state else md_next_state end if; when Md4 => if D = '1' then md_next_state else md_next_state end if; when Md5 => if D = '1' then md_next_state else md_next_state end if; when OTHERS => end case; end process tran_edo_dmin;
-- TRANSICIONES DE ESTADO PARA FSM 5 tran_edo_uhor: process (hu_state,D,H1t) begin case hu_state is when Hu0 => if D = '1' then Hu_next_state <= Hu1; h24 <= '0'; else if (hd_state = Hd0) then Hu_next_state <= Hu3; h24 <= '1'; else Hu_next_state <= Hu9; h24 <= '0'; end if; end if; when Hu1 => h24 <= '0'; if D = '1' then hu_next_state <= Hu2; else hu_next_state <= Hu0; end if; when Hu2 => h24 <= '0'; if D = '1' then hu_next_state <= Hu3; else hu_next_state <= Hu1;
end if; when Hu3 => if D = '1' then if (hd_state = Hd2) then hu_next_state <= Hu0; else hu_next_state <= Hu4; end if; else hu_next_state <= Hu2; end if; when Hu4 => h24 <= '0'; if D = '1' then hu_next_state <= Hu5; else hu_next_state <= Hu3; end if; when Hu5 => h24 <= '0'; if D = '1' then hu_next_state <= Hu6; else hu_next_state <= Hu4; end if; when Hu6 => h24 <= '0'; if D = '1' then hu_next_state <= Hu7; else hu_next_state <= Hu5; end if; when Hu7 => h24 <= '0'; if D = '1' then hu_next_state <= Hu8; else hu_next_state <= Hu6; end if; when Hu8 => h24 <= '0'; if D = '1' then hu_next_state <= hu9; else hu_next_state <= Hu7; end if; when Hu9 => h24 <= '0'; if D = '1' then hu_next_state <= Hu0; else hu_next_state <= Hu8; end if; when OTHERS => end case; end process tran_edo_uhor;
-- TRANSICIONES DE ESTADO PARA FSM 6 tran_edo_dhor: process (hd_state,D) begin case hd_state is when Hd0 => if D = '1' then hd_next_state <= Hd1; else hd_next_state <= Hd2; end if; when Hd1 => if D = '1' then hd_next_state <= Hd2; else hd_next_state <= Hd0; end if; when Hd2 => if D = '1' then hd_next_state <= Hd0; else hd_next_state <= Hd1; end if; when OTHERS => end case; end process tran_edo_dhor; -- PROCESOS DE SALIDA. FSM 1 salida_su: process (su_state,D) begin if(su_state = Su0) then S0 <= "0000"; if(D = '1') then Clk1 <= '1'; else Clk1 <= '0'; end if; end if; if(su_state = Su1) then S0 <= "0001"; Clk1 <= '0'; end if; if(su_state = Su2) then S0 <= "0010"; Clk1 <= '0'; end if; if(su_state = Su3) then S0 <= "0011"; Clk1 <= '0'; end if; if(su_state = Su4) then S0 <= "0100"; Clk1 <= '0'; end if; if(su_state = Su5) then S0 <= "0101"; Clk1 <= '0'; end if; if(su_state = Su6) then S0 <= "0110"; Clk1 <= '0'; end if; if(su_state = Su7) then S0 <= "0111"; Clk1 <= '0';
end if; if(su_state = Su8) then S0 <= "1000"; Clk1 <= '0'; end if; if(su_state = Su9) then S0 <= "1001"; if(D = '1') then Clk1 <= '0'; else Clk1 <= '1'; end if; end if; end process salida_su; -- PROCESOS DE SALIDA. FSM 2 salida_sd: process (sd_state,D) begin if(sd_state = Sd0) then S1 <= "0000"; if(D = '1') then Clk2 <= '1'; else Clk2 <= '0'; end if; end if; if(sd_state = Sd1) then S1 <= "0001"; Clk2 <= '0'; end if; if(sd_state = Sd2) then S1 <= "0010"; Clk2 <= '0'; end if; if(sd_state = Sd3) then S1 <= "0011"; Clk2 <= '0'; end if; if(sd_state = Sd4) then S1 <= "0100"; Clk2 <= '0'; end if; if(sd_state = Sd5) then S1 <= "0101"; if(D = '1') then Clk2 <= '0'; else Clk2 <= '1'; end if; end if; end process salida_sd; -- PROCESOS DE SALIDA. FSM 3 salida_mu: process (mu_state,D) begin if(mu_state = Mu0) then M0 <= "0000"; if(D = '1') then Clk3 <= '1'; else Clk3 <= '0'; end if;
end if; if(mu_state = Mu1) then M0 <= "0001"; Clk3 end if; if(mu_state = Mu2) then M0 <= "0010"; Clk3 end if; if(mu_state = Mu3) then M0 <= "0011"; Clk3 end if; if(mu_state = Mu4) then M0 <= "0100"; Clk3 end if; if(mu_state = Mu5) then M0 <= "0101"; Clk3 end if; if(mu_state = Mu6) then M0 <= "0110"; Clk3 end if; if(mu_state = Mu7) then M0 <= "0111"; Clk3 end if; if(mu_state = Mu8) then M0 <= "1000"; Clk3 end if; if(mu_state = Mu9) then M0 <= "1001"; if(D = '1') then Clk3 <= '0'; else Clk3 <= '1'; end if; end if; end process salida_mu;
<= '0'; <= '0'; <= '0'; <= '0'; <= '0'; <= '0'; <= '0'; <= '0';
-- PROCESOS DE SALIDA. FSM 4 salida_md: process (md_state,D) begin if(md_state = Md0) then M1 <= "0000"; if(D = '1') then Clk4 <= '1'; else Clk4 <= '0'; end if; end if; if(md_state = Md1) then M1 <= "0001"; Clk4 <= '0'; end if; if(md_state = Md2) then M1 <= "0010"; Clk4 <= '0'; end if; if(md_state = Md3) then M1 <= "0011"; Clk4 <= '0'; end if; if(md_state = Md4) then M1 <= "0100"; Clk4 <= '0'; end if;
if(md_state = Md5) then M1 <= "0101"; if(D = '1') then Clk4 <= '0'; else Clk4 <= '1'; end if; end if; end process salida_md; -- PROCESOS DE SALIDA. FSM 5 salida_hu: process (hu_state,D) begin if(hu_state = Hu0) then H0 <= "0000"; if(D = '1') then Clk5 <= '1'; else Clk5 <= '0'; end if; end if; if(hu_state = Hu1) then H0 <= "0001"; Clk5 <= '0'; end if; if(hu_state = Hu2) then H0 <= "0010"; Clk5 <= '0'; end if; if(hu_state = Hu3) then H0 <= "0011"; if(h24='1' and D = '0' ) then Clk5 <= '1'; else Clk5 <= '0'; end if; end if; if(hu_state = Hu4) then H0 <= "0100"; Clk5 <= '0'; end if; if(hu_state = Hu5) then H0 <= "0101"; Clk5 <= '0'; end if; if(hu_state = Hu6) then H0 <= "0110"; Clk5 <= '0'; end if; if(hu_state = Hu7) then H0 <= "0111"; Clk5 <= '0'; end if; if(hu_state = Hu8) then H0 <= "1000"; Clk5 <= '0'; end if; if(hu_state = Hu9) then H0 <= "1001"; if(D = '1') then Clk5 <= '0'; else Clk5 <= '1'; end if; end if; end process salida_hu;
-- PROCESOS DE SALIDA. FSM 6 salida_hd: process (hd_state,D) begin if(hd_state = Hd0) then H1 <= "0000"; H1t <= "0000"; end if; if(hd_state = Hd1) then H1 <= "0001"; H1t <= "0001"; end if; if(hd_state = Hd2) then H1 <= "0010"; H1t <= "0010"; end if; end process salida_hd; end FSM_Mealy_arq;