module tbe; // testbench for the 3-bit by 3-bit unsigned multiplier // exhaustive checking of all 64 possible cases reg [2:0] x, y; // 3-bit inputs wire [5:0] p; // 6-bit output of the multiplier circuit reg [5:0] check; // 6-bit product value used to check correctess integer i, j; // loop variables integer num_correct; // counter to keep track of the number correct integer num_wrong; // counter to keep track of the number wrong // instantiate the 3-bit by 3-bit multiplier mult3 mult_instance(x, y, p); // exhaustive checking of all 64 possible cases initial begin // initialize the counter variables num_correct = 0; num_wrong = 0; // loop through all possible cases and record the results for (i = 0; i < 8; i = i + 1) begin x = i; for (j = 0; j < 8; j = j + 1) begin y = j; check = x * y; // compute and check the product #10 if (p == check) num_correct = num_correct + 1; else num_wrong = num_wrong + 1; // following line is commented out, but is useful for debugging // $display($time, " %d * %d = %d (%d)", x, y, p, check); end end // print the final counter values $display("num_correct = %d, num_wrong = %d", num_correct, num_wrong); end endmodule