/*************************************************************************/ /* File: interpolator_tf.v * Author: Corey Olson * * Description: Test Fixture for Adaptive Interpolation Filter. * Revsions: * 1.0 Initial design - 1/19/2010 - Corey Olson * 1.2 Updated - 1/24/2010 - Carl Ebeling **************************************************************************/ module interpolator_tf (); localparam halfScale = 128; reg [7:0] pixelIn, average; reg dataValid; wire incorrectData; wire [7:0] pixelOut, correctOutput; ///////// // DUT // ///////// interpolate DUT (.pixelIn(pixelIn),.average(average),.pixelOut(pixelOut)); // this will check for correct output assign correctOutput = (pixelIn <= average) ? ((2 * halfScale * pixelIn + average) / (2*average)) : (halfScale + (2 * (halfScale-1) * (pixelIn - average) + (2*halfScale - 1 - average)) / (2*(2*halfScale - 1 - average))); // visual check for simulation assign incorrectData = |(correctOutput ^ pixelOut); // compare the data to the expected data values always @ (pixelIn) begin #10; $display("Average: %d, pixelIn: %d, Expected: %d, pixelOut: %d\n", average, pixelIn, correctOutput, pixelOut); if (dataValid && (pixelOut !== correctOutput)) begin $display("Data does not match expected output...Ending simulation...\n"); $stop; end end initial begin dataValid = 1'b0; average = 8'd128; pixelIn = 8'd20; // allow for strange data at powerup #100 dataValid = 1'b1; #100 pixelIn = 8'd200; #100; // try random inputs now repeat (10) begin average = $random; repeat (10) begin pixelIn = $random; #100; end end end endmodule