Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 10/23/2019 05:12:14 PM
  6. -- Design Name:
  7. -- Module Name: carry_lookahead_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.  
  23. entity carry_lookahead_adder is
  24. generic ( n : integer := 4);
  25. Port ( a : in STD_LOGIC_VECTOR (3 downto 0);
  26. b : in STD_LOGIC_VECTOR (3 downto 0);
  27. cin : in STD_LOGIC;
  28. s : out STD_LOGIC_VECTOR (3 downto 0);
  29. cout : out STD_LOGIC);
  30. end carry_lookahead_adder;
  31.  
  32. architecture Behavioral of carry_lookahead_adder is
  33.  
  34. signal c : std_logic_vector(4 downto 0);
  35. signal g : std_logic_vector(3 downto 0);
  36. signal p : std_logic_vector(3 downto 0);
  37.  
  38. component fulAdder1 iS
  39. Port ( A : in STD_LOGIC;
  40. B : in STD_LOGIC;
  41. Cin : in STD_LOGIC;
  42. S : out STD_LOGIC;
  43. Cout : out STD_LOGIC);
  44. end component;
  45. signal carry_out: std_logic_vector(N downto 0);
  46.  
  47. begin
  48.  
  49. fullA: FOR k IN 0 to N-1 GENERATE
  50. ca: fulAdder1
  51. port map ( A(K), B(K),carry_out(k), s(k), carry_out(k+1));
  52. end GENERATE fullA;
  53.  
  54. carry_out(0) <= cin;
  55. cout <= carry_out(N);
  56.  
  57.  
  58. process (a, b, c, g, p, c)
  59. begin
  60. c(0) <= cin;
  61. for i in 0 to 3 loop
  62. g(i) <= a(i) and b(i);
  63. p(i) <= a(i) or b(i);
  64. c(i + 1) <= g(i) or (p(i) and c(i));
  65. end loop;
  66. cout <= c(4);
  67. end process;
  68.  
  69. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement