Advertisement
Guest User

aiaiaiaih

a guest
Sep 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. module halfadder (a, b, sum, cout);
  2. input a, b;
  3. output sum, cout;
  4.  
  5. and carry(cout, a, b);
  6. xor (sum, a, b);
  7.  
  8. endmodule
  9.  
  10.  
  11.  
  12. module fulladder (a, b, cin, sum, cout);
  13. input a, b, cin;
  14. output sum, cout;
  15.  
  16. wire carry1, carry2, sum1;
  17.  
  18. halfadder h1 (a, b, sum1, carry1);
  19. halfadder h2 (cin, sum1, sum, carry2);
  20.  
  21. or (cout, carry1, carry2);
  22.  
  23. endmodule
  24.  
  25. module SubtractorCircuit (a1, b1, a2, b2, a3, b3, a4, b4, cin, coutinv,sum11, sum22, sum33, sum44);
  26.  
  27. input a1, b1, a2, b2, a3, b3, a4, b4, cin;
  28. output sum11, sum22, sum33, sum44,coutinv;
  29.  
  30. wire carry1, carry2, carry3;
  31. wire b11,b22,b33,b44, cout;
  32. wire sum1, sum2, sum3, sum4;
  33.  
  34. not(b11,b1);
  35. not(b22,b2);
  36. not(b33,b3);
  37. not(b44,b4);
  38. not(coutinv,cout);
  39. not(sum11,sum1);
  40. not(sum22,sum2);
  41. not(sum33,sum3);
  42. not(sum44,sum4);
  43.  
  44. fulladder f1(a1, b11, cin, sum1, carry1);
  45. fulladder f2(a2, b22, carry1, sum2, carry2);
  46. fulladder f3(a3, b33, carry2, sum3, carry3);
  47. fulladder f4(a4, b44, carry3, sum4, cout);
  48.  
  49. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement