Advertisement
foreverfugazi

Untitled

Oct 16th, 2023
2,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //code
  2. module rcadder(
  3.     input logic a1, b1, a2, b2, a3, b3, a4, b4,
  4.     output logic s1, s2, s3, s4, c4
  5.     );
  6.     logic c1, c2, c3;
  7.     fa fa1(a1, b1, 0, s1, c1);
  8.     fa fa2(a2, b2, c1, s2, c2);
  9.     fa fa3(a3, b3, c2, s3, c3);
  10.     fa fa4(a4, b4, c3, s4, c4);
  11. endmodule
  12.  
  13. module fa(
  14.     input logic a, b, cin,
  15.     output logic sum, cout
  16.     );
  17.     assign sum = a^b^cin;
  18.     assign cout = a*b + b*cin + cin*a;
  19. endmodule
  20.  
  21. //testbench
  22.  
  23. module rcadder_tb();
  24. logic a1, b1, a2, b2, a3, b3, a4, b4;
  25. logic s1, s2, s3, s4, c4;
  26.  
  27. rcadder uut(a1, b1, a2, b2, a3, b3, a4, b4,s1, s2, s3, s4, c4);
  28.  
  29. initial begin
  30. a1 = 1; a2 = 0; a3 = 1; a4 = 1;
  31. b1 = 1; b2 = 1; b3 = 1; b4 = 1;
  32. #10
  33. a1 = 1; a2 = 0; a3 = 0; a4 = 0;
  34. b1 = 1; b2 = 1; b3 = 1; b4 = 1;
  35. #10
  36. $finish;
  37. end
  38. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement