Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //code
- module rcadder(
- input logic a1, b1, a2, b2, a3, b3, a4, b4,
- output logic s1, s2, s3, s4, c4
- );
- logic c1, c2, c3;
- fa fa1(a1, b1, 0, s1, c1);
- fa fa2(a2, b2, c1, s2, c2);
- fa fa3(a3, b3, c2, s3, c3);
- fa fa4(a4, b4, c3, s4, c4);
- endmodule
- module fa(
- input logic a, b, cin,
- output logic sum, cout
- );
- assign sum = a^b^cin;
- assign cout = a*b + b*cin + cin*a;
- endmodule
- //testbench
- module rcadder_tb();
- logic a1, b1, a2, b2, a3, b3, a4, b4;
- logic s1, s2, s3, s4, c4;
- rcadder uut(a1, b1, a2, b2, a3, b3, a4, b4,s1, s2, s3, s4, c4);
- initial begin
- a1 = 1; a2 = 0; a3 = 1; a4 = 1;
- b1 = 1; b2 = 1; b3 = 1; b4 = 1;
- #10
- a1 = 1; a2 = 0; a3 = 0; a4 = 0;
- b1 = 1; b2 = 1; b3 = 1; b4 = 1;
- #10
- $finish;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement