Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 10/23/2019 04:55:49 PM
  6. -- Design Name:
  7. -- Module Name: CarryLookahead - 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.  
  21.  
  22. library IEEE;
  23. use IEEE.STD_LOGIC_1164.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx leaf cells in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity CarryLookahead is
  35. Generic(N:integer:=3);
  36. Port (
  37. a:in std_logic_vector(N-1 downto 0);
  38. b:in std_logic_vector(N-1 downto 0);
  39. s:out std_logic_vector(N-1 downto 0);
  40. cin:in std_logic;
  41. cout:out std_logic
  42. );
  43. end CarryLookahead;
  44.  
  45. architecture Behavioral of CarryLookahead is
  46. component FullAdder is
  47. Port ( a : in STD_LOGIC;
  48. b : in STD_LOGIC;
  49. cin : in STD_LOGIC;
  50. s : out STD_LOGIC;
  51. cout : out STD_LOGIC);
  52. end component FullAdder;
  53. signal carry:std_logic_vector(N downto 0);
  54. signal misc:std_logic_vector(N downto 0);
  55. begin
  56. addere: for i in 0 to N-1 generate
  57. i_FULL_ADDER_INST : FullAdder port map(a=>a(i), b=>b(i), s=>s(i), cin=>carry(i), cout=>misc(i));
  58. end generate;
  59.  
  60. carry(0) <= cin;
  61. cout<=carry(N);
  62.  
  63.  
  64. process(a, b, cin)
  65. begin
  66. for i in 1 to N-1 loop
  67. carry(i+1) <= (a(i) and b(i)) or ((a(i) or b(i)) and carry(i));
  68. end loop;
  69. end process;
  70. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement