module tb1hc; // random unsigned inputs, decimal values including a check reg [7:0] a, b; // 8-bit inputs (to be chosen randomly) reg c0; // carry input (to be chosen randomly) wire [7:0] s; // 8-bit sum output wire c8; // carry out of the MSB position reg [8:0] check; // 9-bit sum value used to check correctess // instantiate the 8-bit Han-Carlson adder han_carlson hc1(a, b, c0, s, c8); // simulation of 50 random addition operations initial repeat (50) begin // get new operand values and compute a check value a = $random; b = $random; c0 = $random; check = a + b + c0; // compute and display the sum every 10 time units #10 $display($time, " %d + %d + %d = %d (%d)", a, b, c0, {c8, s}, check); end endmodule