// Test fixture that takes data from the FIFO // We generate a pseudo-random string of data according // to a seed and check this against the input. // We also generate takingData at a random // rate according to a second seed. `timescale 1ns / 1ns module fifo_in_tf(/*AUTOARG*/ // Outputs takingData, // Inputs clk, reset, dataValid, data_in ); parameter WIDTH = 32; // FIFO width parameter DATASEED = 187; // Must match fifo_out_tf // We generate TakingData RATE/128 % of the time parameter RATE = 10; parameter LASTDATA = 0; // Marks last data sent input clk; input reset; input dataValid; output takingData; input [WIDTH-1:0] data_in; /*AUTOREG*/ // Beginning of automatic regs (for this module's undeclared outputs) reg takingData; // End of automatics reg [WIDTH-1:0] checkData; always @(posedge clk) begin if (reset) begin checkData <= DATASEED; takingData <= 0; end else begin if (dataValid & takingData) begin if (data_in == LASTDATA) begin $display("Test complete"); $finish; end if (checkData != data_in) begin $display("ERROR: check=%d, data_in=%d", checkData, data_in); $stop; end checkData <= checkData*1234567 + 98765; end end takingData <= (($random & 127) < RATE); end endmodule // fifo_in_tf