fork download
  1. #include "debayer_tb.h"
  2.  
  3. static const char *output_filename = "large_kernel1_output.bin";
  4. static const char *golden_output_filename = "large_golden_kernel1_output.bin";
  5. static const char *input_filename = "large_kernel1_input.bin";
  6.  
  7. //read input files input/input.txt and input/golden_out.txt
  8. //for input.txt, line 1: clock period T-clk,
  9. //line 2: time resent when reset is deactivated, t-rst
  10. //line 3: integer representing expected duration of sim, T-sim
  11. //line 4- : t-in, path to image (eg input/dog.bin)
  12.  
  13. //send to debayer.cpp
  14.  
  15. //write file output/result.txt where
  16. //line 1: integer time when a debayered image is produced t-out = t-in + T-clk
  17. //line 2: path to the output image, eg output/0000.bin
  18.  
  19. void debayer_tb::source(){
  20. //in lines 4+, read time, and if t-in == time_stamp, read that file
  21. //once read file and place it into file_data, send the data to the dut by setting
  22. //data to file_data (data is the output defined in debayer_tb.h)
  23.  
  24. u16 (*bayer)[WAMI_DEBAYER_IMG_NUM_COLS] = NULL;
  25. rgb_pixel (*debayer)[WAMI_DEBAYER_IMG_NUM_COLS-2*PAD] = NULL;
  26. const size_t num_bayer_pixels = WAMI_DEBAYER_IMG_NUM_ROWS *
  27. WAMI_DEBAYER_IMG_NUM_COLS;
  28.  
  29. //Read input.txt line by line
  30. ifstream myfile;
  31. std::string line;
  32. //file_line represents an array of arrays that each hold one string of a line
  33. string file_line[7][2];
  34. int i = 0;
  35. myfile.open("input.txt");
  36. if (myfile.is_open()){
  37. while ( getline (myfile,line) ){
  38. istringstream iss(line);
  39. copy(istream_iterator<string>(iss),
  40. istream_iterator<string>(),
  41. back_inserter(file_line[i]));
  42. i++;
  43. }
  44. }
  45. myfile.close();
  46. }
  47. else cout << "Unable to open file";
  48.  
  49. // Check for Reset
  50. if (!rst.read()) {
  51. RESET:
  52. // Initialize the output data to zero
  53. out_data.write(0);
  54. } else if (clk.event()) {
  55. // Read each line containing the time and file name
  56. for(int i = 3; i<7; i++){
  57. if(file_line[i][0] == sc_time_stamp()){
  58. //char *input_directory = concat_file_dir_name(file_line[i][1], "../input/");
  59. // If the time stamp is equal to the time of the input image, read the input image
  60. // TODO ?? is input_file the name of the file or path to file??
  61. read_image_file((void*) out_data, sizeof(u16), file_line[i][1], input_directory,
  62. sizeof(u16) * num_bayer_pixels);
  63. }
  64. }
  65. }
  66.  
  67. }
  68.  
  69. void debayer_tb::sink(){
  70. //print to the standard out like in the example, examples/lecture03/MAC_basic/tb/mac_tb.cpp
  71. //and tb/sc_main.cpp. It prints when the results are different and how many mismatches it had.
  72.  
  73. //do we compare the golden_output to the result.txt here?
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:24: fatal error: debayer_tb.h: No such file or directory
 #include "debayer_tb.h"
                        ^
compilation terminated.
stdout
Standard output is empty