module tb7xy4z; // testbench for the XY + 4*Z circuit // random inputs, decimal values including a check reg [4:0] x; // 5-bit inputs (to be chosen randomly) reg [3:0] y; // 4-bit inputs (to be chosen randomly) reg [5:0] z; // 6-bit inputs (to be chosen randomly) wire [9:0] s; // 10-bit output of the XY + 4*Z circuit reg [9:0] check; // 10-bit XY + 4*Z value used to check correctess // instantiate the XY + 4*Z circuit xyz xy4z_instance(x, y, z, s); // simulation of 20 random XY + 4*Z operations initial repeat (20) begin // get new operand values and compute a check value x = $random; y = $random; z = $random; check = x * y + 4* z; // compute and display the value every 10 time units #10 $display($time, " (%d * %d) +(4 * %d) = %d (%d)", x, y, z, s, check); end endmodule