Guest User

Untitled

a guest
Jul 20th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. -- Example of a four bit adder
  2. library ieee;
  3. use ieee.std_logic_1164.all;
  4. -- definition of a full adder
  5. entity FULLADDER is
  6. port (a, b, c: in std_logic;
  7. sum, carry: out std_logic);
  8. end FULLADDER;
  9. architecture fulladder_behav of FULLADDER is
  10. begin
  11. sum <= (a xor b) xor c ;
  12. carry <= (a and b) or (c and (a xor b));
  13. end fulladder_behav;
  14.  
  15. -- 4-bit adder
  16. library ieee;
  17. use ieee.std_logic_1164.all;
  18.  
  19. entity FOURBITADD is
  20. port (a, b: in std_logic_vector(3 downto 0);
  21. Cin : in std_logic;
  22. sum: out std_logic_vector (3 downto 0);
  23. Cout, V: out std_logic);
  24. end FOURBITADD;
  25.  
  26. architecture fouradder_structure of FOURBITADD is
  27. signal c: std_logic_vector (4 downto 0);
  28. component FULLADDER
  29. port(a, b, c: in std_logic;
  30. sum, carry: out std_logic);
  31. end component;
  32. begin
  33. FA0: FULLADDER
  34. port map (a(0), b(0), Cin, sum(0), c(1));
  35. FA1: FULLADDER
  36. port map (a(1), b(1), C(1), sum(1), c(2));
  37. FA2: FULLADDER
  38. port map (a(2), b(2), C(2), sum(2), c(3));
  39. FA3: FULLADDER
  40. port map (a(3), b(3), C(3), sum(3), c(4));
  41. V <= c(3) xor c(4);
  42. Cout <= c(4);
  43. end fouradder_structure;
Add Comment
Please, Sign In to add comment