marcoshuck

Comparador binario (4 bits)

Jun 3rd, 2016
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.86 KB | None | 0 0
  1. -- Declaramos librerías
  2. library IEEE;
  3. use IEEE.STD_LOGIC_1164.ALL;
  4. use IEEE.STD_LOGIC_ARITH.ALL;
  5. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  6.  
  7. -- Definimos la entidad
  8. entity base is
  9.     Port (
  10.         A0, A1, A2, A3 : in std_logic; -- Entradas A
  11.         B0, B1, B2, B3 : in std_logic; -- Entradas B
  12.         mayor, menor, igual : out std_logic -- Salidas
  13.         );
  14. end base;
  15.  
  16. -- Definimos la arquitectura
  17. architecture behavioral of base is
  18. signal A: std_logic_vector(3 downto 0); -- Vector A
  19. signal B: std_logic_vector(3 downto 0); -- Vector B
  20. begin
  21.     process(A3, A2, A1, A0)
  22.     begin
  23.         A(3) <= A3;
  24.         A(2) <= A2;
  25.         A(1) <= A1;
  26.         A(0) <= A0;
  27.     end process;
  28.    
  29.     process(B3, B2, B1, B0)
  30.     begin
  31.         B(3) <= B3;
  32.         B(2) <= B2;
  33.         B(1) <= B1;
  34.         B(0) <= B0;
  35.     end process;
  36.    
  37.     mayor <= '1' when(A>B) else '0';
  38.     menor <= '1' when(A<B) else '0';
  39.     igual <= '1' when(A=B) else '0';
  40.    
  41. end behavioral;
Advertisement