SallatielFernandes

ula

Nov 26th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.01 KB | None | 0 0
  1. -- ULA com 4 bits de entrada e 5 bits de saida, opcode com 6 operacoes
  2. -- Autores: Joao Vitor e Marcos Meira
  3. -- Data 28/07/2017
  4.  
  5. library IEEE;
  6. use IEEE.STD_LOGIC_1164.ALL;
  7. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  8.  
  9. entity ula is
  10.     Port ( NUM1: in  STD_LOGIC_VECTOR (3 downto 0);    --
  11.            NUM2: in  STD_LOGIC_VECTOR (3 downto 0);    -- 4-bit number
  12.            op_code: in  STD_LOGIC_VECTOR (2 downto 0);
  13.              saida: out STD_LOGIC_VECTOR (4 downto 0));   -- 5 bit result
  14. end ula;
  15.  
  16. architecture behavioral of ula is
  17. begin
  18.  
  19.     process (op_code, NUM1, NUM2)
  20.     begin
  21.         case op_code is
  22.             when "000" => saida <= ('0' & NUM1) + ('0' & NUM2);
  23.             when "001" => saida <= ('0' & NUM1) - ('0' & NUM2);
  24.             when "010" => saida <= ('0' & NUM1) and ('0' & NUM2);
  25.             when "011" => saida <= ('0' & NUM1) or ('0' & NUM2);
  26.             when "100" => saida <= ('0' & NUM1) xor ('0' & NUM2);
  27.             when "101" => saida <= ('0' & NUM1) xnor ('0' & NUM2);
  28.             when others => saida <= "00000";
  29.         end case;
  30.     end process;
  31.    
  32. end behavioral;
Add Comment
Please, Sign In to add comment