jueves, 11 de agosto de 2011

fundamentos de diseño logico y de computadors Morris Mano

fundamentos de diseño logico y de computadorsautor: Morris Manohttp://www.4shared.com/document/Us-aBzem/fundamentos_de_diseo_logico_y_.html 

martes, 12 de julio de 2011

Sumador - Restador

library ieee;
use  ieee.std_logic_1164.all;
use  ieee.std_logic_unsigned.all;

entity suma_resta is
    port ( A, B : in std_logic_vector( 3 downto 0 );
             C0 : in std_logic ;
             S : out  std_logic_vector ( 3 downto 0 );
             C4 : out std_logic );
 end suma_resta;

 architecture  comportamiento_1   of  suma_resta  is
 signal   suma : std_logic_vector( 4 downto 0 );
 begin
        process (A,B,C0)
            begin
                if C0='1' then
                   
                    suma <= ( '0' & A ) + ( '0' & B );
                   
                    else
                    suma <= ( '0' & A ) - ( '0' & B );
                end if;
               
               
               
                C4 <= suma( 4 );
                S <= suma( 3 downto 0 );
        end process;
  end comportamiento_1;

sábado, 9 de julio de 2011

banco de pruebas detector de secuencias 1101

library ieee;
use IEEE.STD_LOGIC_1164.all;
entity bp_detector_secuencia is
end bp_detector_secuencia;
architecture estructural of bp_detector_secuencia is
    signal  bp_RESET, bp_RELOJ, bp_X, bp_Z : std_logic;
begin
uut: entity work.det_sec(detector_1)
port map ( RESET=>bp_RESET, CLK=>bp_RELOJ, x=>bp_X );
             process
      begin
         bp_RESET <= '1';     -- inicializa al sistema
                     bp_RELOJ <= '0';
                     bp_X <= '0';
                     wait for 50 ns;
                     bp_RESET <= '0';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <='0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <='0';
                     bp_X <= '0';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <='0';
                     bp_X <= '0';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '0';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <='0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <='0';
                     bp_X <= '0';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <='0';
                     bp_X <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '0';
                     wait for 50 ns;
                     bp_RELOJ <= '1';
                     wait for 50 ns;
                     bp_RELOJ <= '0';
                     bp_X <= '1';
                     wait for 50 ns;
    end process;
end architecture estructural;

Detector de secuencias

Detecter de secuencias que busca la secuencia 1101y al encontrarla activa la salida Z



library  ieee ;
use  ieee.std_logic_1164.all ;
entity  det_sec is
port ( CLK, RESET, x  :  in std_logic ;
          z : out std_logic );
end  det_sec ;
architecture  detector_1 of  det_sec  is             
type tipo_estado  is  ( A, B, C, D ) ;                
signal estado, siguiente_estado : tipo_estado ;
begin
process ( CLK, RESET )
 begin
    if ( RESET = '1' ) then
          estado <= A ;
    elsif ( CLK'event  and  CLK = '1' ) then
           estado <= siguiente_estado ;
     end if;
  end process ;
 
  process ( x, estado )
     begin
         case  estado  is
             when A =>
                  if  x = '1'  then
                       siguiente_estado <= B ;
                   else
                       siguiente_estado <= A ;
                  end if ;
              when B =>
                  if x = '1' then
                        siguiente_estado <= C ;
                  else
                        siguiente_estado <= A ;
                  end if ;
              when C =>
                   if x = '1' then
                        siguiente_estado <= C ;
                    else
                         siguiente_estado <= D ;
                   end if;
              when D =>
                    if  x = '1' then
                         siguiente_estado <= B  ;
                    else
                          siguiente_estado <= A ;
                    end if ;
          end case ;
  end process ;
  process ( x, estado )
    begin
        case  estado  is
            when  A =>
                z <= '0' ;
            when B =>
                z <= '0' ;
            when C =>
                z <= '0' ;
            when D =>
                if x = '1' then
                    z <= '1' ;
                else
                    z <= '0' ;
                end if ;
            end case ;
   
  end process ;
end detector_1 ;

domingo, 19 de junio de 2011

banco de pruebas decodificador 3 a 8 VHDL

Aqui les dejo el codigo que corresponde al banco de pruebas del decodificador 3 a 8 que les deje antes, exito.  Les recomiendo Geany para escribir el codigo y ModelSim para compilarlo y probarlo. exito


library ieee;
use IEEE.STD_LOGIC_1164.all;
entity banco_prueba is
end entity banco_prueba ;
architecture prueba_decodificador_3_a_8 of banco_prueba is
    signal  bp_H : std_logic;
    signal  bp_D : std_logic_vector(7 downto 0);
    signal    bp_S : std_logic_vector(2 downto 0);


begin
uut: entity work.decodificador_3_a_8(estructural_1)
port map ( H=>bp_H, S=>bp_S, D=>bp_D);
        
    process
      begin
        bp_H <= '0';
        bp_S <= "000";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "001";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "010";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "011";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "100";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "101";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "110";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "111";
        wait for 20 ns;
       
        bp_H <= '1';
        bp_S <= "000";
        wait for 20 ns;
        bp_H <= '1';
        bp_S <= "001";
        wait for 20 ns;
        bp_H <= '1';
        bp_S <= "010";
        wait for 20 ns;
        bp_H <= '1';
        bp_S <= "011";
        wait for 20 ns;
        bp_H <= '0';
        bp_S <= "100";
        wait for 20 ns;
        bp_H <= '1';
        bp_S <= "101";
        wait for 20 ns;
        bp_H <= '1';
        bp_S <= "110";
        wait for 20 ns;
        bp_H <= '1';
        bp_S <= "111";
        wait for 20 ns;
       

       
    end process;
end architecture prueba_decodificador_3_a_8;
 

VHDL. Decodificador 3 a 8

aqui les dejo el codigo en VHDL para un decodificador 3 a 8 utilizando process, case, if y vectores. Les recomiendo Geany para escribir el codigo y ModelSim para compilarlo y probarlo. exito




library ieee;                                       
use ieee.std_logic_1164.all;         
entity decodificador_3_a_8 is                              
port (    H : in std_logic;                                
        S : in std_logic_vector(2 downto 0);
        D : out std_logic_vector(7 downto 0));                               
end decodificador_3_a_8;
architecture estructural_1 of decodificador_3_a_8 is        
begin
  process(S,H)
  begin
    case s is
        when "000" =>
            if H ='1' then
                D <= "00000001";
            else
                D <= "00000000";
            end if;
        when "001" =>
            if H ='1' then
                D <= "00000010";
            else
                D <= "00000000";
            end if;
        when "010" =>
            if H ='1' then
                D <= "00000100";
            else
                D <= "00000000";
            end if;
            when "011" =>
            if H ='1' then
                D <= "00001000";
            else
                D <= "00000000";
            end if;
            when "100" =>
            if H ='1' then
                D <= "00010000";
            else
                D <= "00000000";
            end if;
            when "101" =>
            if H ='1' then
                D <= "00100000";
            else
                D <= "00000000";
            end if;
            when "110" =>
            if H ='1' then
                D <= "01000000";
            else
                D <= "00000000";
            end if;
            when "111" =>
            if H ='1' then
                D <= "10000000";
            else
                D <= "00000000";
            end if;
            when others =>
                D <= "00000000";           
        end case;

  end process;      
end estructural_1;


listo.