module Sobel_testbench;
reg clk_tb;
reg reset_n_tb;
reg in_valid_tb;
reg [7:0] in_data_tb;
wire [7:0] out_data_tb;
integer i; // loop counter
reg [7:0] storage_values [0:153600]; // size of image 640 x 240
// initalize the hexadecimal read from the txt file
initial $readmemh("myhexval_1d.txt", storage_values);
integer fileOutput;
// Control the clock signal
initial
clk_tb = 1'b0;
always
#5 clk_tb = ~clk_tb;
initial
begin
reset_n_tb = 1'b1;
#15 reset_n_tb = 1'b0;
for (i=0; i < 153600; i=i+1)
begin
in_data_tb = storage_values[i];
fileOutput = $fopen("result_sobel.txt", "w");
$fwrite(fileOutput,"%d\n",out_data_tb);
$fclose(fileOutput);
end
end
//instatiate the test hardware block
sobel_operator_eight_bit s1(clk_tb, reset_n_tb, in_valid_tb, in_data_tb, out_data_tb);
endmodule