Sie sind auf Seite 1von 14

a

UNIVERSIDAD NACIONAL AUTNONA DE MXICO

FACULTAD DE INGENIERA

Proyecto1
Simulacin e Implementacin de una mquina de estados.

Arquitectura de Computadoras

Integrantes:

Palacios Rivero Dorian Raziel Vargas Snchez Daniel

FECHA ENTREGA: 21/Octubre/2013

000

001

S1

010

S1,S3
011

S2,S3 Y
0 1
100

S1,S2
1
110

Z
0

S1,S0

I
1
111

101

S0,S1,S2,S3 I
1 0

S1
2

Memoria del microprograma


Estado Actual 000 001 010 011 100 101 110 111 Prueba Valor X Y Z I 00 01 10 11 Liga *** 001 110 101 *** 001 *** 001 Prueba ** 00 01 10 11 ** 11 ** MicroInstrucccn PC SC0 SC1 ST SF SI0 SI1 MI 011 010 001 001 110 100 101 100 Valor 000 001 010 011 100 101 110 Salida 0000 0010 1010 1100 0110 1111 0011 0010

Codigo fuente
Placa(Principal)
-----------------------------------------------------Arquitectura de computadoras -Simulacin e implementacin de una -mquina de estados de tercer estado. -Pajarito Vargas Antonio -Zurita Garca Fernando Daniel ---------------------------------------------------library IEEE; use IEEE.STD_LOGIC_1164.ALL; use work.paquete.all; 3

entity Placa is Port ( x : in STD_LOGIC; y : in STD_LOGIC; z : in STD_LOGIC; int : in STD_LOGIC; switch1 : in STD_LOGIC_VECTOR (2 downto 0); switch2 : in STD_LOGIC_VECTOR (2 downto 0); relojEnt : in STD_LOGIC; reset : in STD_LOGIC; habD7S : out STD_LOGIC_VECTOR (3 downto 0); D7S : out STD_LOGIC_VECTOR (6 downto 0); salida : out STD_LOGIC_VECTOR (3 downto 0)); end Placa; architecture Behavioral of Placa is signal entrada_sel: STD_LOGIC; signal cont,lig,inter,trans : STD_LOGIC; signal relojDiv : STD_LOGIC; signal G : STD_LOGIC_VECTOR (1 downto 0); signal MI, estado_actual, liga, regIncr : STD_LOGIC_VECTOR (2 downto 0); begin habD7S <= "1110"; relojDiv <= relojEnt; --Memoria de microprama mem: Memoria port map(estado_presente => estado_actual, prueba => G, microinstruccion => MI, liga => liga, salida => salida ); --Multiplexor de 4x1 mp: Multiplexor port map(Selector => G, Entrada(0) => x, Entrada(1) => y, Entrada(2) => z, Entrada(3) => int, Salida => entrada_sel ); --Decodificador de 3x7 para display de siete segmentos dcd: decodificador port map (entrada => estado_actual, salida => D7S ); --Registro de interrupciones regInt: registro port map(hab => inter, reloj => relojDiv, reset => reset, entrada => switch1, 4

salida => estado_actual ); --Registro de transformacin regTr: registro port map(hab => trans, reloj => relojDiv, reset => reset, entrada => switch2, salida => estado_actual ); --Registro de Liga regLi: registro port map(hab => lig, reloj => relojDiv, reset => reset, entrada => liga, salida => estado_actual ); --Registro de incrementador regI: registro port map(hab => cont, reloj => relojDiv, reset => reset, entrada => regIncr, salida => estado_actual ); --Divisor de frecuencia rel: reloj port map(reloj => relojEnt, divisor => relojDiv ); increm: incrementador port map(entrada => estado_actual, salida => regIncr ); sec: secuenciador port map(cc => entrada_Sel, microinstruccion => MI, habilitadores(0) => trans, habilitadores(1) => inter, habilitadores(2) => lig, habilitadores(3) => cont ); end Behavioral;

Incrementador
library IEEE; use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Incrementador is Port ( entrada : in STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (2 downto 0)); end incrementador;

architecture Behavioral of Incrementador is begin process(entrada) begin salida <= entrada + 1; end process; end Behavioral;

Multiplexor
library IEEE; use IEEE.STD_LOGIC_1164.ALL;

entity Multiplexor is Port ( Selector : in STD_LOGIC_VECTOR (1 downto 0); Entrada : in STD_LOGIC_VECTOR (3 downto 0); 6

Salida : out STD_LOGIC); end Multiplexor;

architecture Behavioral of Multiplexor is begin process (Selector,Entrada) begin case Selector is when "00" => Salida <= Entrada(0); when "01" => Salida <= Entrada(1); when "10" => Salida <= Entrada(2); when "11" => Salida <= Entrada(3); when others => Salida <= '0'; end case; end process; end Behavioral;

Registro
library IEEE; use IEEE.STD_LOGIC_1164.ALL;

