module tb3; // random inputs, decimal values including a check reg [3:0] a, b; // 4-bit inputs (to be chosen randomly) reg c; // carry input (to be chosen randomly) wire [4:0] s; // 5-bit output of the RCA circuit reg [4:0] check; // 5-bit sum value used to check correctess // instantiate the 4-bit ripple-carry adder RCA rca1(a, b, c, s); // simulation of 20 random addition operations initial repeat (20) begin // get new operand values and compute a check value a = $random; b = $random; c = $random; check = a + b + c; // compute and display the sum every 10 time units #10 $display($time, " %d + %d + %d = %d (%d)", a, b, c, s, check); end endmodule