Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 20:58:27 10/26/2016
  6. -- Design Name:
  7. -- Module Name: carry_adder - 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. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. ---- Uncomment the following library declaration if instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity carry_adder is
  31. port(
  32. A : in std_logic_vector(3 downto 0);
  33. B : in std_logic_vector (3 downto 0);
  34. carryIn : in std_logic ;
  35. carryOut : out std_logic;
  36. result : out std_logic_vector( 3 downto 0)
  37. );
  38. -- defining signals used
  39.  
  40. signal carryGenerate : std_logic_vector(3 downto 0);
  41. signal carryPropagate : std_logic_vector(3 downto 0);
  42. signal carryInternal : std_logic_vector(3 downto 0);
  43.  
  44.  
  45.  
  46. end carry_adder;
  47.  
  48. architecture Behavioral of carry_adder is
  49.  
  50. begin
  51.  
  52. process (A,B,carryPropagate,carryInternal,carryGenerate)
  53. begin
  54.  
  55. carryPropagate <= A xor B;
  56. carryGenerate <= A and B;
  57. carryInternal(1) <= carryGenerate(0) or (carryPropagate(0) and carryIn);
  58.  
  59. inst :for i in 1 to 2 loop
  60. carryInternal(i+1) <= carryGenerate(1) or (carryPropagate(i) and carryInternal(i));
  61. end loop;
  62. carryOut <= carryGenerate(3) or (carryPropagate(3) and carryInternal(3));
  63. result(0) <= carryPropagate(0) xor carryIn;
  64. result(3 downto 1) <= carryPropagate(3 downto 1) xor carryInternal(3 downto 1);
  65.  
  66.  
  67. end process;
  68.  
  69. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement