Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.85 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    13:56:38 11/17/2014
  6. -- Design Name:
  7. -- Module Name:    alu32 - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. library UNISIM;
  30. use UNISIM.VComponents.all;
  31.  
  32. entity alu32 is
  33.     Port ( A : in  STD_LOGIC_VECTOR (31 downto 0);
  34.            B : in  STD_LOGIC_VECTOR (31 downto 0);
  35.               F : in  STD_LOGIC_VECTOR (2 downto 0);
  36.            Y : out  STD_LOGIC_VECTOR (31 downto 0);
  37.            Zero : out  STD_LOGIC);
  38. end alu32;
  39.  
  40.  
  41.  
  42. architecture Behavioral of alu32 is
  43.  
  44. signal b_prime : STD_LOGIC_VECTOR (31 downto 0);
  45. signal sum : STD_LOGIC_VECTOR (31 downto 0);
  46. signal f_add : STD_LOGIC_VECTOR (31 downto 0);
  47. signal slt : STD_LOGIC_VECTOR (31 downto 0);
  48.  
  49. begin
  50.     f_add(31 downto 1) <= "0000000000000000000000000000000";
  51.     f_add(0) <= F(2);
  52.     sum <= std_logic_vector(signed(A) + signed(b_prime) + signed(f_add));
  53.     slt(31 downto 1) <= "0000000000000000000000000000000";
  54.     slt(0) <= sum(31);
  55.    
  56.     with F(2) select
  57.         b_prime <=  NOT B when '1',
  58.                         B when '0',
  59.                         x"00000000" when others;
  60.    
  61.     with F(1 downto 0) select
  62.         Y <=    A AND b_prime when "00",
  63.                 A OR b_prime when "01",
  64.                 sum when "10",
  65.                 slt when "11",
  66.                 x"00000000" when others;
  67.  
  68.     Zero <= '1' when sum = x"00000000" else '0';
  69.  
  70. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement