// // Title : 16-1 multiplexer test fixture // Author : Carl Ebeling // Company : CSE 370 // //------------------------------------------------------------------------------------------------- // // File : mux16_tf.v // // Description : This test fixture tests the 16-1 multiplexer. We can't try all combinations, // so we'll generate random tests on the D input while trying many select combinations // //------------------------------------------------------------------------------------------------- `timescale 1ns / 1ns module mux16_tf (D, S, Q); output [15:0] D; output [3:0] S; input Q; reg [15:0] D; reg [3:0] S; integer errors; integer count; initial begin errors = 0; for (count = 0; count < 1024; count = count + 1) begin { S } = count; // Sets S from the low order bits of count D = $random; // Set D to a random 16-bit value #10 // Wait 10 ns. if (Q != D[S]) begin $display("***Error*** D:%b, S:%d, Q:%b", D, S, Q); errors = errors + 1; $stop; // Stop simulation so we can look at error end end if (errors == 0) $display("Test passed - No errors!!"); else $display("**** %d Errors****", errors); end endmodule