Advertisement
lasthunter657

Untitled

Dec 21st, 2021
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity full_adder is
  6. port (
  7. i_bit1 : in std_logic;
  8. i_bit2 : in std_logic;
  9. i_carry : in std_logic;
  10. --
  11. o_sum : out std_logic;
  12. o_carry : out std_logic
  13. );
  14. end full_adder;
  15.  
  16.  
  17. architecture rtl of full_adder is
  18.  
  19. signal w_WIRE_1 : std_logic;
  20. signal w_WIRE_2 : std_logic;
  21. signal w_WIRE_3 : std_logic;
  22.  
  23. begin
  24.  
  25. w_WIRE_1 <= i_bit1 xor i_bit2;
  26. w_WIRE_2 <= w_WIRE_1 and i_carry;
  27. w_WIRE_3 <= i_bit1 and i_bit2;
  28.  
  29. o_sum <= w_WIRE_1 xor i_carry;
  30. o_carry <= w_WIRE_2 or w_WIRE_3;
  31.  
  32.  
  33. -- FYI: Code above using wires will produce the same results as:
  34. -- o_sum <= i_bit1 xor i_bit2 xor i_carry;
  35. -- o_carry <= (i_bit1 xor i_bit2) and i_carry) or (i_bit1 and i_bit2);
  36. -- Wires are just used to be explicit.
  37.  
  38. end rtl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement