Digital Systems Laboratory - Eskişehir Osmangazi Üniversitesi
Digital Systems Laboratory - Eskişehir Osmangazi Üniversitesi
Digital Systems Laboratory - Eskişehir Osmangazi Üniversitesi
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
module testbench_v;// Outputswire sig3;// Inputsreg sig1;reg sig2;// Instantiate the Unit Under Test (UUT)two_input_xor uut (.in1(sig1),.in2(sig2),.out(sig3));reg test_passed;initial begin// Let's start off assuming we are going// to pass the tests until we find a case// that contradicts!test_passed = 1'b1;// Test Case #0sig1 = 1'b0;sig2 = 1'b0;#5;$display("At time %t, sig1 = %b, sig2 = %b, output = %b.",$time, sig1, sig2, sig3);if (sig3 != 1'b0) test_passed = 1'b0;// Test Case #1sig1 = 1'b0;sig2 = 1'b1;#5;$display("At time %t, sig1 = %b, sig2 = %b, output = %b.",$time, sig1, sig2, sig3);if (sig3 != 1'b1) test_passed = 1'b0;// Test Case #2sig1 = 1'b1;sig2 = 1'b0;#5;$display("At time %t, sig1 = %b, sig2 = %b, output = %b.",$time, sig1, sig2, sig3);if (sig3 != 1'b1) test_passed = 1'b0;// Test Case #3sig1 = 1'b1;sig2 = 1'b1;#5;$display("At time %t, sig1 = %b, sig2 = %b, output = %b.",$time, sig1, sig2, sig3);if (sig3 != 1'b0) test_passed = 1'b0;// Now, print out a message with the test// results and then finish the simulation.if (test_passed) $display("Result: PASS");else $display("Result: FAIL");$stop;end46