Advertisement
wojtas626

[VHDL] ALU

Jan 27th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.69 KB | None | 0 0
  1. entity ALU is
  2.     port( CLK : in std_logic;
  3.           A : in std_logic_vector(31 ownto 0);
  4.           B : in std_logic_vector(31 downto 0);
  5.           C : out std_logic_vector(31 downto 0);
  6.           TYP_DZIALANIA : in std_logic_vector(2 downto 0) -- 1='+'; 2='-'; 3='*'; 4='and'; 5='or'
  7.     );
  8. end ALU;
  9.  
  10.  
  11. architecture arch_ALU of ALU is
  12.     process (CLK)
  13.     begin
  14.         if (CLK''event and CLK='1') then
  15.             if (TYP_DZIALANIA = '001') then
  16.                 C <= A + B;
  17.             elsif (TYP_DZIALANIA = '010') then
  18.                 C <= A - B;
  19.             elsif (TYP_DZIALANIA = '011') then
  20.                 C <= A * B;
  21.             elsif (TYP_DZIALANIA = '100') then
  22.                 C <= A and B;
  23.             elsif (TYP_DZIALANIA = '101') then
  24.                 C <= A or B;
  25.             end if;
  26.         end if;
  27.     end process;
  28. end arch_ALU;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement