//-------------------------------------------------------------------------------------------------- // // Title : adder4_tf // Design : HW3 // Author : Lucas Kreger-Stickles // Company : uw // //------------------------------------------------------------------------------------------------- // // File : adder4_tf.v // //------------------------------------------------------------------------------------------------- // // Description : Run this test fixture for 20us to test your 4 bit ripple carry adder. // //------------------------------------------------------------------------------------------------- `timescale 1ns / 1ns module adder4_tf ( A ,Cin ,B ,Cout ,Sum ); input Cout ; input [3:0] Sum ; output [3:0] A ; output [3:0] B ; output Cin ; reg [3:0] A ; reg [3:0] B ; reg Cin ; integer i; initial begin for (i=0; i<1000 ; i=i+1) begin A = $random; B = ($random & 1'b1) ? ~A : $random; Cin = $random; #20; if ({Cout,Sum} != A+B+Cin) begin $display("Error: on A: %d, B: %d, Cin: %d... should be: %d",A,B,Cin,(A+B+Cin)); $stop; end else begin //$display("Correct: on A:%d, B:%d, Cin:%d == %d ",A,B,Cin,(A+B+Cin)); end//else end // for (i=0; i<8; i=i+1) $display("Test Passed: No errors found"); end // initial begin endmodule