Advertisement
Guest User

VHDL1CODE

a guest
Jul 7th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.25 KB | None | 0 0
  1. Entity FADDER is
  2. port(A,B,Cin: in STD_LOGIC;
  3.     Cout,S: out STD_LOGIC);
  4. End FADDER;
  5.  
  6. Architecture FA of FADDER is
  7. Signal P,G;
  8. begin
  9. P<=A xor B;
  10. G<=A and B;
  11. S<=P xor Cin;
  12. Cout<=G or (P and Cin);
  13. end FA;
  14.  
  15. Entity RC5 is
  16. port(A,B: in STD_LOGIC_VECTOR(4 downto 0);
  17.     Cin: in STD_LOGIC;
  18.     S: out STD_LOGIC_VECTOR(5 downto 0));
  19. end RC5;
  20.  
  21. Architecture Behavioral of RC5 is
  22. Component FADDER is
  23. port(A,B,Cin: in STD_LOGIC;
  24.     Cout,S: out STD_LOGIC);
  25. End Component;
  26. Signal C:STD_LOGIC_VECTOR(3 downto 0);
  27. begin
  28. FA0: FADDER port map(A(0),B(0),'0',C(0),S(0));
  29. FA0: FADDER port map(A(1),B(1),C(0),C(1),S(2));
  30. FA0: FADDER port map(A(2),B(2),C(1),C(2),S(2));
  31. FA0: FADDER port map(A(3),B(3),C(2),C(3),S(3));
  32. FA0: FADDER port map(A(4),B(4),C(3),S(4),S(3));
  33. end Behavioral;
  34.  
  35. Entity compl is
  36. port(A,B: in STD_LOGIC_VECTOR(3 downto 0);
  37.     CompA,CompaB: out STD_LOGIC_VECTOR(4 downto 0));
  38. end compl;
  39.  
  40. Architecture Behavioral of compl is
  41. Component RC5 is
  42. port(A,B: in STD_LOGIC_VECTOR(3 downto 0);
  43.     Cin: in STD_LOGIC;
  44.     S: out STD_LOGIC_VECTOR(5 downto 0));
  45. End Component
  46. Signal XA, XB: STD_LOGIC_VECTOR(4 downto 0);
  47. Begin
  48. XA<=A(3)&A;
  49. XB<=B(3)&B;
  50. Rc5_1: RC5 port map(not(XA),"00001",'0',CompA);
  51. Rc5_2: RC5 port map(not(XB),"00001",'0',CompB);
  52. end Behavioral
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement