#include "debayer_tb.h"
static const char *output_filename = "large_kernel1_output.bin";
static const char *golden_output_filename = "large_golden_kernel1_output.bin";
static const char *input_filename = "large_kernel1_input.bin";
//read input files input/input.txt and input/golden_out.txt
//for input.txt, line 1: clock period T-clk,
//line 2: time resent when reset is deactivated, t-rst
//line 3: integer representing expected duration of sim, T-sim
//line 4- : t-in, path to image (eg input/dog.bin)
//send to debayer.cpp
//write file output/result.txt where
//line 1: integer time when a debayered image is produced t-out = t-in + T-clk
//line 2: path to the output image, eg output/0000.bin
void debayer_tb::source(){
//in lines 4+, read time, and if t-in == time_stamp, read that file
//once read file and place it into file_data, send the data to the dut by setting
//data to file_data (data is the output defined in debayer_tb.h)
u16 (*bayer)[WAMI_DEBAYER_IMG_NUM_COLS] = NULL;
rgb_pixel (*debayer)[WAMI_DEBAYER_IMG_NUM_COLS-2*PAD] = NULL;
const size_t num_bayer_pixels = WAMI_DEBAYER_IMG_NUM_ROWS *
WAMI_DEBAYER_IMG_NUM_COLS;
//Read input.txt line by line
ifstream myfile;
std::string line;
//file_line represents an array of arrays that each hold one string of a line
string file_line[7][2];
int i = 0;
myfile.open("input.txt");
if (myfile.is_open()){
while ( getline (myfile,line) ){
istringstream iss(line);
copy(istream_iterator<string>(iss),
istream_iterator<string>(),
back_inserter(file_line[i]));
i++;
}
}
myfile.close();
}
else cout << "Unable to open file";
// Check for Reset
if (!rst.read()) {
RESET:
// Initialize the output data to zero
out_data.write(0);
} else if (clk.event()) {
// Read each line containing the time and file name
for(int i = 3; i<7; i++){
if(file_line[i][0] == sc_time_stamp()){
//char *input_directory = concat_file_dir_name(file_line[i][1], "../input/");
// If the time stamp is equal to the time of the input image, read the input image
// TODO ?? is input_file the name of the file or path to file??
read_image_file((void*) out_data, sizeof(u16), file_line[i][1], input_directory,
sizeof(u16) * num_bayer_pixels);
}
}
}
}
void debayer_tb::sink(){
//print to the standard out like in the example, examples/lecture03/MAC_basic/tb/mac_tb.cpp
//and tb/sc_main.cpp. It prints when the results are different and how many mismatches it had.
//do we compare the golden_output to the result.txt here?