uint64 needlemanWunsch ( uint2 read[100], uint2 ref_genome[1000000]) { fstream wrapc_switch_file_token; wrapc_switch_file_token.open(".hls_cosim_wrapc_switch.log"); int AESL_i; if (wrapc_switch_file_token.good()) { static unsigned AESL_transaction_pc = 0; string AESL_token; string AESL_num; static AESL_FILE_HANDLER aesl_fh; uint64 AESL_return; // output port post check: "ap_return" aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_token); // [[transaction]] if (AESL_token != "[[transaction]]") { exit(1); } aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_num); // transaction number if (atoi(AESL_num.c_str()) == AESL_transaction_pc) { aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_token); // data sc_bv<64> ap_return_pc_buffer; int i = 0; while (AESL_token != "[[/transaction]]") { bool no_x = false; bool err = false; // search and replace 'X' with "0" from the 1st char of token while (!no_x) { size_t x_found = AESL_token.find('X'); if (x_found != string::npos) { if (!err) { cerr << "@W [SIM-201] RTL produces unknown value 'X' on port 'ap_return', possible cause: There are uninitialized variables in the C design." << endl; err = true; } AESL_token.replace(x_found, 1, "0"); } else { no_x = true; } } no_x = false; // search and replace 'x' with "0" from the 3rd char of token while (!no_x) { size_t x_found = AESL_token.find('x', 2); if (x_found != string::npos) { if (!err) { cerr << "@W [SIM-201] RTL produces unknown value 'X' on port 'ap_return', possible cause: There are uninitialized variables in the C design." << endl; err = true; } AESL_token.replace(x_found, 1, "0"); } else { no_x = true; } } // push token into output port buffer if (AESL_token != "") { ap_return_pc_buffer = AESL_token.c_str(); i++; } aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_token); // data or [[/transaction]] if (AESL_token == "[[[/runtime]]]" || aesl_fh.eof(AUTOTB_TVOUT_PC_ap_return)) { exit(1); } } // *********************************** if (i > 0) { // RTL Name: ap_return { // bitslice(63, 0) // { // celement: return(63, 0) // { sc_lv<64> return_lv0_0_1_0; // } // } // bitslice(63, 0) { // celement: return(63, 0) { // carray: (0) => (1) @ (0) { if (&(AESL_return) != NULL) // check the null address if the c port is array or others { return_lv0_0_1_0.range(63, 0) = sc_bv<64>(ap_return_pc_buffer.range(63, 0)); } } } } // bitslice(63, 0) { // celement: return(63, 0) { // carray: (0) => (1) @ (0) { if (&(AESL_return) != NULL) // check the null address if the c port is array or others { AESL_return = (return_lv0_0_1_0).to_uint64(); } } } } } } } AESL_transaction_pc++; return AESL_return; } else { static unsigned AESL_transaction; static AESL_FILE_HANDLER aesl_fh; // "read_r" char* tvin_read_r = new char[50]; aesl_fh.touch(AUTOTB_TVIN_read_r); // "ref_genome" char* tvin_ref_genome = new char[50]; aesl_fh.touch(AUTOTB_TVIN_ref_genome); // "ap_return" char* tvout_ap_return = new char[50]; aesl_fh.touch(AUTOTB_TVOUT_ap_return); static INTER_TCL_FILE tcl_file(INTER_TCL); int leading_zero; // [[transaction]] sprintf(tvin_read_r, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVIN_read_r, tvin_read_r); sc_bv<16>* read_r_tvin_wrapc_buffer = new sc_bv<16>[13]; // RTL Name: read_r { // bitslice(1, 0) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (0) => (96) @ (8) for (int i_0 = 0; i_0 <= 96; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(1, 0) = read_tmp_mem.range(1, 0); } } } } // bitslice(3, 2) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (1) => (97) @ (8) for (int i_0 = 1; i_0 <= 97; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(3, 2) = read_tmp_mem.range(1, 0); } } } } // bitslice(5, 4) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (2) => (98) @ (8) for (int i_0 = 2; i_0 <= 98; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(5, 4) = read_tmp_mem.range(1, 0); } } } } // bitslice(7, 6) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (3) => (99) @ (8) for (int i_0 = 3; i_0 <= 99; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(7, 6) = read_tmp_mem.range(1, 0); } } } } // bitslice(9, 8) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (4) => (99) @ (8) for (int i_0 = 4; i_0 <= 99; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(9, 8) = read_tmp_mem.range(1, 0); } } } // dummy celement: (1, 0) { hls_map_index += 1; } } // bitslice(11, 10) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (5) => (99) @ (8) for (int i_0 = 5; i_0 <= 99; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(11, 10) = read_tmp_mem.range(1, 0); } } } // dummy celement: (1, 0) { hls_map_index += 1; } } // bitslice(13, 12) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (6) => (99) @ (8) for (int i_0 = 6; i_0 <= 99; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(13, 12) = read_tmp_mem.range(1, 0); } } } // dummy celement: (1, 0) { hls_map_index += 1; } } // bitslice(15, 14) { int hls_map_index = 0; // celement: read(1, 0) { // carray: (7) => (99) @ (8) for (int i_0 = 7; i_0 <= 99; i_0 += 8) { if (&(read[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> read_tmp_mem; read_tmp_mem = read[i_0]; read_r_tvin_wrapc_buffer[hls_map_index++].range(15, 14) = read_tmp_mem.range(1, 0); } } } // dummy celement: (1, 0) { hls_map_index += 1; } } } // dump tv to file for (int i = 0; i < 13; i++) { sprintf(tvin_read_r, "%s\n", (read_r_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVIN_read_r, tvin_read_r); } tcl_file.set_num(13, &tcl_file.read_r_depth); sprintf(tvin_read_r, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVIN_read_r, tvin_read_r); // release memory allocation delete [] read_r_tvin_wrapc_buffer; // [[transaction]] sprintf(tvin_ref_genome, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVIN_ref_genome, tvin_ref_genome); sc_bv<8>* ref_genome_tvin_wrapc_buffer = new sc_bv<8>[1000000]; // RTL Name: ref_genome { // bitslice(1, 0) { int hls_map_index = 0; // celement: ref_genome(1, 0) { // carray: (0) => (999999) @ (1) for (int i_0 = 0; i_0 <= 999999; i_0 += 1) { if (&(ref_genome[0]) != NULL) // check the null address if the c port is array or others { sc_lv<2> ref_genome_tmp_mem; ref_genome_tmp_mem = ref_genome[i_0]; ref_genome_tvin_wrapc_buffer[hls_map_index++].range(1, 0) = ref_genome_tmp_mem.range(1, 0); } } } } } // dump tv to file for (int i = 0; i < 1000000; i++) { sprintf(tvin_ref_genome, "%s\n", (ref_genome_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVIN_ref_genome, tvin_ref_genome); } tcl_file.set_num(1000000, &tcl_file.ref_genome_depth); sprintf(tvin_ref_genome, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVIN_ref_genome, tvin_ref_genome); // release memory allocation delete [] ref_genome_tvin_wrapc_buffer; // [call_c_dut] ----------> uint64 AESL_return = AESL_ORIG_DUT_needlemanWunsch(read, ref_genome); // [[transaction]] sprintf(tvout_ap_return, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVOUT_ap_return, tvout_ap_return); sc_bv<64> ap_return_tvout_wrapc_buffer; // RTL Name: ap_return { // bitslice(63, 0) { // celement: return(63, 0) { // carray: (0) => (1) @ (0) { if (&(AESL_return) != NULL) // check the null address if the c port is array or others { sc_lv<64> return_tmp_mem; return_tmp_mem = AESL_return; ap_return_tvout_wrapc_buffer.range(63, 0) = return_tmp_mem.range(63, 0); } } } } } // dump tv to file for (int i = 0; i < 1; i++) { sprintf(tvout_ap_return, "%s\n", (ap_return_tvout_wrapc_buffer).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVOUT_ap_return, tvout_ap_return); } tcl_file.set_num(1, &tcl_file.ap_return_depth); sprintf(tvout_ap_return, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVOUT_ap_return, tvout_ap_return); // release memory allocation: "read_r" delete [] tvin_read_r; // release memory allocation: "ref_genome" delete [] tvin_ref_genome; // release memory allocation: "ap_return" delete [] tvout_ap_return; AESL_transaction++; tcl_file.set_num(AESL_transaction , &tcl_file.trans_num); return AESL_return; } }
void pyrconstuct_top ( std::complex<ap_fixed<16, 1, (ap_q_mode) 5, (ap_o_mode)3, 0> > imgIn[512], hls::stream<std::complex<ap_fixed<17, 6, (ap_q_mode) 0, (ap_o_mode)3, 0> > >& pyrFilOut, const int nL) { fstream wrapc_switch_file_token; wrapc_switch_file_token.open(".hls_cosim_wrapc_switch.log"); int AESL_i; if (wrapc_switch_file_token.good()) { static unsigned AESL_transaction_pc = 0; string AESL_token; string AESL_num; static AESL_FILE_HANDLER aesl_fh; // define output stream variables: "pyrFilOut" std::vector<std::complex<ap_fixed<17, 6, (ap_q_mode) 0, (ap_o_mode)3, 0> > > aesl_tmp_0; int aesl_tmp_1; int aesl_tmp_2 = 0; // read output stream size: "pyrFilOut" aesl_fh.read(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, AESL_token); // [[transaction]] aesl_fh.read(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, AESL_num); // transaction number if (atoi(AESL_num.c_str()) == AESL_transaction_pc) { aesl_fh.read(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, AESL_token); // pop_size aesl_tmp_1 = atoi(AESL_token.c_str()); aesl_fh.read(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, AESL_token); // [[/transaction]] } // output port post check: "pyrFilOut_V" aesl_fh.read(AUTOTB_TVOUT_PC_pyrFilOut_V, AESL_token); // [[transaction]] if (AESL_token != "[[transaction]]") { exit(1); } aesl_fh.read(AUTOTB_TVOUT_PC_pyrFilOut_V, AESL_num); // transaction number if (atoi(AESL_num.c_str()) == AESL_transaction_pc) { aesl_fh.read(AUTOTB_TVOUT_PC_pyrFilOut_V, AESL_token); // data std::vector<sc_bv<34> > pyrFilOut_V_pc_buffer; int i = 0; while (AESL_token != "[[/transaction]]") { bool no_x = false; bool err = false; // search and replace 'X' with "0" from the 1st char of token while (!no_x) { size_t x_found = AESL_token.find('X'); if (x_found != string::npos) { if (!err) { cerr << "@W [SIM-201] RTL produces unknown value 'X' on port 'pyrFilOut_V', possible cause: There are uninitialized variables in the C design." << endl; err = true; } AESL_token.replace(x_found, 1, "0"); } else { no_x = true; } } no_x = false; // search and replace 'x' with "0" from the 3rd char of token while (!no_x) { size_t x_found = AESL_token.find('x', 2); if (x_found != string::npos) { if (!err) { cerr << "@W [SIM-201] RTL produces unknown value 'X' on port 'pyrFilOut_V', possible cause: There are uninitialized variables in the C design." << endl; err = true; } AESL_token.replace(x_found, 1, "0"); } else { no_x = true; } } // push token into output port buffer if (AESL_token != "") { pyrFilOut_V_pc_buffer.push_back(AESL_token.c_str()); i++; } aesl_fh.read(AUTOTB_TVOUT_PC_pyrFilOut_V, AESL_token); // data or [[/transaction]] if (AESL_token == "[[[/runtime]]]" || aesl_fh.eof(AUTOTB_TVOUT_PC_pyrFilOut_V)) { exit(1); } } // correct the buffer size the current transaction if (i != aesl_tmp_1) { aesl_tmp_1 = i; } if (aesl_tmp_1 > 0 && aesl_tmp_0.size() < aesl_tmp_1) { int aesl_tmp_0_size = aesl_tmp_0.size(); for (int tmp_aesl_tmp_0 = 0; tmp_aesl_tmp_0 < aesl_tmp_1 - aesl_tmp_0_size; tmp_aesl_tmp_0++) { std::complex<ap_fixed<17, 6, (ap_q_mode) 0, (ap_o_mode)3, 0> > tmp; aesl_tmp_0.push_back(tmp); } } // *********************************** if (i > 0) { // RTL Name: pyrFilOut_V { // bitslice(16, 0) // { // celement: pyrFilOut.V._M_real.V(16, 0) // { sc_lv<17>* pyrFilOut_V__M_real_V_lv0_0_1519_1 = new sc_lv<17>[1520]; // } // } // bitslice(33, 17) // { // celement: pyrFilOut.V._M_imag.V(16, 0) // { sc_lv<17>* pyrFilOut_V__M_imag_V_lv0_0_1519_1 = new sc_lv<17>[1520]; // } // } // bitslice(16, 0) { int hls_map_index = 0; // celement: pyrFilOut.V._M_real.V(16, 0) { // carray: (aesl_tmp_2) => (aesl_tmp_1 - 1) @ (1) for (int i_0 = aesl_tmp_2; i_0 <= aesl_tmp_1 - 1; i_0 += 1) { if (&(aesl_tmp_0[0].real()) != NULL) // check the null address if the c port is array or others { pyrFilOut_V__M_real_V_lv0_0_1519_1[hls_map_index++].range(16, 0) = sc_bv<17>(pyrFilOut_V_pc_buffer[hls_map_index].range(16, 0)); } } } } // bitslice(33, 17) { int hls_map_index = 0; // celement: pyrFilOut.V._M_imag.V(16, 0) { // carray: (aesl_tmp_2) => (aesl_tmp_1 - 1) @ (1) for (int i_0 = aesl_tmp_2; i_0 <= aesl_tmp_1 - 1; i_0 += 1) { if (&(aesl_tmp_0[0].imag()) != NULL) // check the null address if the c port is array or others { pyrFilOut_V__M_imag_V_lv0_0_1519_1[hls_map_index++].range(16, 0) = sc_bv<17>(pyrFilOut_V_pc_buffer[hls_map_index].range(33, 17)); } } } } // bitslice(16, 0) { int hls_map_index = 0; // celement: pyrFilOut.V._M_real.V(16, 0) { // carray: (aesl_tmp_2) => (aesl_tmp_1 - 1) @ (1) for (int i_0 = aesl_tmp_2; i_0 <= aesl_tmp_1 - 1; i_0 += 1) { // sub : i_0 // ori_name : aesl_tmp_0[i_0].real() // sub_1st_elem : 0 // ori_name_1st_elem : aesl_tmp_0[0].real() // output_left_conversion : (aesl_tmp_0[i_0].real()).range() // output_type_conversion : (pyrFilOut_V__M_real_V_lv0_0_1519_1[hls_map_index++]).to_string(SC_BIN).c_str() if (&(aesl_tmp_0[0].real()) != NULL) // check the null address if the c port is array or others { (aesl_tmp_0[i_0].real()).range() = (pyrFilOut_V__M_real_V_lv0_0_1519_1[hls_map_index++]).to_string(SC_BIN).c_str(); } } } } // bitslice(33, 17) { int hls_map_index = 0; // celement: pyrFilOut.V._M_imag.V(16, 0) { // carray: (aesl_tmp_2) => (aesl_tmp_1 - 1) @ (1) for (int i_0 = aesl_tmp_2; i_0 <= aesl_tmp_1 - 1; i_0 += 1) { // sub : i_0 // ori_name : aesl_tmp_0[i_0].imag() // sub_1st_elem : 0 // ori_name_1st_elem : aesl_tmp_0[0].imag() // output_left_conversion : (aesl_tmp_0[i_0].imag()).range() // output_type_conversion : (pyrFilOut_V__M_imag_V_lv0_0_1519_1[hls_map_index++]).to_string(SC_BIN).c_str() if (&(aesl_tmp_0[0].imag()) != NULL) // check the null address if the c port is array or others { (aesl_tmp_0[i_0].imag()).range() = (pyrFilOut_V__M_imag_V_lv0_0_1519_1[hls_map_index++]).to_string(SC_BIN).c_str(); } } } } } } } // push back output stream: "pyrFilOut" for (int i = 0; i < aesl_tmp_1; i++) { pyrFilOut.write(aesl_tmp_0[i]); } AESL_transaction_pc++; } else { static unsigned AESL_transaction; static AESL_FILE_HANDLER aesl_fh; // "imgIn_M_real_V" char* tvin_imgIn_M_real_V = new char[50]; aesl_fh.touch(AUTOTB_TVIN_imgIn_M_real_V); // "imgIn_M_imag_V" char* tvin_imgIn_M_imag_V = new char[50]; aesl_fh.touch(AUTOTB_TVIN_imgIn_M_imag_V); // "pyrFilOut_V" char* tvin_pyrFilOut_V = new char[50]; aesl_fh.touch(AUTOTB_TVIN_pyrFilOut_V); char* tvout_pyrFilOut_V = new char[50]; aesl_fh.touch(AUTOTB_TVOUT_pyrFilOut_V); char* wrapc_stream_size_out_pyrFilOut_V = new char[50]; aesl_fh.touch(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V); char* wrapc_stream_egress_status_pyrFilOut_V = new char[50]; aesl_fh.touch(WRAPC_STREAM_EGRESS_STATUS_pyrFilOut_V); static INTER_TCL_FILE tcl_file(INTER_TCL); int leading_zero; // dump stream tvin: "pyrFilOut" std::vector<std::complex<ap_fixed<17, 6, (ap_q_mode) 0, (ap_o_mode)3, 0> > > aesl_tmp_0; int aesl_tmp_1 = 0; while (!pyrFilOut.empty()) { aesl_tmp_0.push_back(pyrFilOut.read()); aesl_tmp_1++; } // [[transaction]] sprintf(tvin_imgIn_M_real_V, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVIN_imgIn_M_real_V, tvin_imgIn_M_real_V); sc_bv<16>* imgIn_M_real_V_tvin_wrapc_buffer = new sc_bv<16>[512]; // RTL Name: imgIn_M_real_V { // bitslice(15, 0) { int hls_map_index = 0; // celement: imgIn._M_real.V(15, 0) { // carray: (0) => (511) @ (1) for (int i_0 = 0; i_0 <= 511; i_0 += 1) { // sub : i_0 // ori_name : imgIn[i_0].real() // sub_1st_elem : 0 // ori_name_1st_elem : imgIn[0].real() // regulate_c_name : imgIn__M_real_V // input_type_conversion : (imgIn[i_0].real()).range().to_string(SC_BIN).c_str() if (&(imgIn[0].real()) != NULL) // check the null address if the c port is array or others { sc_lv<16> imgIn__M_real_V_tmp_mem; imgIn__M_real_V_tmp_mem = (imgIn[i_0].real()).range().to_string(SC_BIN).c_str(); imgIn_M_real_V_tvin_wrapc_buffer[hls_map_index++].range(15, 0) = imgIn__M_real_V_tmp_mem.range(15, 0); } } } } } // dump tv to file for (int i = 0; i < 512; i++) { sprintf(tvin_imgIn_M_real_V, "%s\n", (imgIn_M_real_V_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVIN_imgIn_M_real_V, tvin_imgIn_M_real_V); } tcl_file.set_num(512, &tcl_file.imgIn_M_real_V_depth); sprintf(tvin_imgIn_M_real_V, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVIN_imgIn_M_real_V, tvin_imgIn_M_real_V); // release memory allocation delete [] imgIn_M_real_V_tvin_wrapc_buffer; // [[transaction]] sprintf(tvin_imgIn_M_imag_V, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVIN_imgIn_M_imag_V, tvin_imgIn_M_imag_V); sc_bv<16>* imgIn_M_imag_V_tvin_wrapc_buffer = new sc_bv<16>[512]; // RTL Name: imgIn_M_imag_V { // bitslice(15, 0) { int hls_map_index = 0; // celement: imgIn._M_imag.V(15, 0) { // carray: (0) => (511) @ (1) for (int i_0 = 0; i_0 <= 511; i_0 += 1) { // sub : i_0 // ori_name : imgIn[i_0].imag() // sub_1st_elem : 0 // ori_name_1st_elem : imgIn[0].imag() // regulate_c_name : imgIn__M_imag_V // input_type_conversion : (imgIn[i_0].imag()).range().to_string(SC_BIN).c_str() if (&(imgIn[0].imag()) != NULL) // check the null address if the c port is array or others { sc_lv<16> imgIn__M_imag_V_tmp_mem; imgIn__M_imag_V_tmp_mem = (imgIn[i_0].imag()).range().to_string(SC_BIN).c_str(); imgIn_M_imag_V_tvin_wrapc_buffer[hls_map_index++].range(15, 0) = imgIn__M_imag_V_tmp_mem.range(15, 0); } } } } } // dump tv to file for (int i = 0; i < 512; i++) { sprintf(tvin_imgIn_M_imag_V, "%s\n", (imgIn_M_imag_V_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVIN_imgIn_M_imag_V, tvin_imgIn_M_imag_V); } tcl_file.set_num(512, &tcl_file.imgIn_M_imag_V_depth); sprintf(tvin_imgIn_M_imag_V, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVIN_imgIn_M_imag_V, tvin_imgIn_M_imag_V); // release memory allocation delete [] imgIn_M_imag_V_tvin_wrapc_buffer; // push back input stream: "pyrFilOut" for (int i = 0; i < aesl_tmp_1; i++) { pyrFilOut.write(aesl_tmp_0[i]); } // [call_c_dut] ----------> AESL_ORIG_DUT_pyrconstuct_top(imgIn, pyrFilOut, nL); // pop output stream: "pyrFilOut" int aesl_tmp_2 = aesl_tmp_1; aesl_tmp_1 = 0; aesl_tmp_0.clear(); while (!pyrFilOut.empty()) { aesl_tmp_0.push_back(pyrFilOut.read()); aesl_tmp_1++; } // [[transaction]] sprintf(tvout_pyrFilOut_V, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVOUT_pyrFilOut_V, tvout_pyrFilOut_V); sc_bv<34>* pyrFilOut_V_tvout_wrapc_buffer = new sc_bv<34>[1520]; // RTL Name: pyrFilOut_V { // bitslice(16, 0) { int hls_map_index = 0; // celement: pyrFilOut.V._M_real.V(16, 0) { // carray: (aesl_tmp_2) => (aesl_tmp_1 - 1) @ (1) for (int i_0 = aesl_tmp_2; i_0 <= aesl_tmp_1 - 1; i_0 += 1) { // sub : i_0 // ori_name : aesl_tmp_0[i_0].real() // sub_1st_elem : 0 // ori_name_1st_elem : aesl_tmp_0[0].real() // regulate_c_name : pyrFilOut_V__M_real_V // input_type_conversion : (aesl_tmp_0[i_0].real()).range().to_string(SC_BIN).c_str() if (&(aesl_tmp_0[0].real()) != NULL) // check the null address if the c port is array or others { sc_lv<17> pyrFilOut_V__M_real_V_tmp_mem; pyrFilOut_V__M_real_V_tmp_mem = (aesl_tmp_0[i_0].real()).range().to_string(SC_BIN).c_str(); pyrFilOut_V_tvout_wrapc_buffer[hls_map_index++].range(16, 0) = pyrFilOut_V__M_real_V_tmp_mem.range(16, 0); } } } } // bitslice(33, 17) { int hls_map_index = 0; // celement: pyrFilOut.V._M_imag.V(16, 0) { // carray: (aesl_tmp_2) => (aesl_tmp_1 - 1) @ (1) for (int i_0 = aesl_tmp_2; i_0 <= aesl_tmp_1 - 1; i_0 += 1) { // sub : i_0 // ori_name : aesl_tmp_0[i_0].imag() // sub_1st_elem : 0 // ori_name_1st_elem : aesl_tmp_0[0].imag() // regulate_c_name : pyrFilOut_V__M_imag_V // input_type_conversion : (aesl_tmp_0[i_0].imag()).range().to_string(SC_BIN).c_str() if (&(aesl_tmp_0[0].imag()) != NULL) // check the null address if the c port is array or others { sc_lv<17> pyrFilOut_V__M_imag_V_tmp_mem; pyrFilOut_V__M_imag_V_tmp_mem = (aesl_tmp_0[i_0].imag()).range().to_string(SC_BIN).c_str(); pyrFilOut_V_tvout_wrapc_buffer[hls_map_index++].range(33, 17) = pyrFilOut_V__M_imag_V_tmp_mem.range(16, 0); } } } } } // dump tv to file for (int i = 0; i < aesl_tmp_1 - aesl_tmp_2; i++) { sprintf(tvout_pyrFilOut_V, "%s\n", (pyrFilOut_V_tvout_wrapc_buffer[i]).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVOUT_pyrFilOut_V, tvout_pyrFilOut_V); } tcl_file.set_num(aesl_tmp_1 - aesl_tmp_2, &tcl_file.pyrFilOut_V_depth); sprintf(tvout_pyrFilOut_V, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVOUT_pyrFilOut_V, tvout_pyrFilOut_V); // release memory allocation delete [] pyrFilOut_V_tvout_wrapc_buffer; // dump stream size sprintf(wrapc_stream_size_out_pyrFilOut_V, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, wrapc_stream_size_out_pyrFilOut_V); sprintf(wrapc_stream_size_out_pyrFilOut_V, "%d\n", aesl_tmp_1 - aesl_tmp_2); aesl_fh.write(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, wrapc_stream_size_out_pyrFilOut_V); sprintf(wrapc_stream_size_out_pyrFilOut_V, "[[/transaction]] \n"); aesl_fh.write(WRAPC_STREAM_SIZE_OUT_pyrFilOut_V, wrapc_stream_size_out_pyrFilOut_V); // push back output stream: "pyrFilOut" for (int i = 0; i < aesl_tmp_1; i++) { pyrFilOut.write(aesl_tmp_0[i]); } // release memory allocation: "imgIn_M_real_V" delete [] tvin_imgIn_M_real_V; // release memory allocation: "imgIn_M_imag_V" delete [] tvin_imgIn_M_imag_V; // release memory allocation: "pyrFilOut_V" delete [] tvout_pyrFilOut_V; delete [] tvin_pyrFilOut_V; delete [] wrapc_stream_size_out_pyrFilOut_V; AESL_transaction++; tcl_file.set_num(AESL_transaction , &tcl_file.trans_num); } }
ap_fixed<30, 3, (ap_q_mode) 4, (ap_o_mode)0, 0> Compult ( ap_fixed<32, 3, (ap_q_mode) 4, (ap_o_mode)0, 0> y_in, ap_fixed<30, 3, (ap_q_mode) 4, (ap_o_mode)0, 0> ref_in) { fstream wrapc_switch_file_token; wrapc_switch_file_token.open(".hls_cosim_wrapc_switch.log"); int AESL_i; if (wrapc_switch_file_token.good()) { static unsigned AESL_transaction_pc; string AESL_token; string AESL_num; static AESL_FILE_HANDLER aesl_fh; ap_fixed<30, 3, (ap_q_mode) 4, (ap_o_mode)0, 0> AESL_return; aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_token); //[[transaction]] if ( AESL_token != "[[transaction]]") { exit(1); } aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_num); //transaction number if (atoi(AESL_num.c_str()) == AESL_transaction_pc ) { aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_token); //data sc_bv<30> ap_return_pc_buffer; int i = 0; while (AESL_token != "[[/transaction]]") { bool no_x = false; bool err = false; while (!no_x) { size_t x_found = AESL_token.find('X'); if (x_found != string::npos) { if (!err) { cerr << "@W [SIM-201] RTL produces unknown value 'X' on port 'ap_return', possible cause: There are uninitialized variables in the C design." << endl; err = true; } AESL_token.replace(x_found, 1, "0"); } else { no_x = true; } } no_x = false; while (!no_x) { size_t x_found = AESL_token.find('x', 2); if (x_found != string::npos) { if (!err) { cerr << "@W [SIM-201] RTL produces unknown value 'X' on port 'ap_return', possible cause: There are uninitialized variables in the C design." << endl; err = true; } AESL_token.replace(x_found, 1, "0"); } else { no_x = true; } } if (AESL_token != "") { ap_return_pc_buffer = AESL_token.c_str(); i++; } aesl_fh.read(AUTOTB_TVOUT_PC_ap_return, AESL_token); //data or [[/transaction]] if (AESL_token == "[[[/runtime]]]" || aesl_fh.eof(AUTOTB_TVOUT_PC_ap_return)) { exit(1); } } if (i > 0) { sc_lv<30> agg_result_V_lv0_0_0_0; AESL_i = 0; //subscript for rtl array if(&(AESL_return) != 0) { agg_result_V_lv0_0_0_0.range(29, 0) = sc_bv<30>(ap_return_pc_buffer.range(29, 0)); } AESL_i++; AESL_i = 0; //subscript for rtl array if(&(AESL_return) != 0) { (AESL_return).range() = (agg_result_V_lv0_0_0_0).to_string(SC_BIN).c_str(); } AESL_i++; } } AESL_transaction_pc ++ ; return AESL_return; } else { static unsigned AESL_transaction; static AESL_FILE_HANDLER aesl_fh; char* tvin_y_in_V = new char[50]; char* tvin_ref_in_V = new char[50]; char* tvout_ap_return = new char[50]; static INTER_TCL_FILE tcl_file(INTER_TCL); int leading_zero; sprintf(tvin_y_in_V, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVIN_y_in_V, tvin_y_in_V); sc_bv<32> y_in_V_tvin_wrapc_buffer; AESL_i = 0; //subscript for rtl array sc_lv<32> y_in_V_tmp_mem; if(&(y_in) != 0) { y_in_V_tmp_mem = (y_in).range().to_string(SC_BIN).c_str(); y_in_V_tvin_wrapc_buffer.range(31, 0) = y_in_V_tmp_mem.range(31, 0 ) ; } AESL_i++; for (int i = 0; i < 1 ; i++) { sprintf(tvin_y_in_V, "%s\n", (y_in_V_tvin_wrapc_buffer).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVIN_y_in_V, tvin_y_in_V); } tcl_file.set_num(1,&tcl_file.y_in_V_depth); sprintf(tvin_y_in_V, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVIN_y_in_V, tvin_y_in_V); sprintf(tvin_ref_in_V, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVIN_ref_in_V, tvin_ref_in_V); sc_bv<30> ref_in_V_tvin_wrapc_buffer; AESL_i = 0; //subscript for rtl array sc_lv<30> ref_in_V_tmp_mem; if(&(ref_in) != 0) { ref_in_V_tmp_mem = (ref_in).range().to_string(SC_BIN).c_str(); ref_in_V_tvin_wrapc_buffer.range(29, 0) = ref_in_V_tmp_mem.range(29, 0 ) ; } AESL_i++; for (int i = 0; i < 1 ; i++) { sprintf(tvin_ref_in_V, "%s\n", (ref_in_V_tvin_wrapc_buffer).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVIN_ref_in_V, tvin_ref_in_V); } tcl_file.set_num(1,&tcl_file.ref_in_V_depth); sprintf(tvin_ref_in_V, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVIN_ref_in_V, tvin_ref_in_V); ap_fixed<30, 3, (ap_q_mode) 4, (ap_o_mode)0, 0> AESL_return = AESL_ORIG_DUT_Compult(y_in,ref_in); sprintf(tvout_ap_return, "[[transaction]] %d\n", AESL_transaction); aesl_fh.write(AUTOTB_TVOUT_ap_return, tvout_ap_return); sc_bv<30> ap_return_tvout_wrapc_buffer; AESL_i = 0; //subscript for rtl array sc_lv<30> agg_result_V_tmp_mem; if(&(AESL_return) != 0) { agg_result_V_tmp_mem = (AESL_return).range().to_string(SC_BIN).c_str(); ap_return_tvout_wrapc_buffer.range(29, 0) = agg_result_V_tmp_mem.range(29, 0 ) ; } AESL_i++; for (int i = 0; i < 1 ; i++) { sprintf(tvout_ap_return, "%s\n", (ap_return_tvout_wrapc_buffer).to_string(SC_HEX).c_str()); aesl_fh.write(AUTOTB_TVOUT_ap_return, tvout_ap_return); } tcl_file.set_num(1,&tcl_file.ap_return_depth); sprintf(tvout_ap_return, "[[/transaction]] \n"); aesl_fh.write(AUTOTB_TVOUT_ap_return, tvout_ap_return); delete [] tvin_y_in_V; delete [] tvin_ref_in_V; delete [] tvout_ap_return; AESL_transaction++; tcl_file.set_num(AESL_transaction , &tcl_file.trans_num); return AESL_return; } }