entity Registro is Port ( hab : in STD_LOGIC; reloj : in STD_LOGIC; reset : in STD_LOGIC; entrada : in STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (2 downto 0)); end Registro;

architecture Behavioral of Registro is 7

begin process (reloj) begin if reloj'event and reloj='1' then if hab ='0' then if reset = '0' then salida <= entrada; elsif reset = '1' then salida <= "000"; end if; elsif hab = '1' then salida <= "ZZZ"; end if; end if; end process; end Behavioral;

Decodificador
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity Decodificador is Port ( entrada : in STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (6 downto 0)); end Decodificador; architecture Behavioral of Decodificador is begin process(entrada) begin case entrada is when "000" => salida <= "0000001";--ABCDEFG when "001" => salida <= "1001111"; when "010" => salida <= "0010010"; when "011" => salida <= "0000110"; when "100" => salida <= "1001100"; when "101" => salida <= "0100100"; when "110" => salida <= "0100000"; when "111" => salida <= "0001111"; when others => salida <= "1111111"; end case; end process; 8

end Behavioral;

Reloj
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Reloj is Port ( reloj : in STD_LOGIC; divisor : out STD_LOGIC); end Reloj;

architecture Behavioral of Reloj is begin process(reloj) variable cuenta : std_logic_vector(27 downto 0); begin if reloj='1' and reloj'event then cuenta := cuenta +1; end if; divisor <= cuenta(27); end process; end Behavioral;

Secuenciador
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;

--------

Paso continuo Salto condicional con 0 Salto condicional con 1 Salto de Transformacion Salto forzado Salto por Interrupcion con 0 Salto por Interrupcion con 1

000 001 010 011 100 101 110

-- Habilitadores: Incrementador, Liga, Interrupcion, Transformacion entity Secuenciador is Port ( cc : in STD_LOGIC; microinstruccion : in STD_LOGIC_VECTOR (2 downto 0); habilitadores : out STD_LOGIC_VECTOR (3 downto 0)); end Secuenciador; architecture Behavioral of Secuenciador is begin process(cc,microinstruccion) begin case microinstruccion is --PC when "000" => habilitadores <= "0111"; --SC0 when "001" => if cc = '0' then habilitadores <= "1011"; elsif cc = '1' then habilitadores <= "0111"; end if; --SC1 when "010" => if cc = '1' then habilitadores <= "1011"; elsif cc = '0' then habilitadores <= "0111"; end if; --ST when "011" => habilitadores <= "1110"; --SF 10

when "100" => habilitadores <= "1011"; --SI0 when "101" => if cc = '0' then habilitadores <= "1101"; elsif cc = '1' then habilitadores <= "0111"; end if; --SI1 when "110" => if cc = '1' then habilitadores <= "1101"; elsif cc = '0' then habilitadores <= "0111"; end if; when others => habilitadores <= "0111"; end case; end process; end Behavioral;

Paquete
library IEEE; use IEEE.STD_LOGIC_1164.all;

package Paquete is

component Memoria is Port ( estado_presente : in STD_LOGIC_VECTOR (2 downto 0); prueba : out STD_LOGIC_VECTOR (1 downto 0); microinstruccion : out STD_LOGIC_VECTOR (2 downto 0); liga : out STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (3 downto 0)); end component;

component Multiplexor is Port ( Selector : in STD_LOGIC_VECTOR (1 downto 0); Entrada : in STD_LOGIC_VECTOR (3 downto 0); Salida : out STD_LOGIC); 11

end component;

component decodificador is Port ( entrada : in STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (6 downto 0)); end component;

component registro is Port ( hab : in STD_LOGIC; reloj : in STD_LOGIC; reset : in STD_LOGIC; entrada : in STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (2 downto 0)); end component;

component reloj is Port ( reloj : in STD_LOGIC; divisor : out STD_LOGIC); end component;

component incrementador is Port ( entrada : in STD_LOGIC_VECTOR (2 downto 0); salida : out STD_LOGIC_VECTOR (2 downto 0)); end component;

component secuenciador is 12

Port ( cc : in STD_LOGIC; microinstruccion : in STD_LOGIC_VECTOR (2 downto 0); habilitadores : out STD_LOGIC_VECTOR(3 downto 0)); end component;

end Paquete;

Simulacion
Simulacin aleatoria, pasando por los ocho estados de la carta ASM diseada. Las seales de entrada se encuentran en la parte superior, representando la seal de reloj, la seal de reset, las seales x, y, z, la seal de interrupcin, el switch1 personificando al registro de interrupcin y el switch2 figurando como el registro de transformacin, respectivamente. En la parte inferior se visualizan las salidas y el estado actual acordes a la carta, pasando por cada uno de los estados segn las entradas descritas anteriormente. Comparando con la carta ASM y/o cargando el .bit en la tarjeta Basys 2, se verifica que la simulacin fue correcta.

13

14

Das könnte Ihnen auch gefallen