Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. library IEEE;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity soma is
  5. generic (
  6. n: integer := 16
  7. );
  8. port (
  9. a : in std_logic_vector(n-1 downto 0);
  10. b : in std_logic_vector(n-1 downto 0);
  11. clk : in std_logic;
  12. q : out std_logic_vector (n-1 downto 0)
  13. );
  14. end soma;
  15.  
  16. architecture comport of soma is
  17. begin
  18. process(a,b)
  19. variable v : integer;
  20. begin
  21. for v in 0 to (n-1) loop
  22. if (v=0) then
  23. q(v) <= a(v) xor b(v);
  24. else
  25. q(v) <= a(v) xor b(v) xor (a(v-1) and b(v-1));
  26. end if;
  27. end loop;
  28. end process;
  29. end comport;
  30.  
  31. ------------------------------------------------------------------------------------------------
  32.  
  33. library IEEE;
  34. use ieee.std_logic_1164.all;
  35.  
  36. entity somador is
  37. generic (
  38. gen : integer := 4
  39. );
  40.  
  41. port (
  42. A : in std_logic_vector (gen-1 downto 0);
  43. B : in std_logic_vector (gen-1 downto 0);
  44. C: in std_logic;
  45. Q : out std_logic_vector (gen-1 downto 0)
  46. );
  47. end somador;
  48.  
  49. architecture rtl of somador is
  50. component soma is
  51. generic (
  52. n: integer := 16
  53. );
  54. port (
  55. a : in std_logic_vector(n-1 downto 0);
  56. b : in std_logic_vector(n-1 downto 0);
  57. clk : in std_logic;
  58. q : out std_logic_vector (n-1 downto 0)
  59. );
  60. end component;
  61.  
  62. begin
  63. r1 : soma
  64. generic map(
  65. n => gen
  66. )
  67.  
  68. port map (
  69. a => A,
  70. b => B,
  71. clk => C,
  72. q => Q
  73. );
  74. end rtl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement