module tb1wallace; // random unsigned inputs, decimal values including a check reg [7:0] p0, p1, p2, p3, p4, p5; // 8-bit inputs (to be chosen randomly) wire [8:0] s; // 9-bit sum output wire [9:1] c; // 9-bit carry output reg [10:0] sval, check; // 11-bit final sum and check values // instantiate the 6-input Wallace tree wallace wallace1(p0, p1, p2, p3, p4, p5, s, c); // simulation of 50 random addition operations initial repeat (50) begin // get new operand values and compute a check value p0 = $random; p1 = $random; p2 = $random; p3 = $random; p4 = $random; p5 = $random; check = p0 + p1 + p2 + p3 + p4 + p5; // compute and display the final sum value every 10 time units #10 sval = s + (2*c); $display($time, " %d + %d + %d + %d + %d + %d = %d (%d)", p0, p1, p2, p3, p4, p5, sval, check); end endmodule