void cmpy_complex_top (
const std::complex<ap_fixed<10, 1, (ap_q_mode) 5, (ap_o_mode)3, 0> > sig[1024],
const std::complex<ap_fixed<10, 1, (ap_q_mode) 5, (ap_o_mode)3, 0> > sigRef[2048],
const ap_fixed<18, 12, (ap_q_mode) 5, (ap_o_mode)3, 0> prealign[1024],
std::complex<ap_fixed<20, 2, (ap_q_mode) 0, (ap_o_mode)3, 0> > cmp[1024],
const int nL,
const int nLExp,
const int nLen,
const ap_fixed<10, 1, (ap_q_mode) 5, (ap_o_mode)3, 0> factor)
{
	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;


		// output port post check: "cmp"
		aesl_fh.read(AUTOTB_TVOUT_PC_cmp, AESL_token); // [[transaction]]
		if (AESL_token != "[[transaction]]")
		{
			exit(1);
		}
		aesl_fh.read(AUTOTB_TVOUT_PC_cmp, AESL_num); // transaction number

		if (atoi(AESL_num.c_str()) == AESL_transaction_pc)
		{
			aesl_fh.read(AUTOTB_TVOUT_PC_cmp, AESL_token); // data

			sc_bv<40> *cmp_pc_buffer = new sc_bv<40>[1024];
			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 'cmp', 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 'cmp', 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 != "")
				{
					cmp_pc_buffer[i] = AESL_token.c_str();
					i++;
				}

				aesl_fh.read(AUTOTB_TVOUT_PC_cmp, AESL_token); // data or [[/transaction]]

				if (AESL_token == "[[[/runtime]]]" || aesl_fh.eof(AUTOTB_TVOUT_PC_cmp))
				{
					exit(1);
				}
			}

			// ***********************************
			if (i > 0)
			{
				// RTL Name: cmp
				{
					// bitslice(19, 0)
					// {
						// celement: cmp._M_real.V(19, 0)
						// {
							sc_lv<20>* cmp__M_real_V_lv0_0_1023_1 = new sc_lv<20>[1024];
						// }
					// }
					// bitslice(39, 20)
					// {
						// celement: cmp._M_imag.V(19, 0)
						// {
							sc_lv<20>* cmp__M_imag_V_lv0_0_1023_1 = new sc_lv<20>[1024];
						// }
					// }

					// bitslice(19, 0)
					{
						int hls_map_index = 0;
						// celement: cmp._M_real.V(19, 0)
						{
							// carray: (0) => (1023) @ (1)
							for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
							{
								if (&(cmp[0].real()) != NULL) // check the null address if the c port is array or others
								{
									cmp__M_real_V_lv0_0_1023_1[hls_map_index++].range(19, 0) = sc_bv<20>(cmp_pc_buffer[hls_map_index].range(19, 0));
								}
							}
						}
					}
					// bitslice(39, 20)
					{
						int hls_map_index = 0;
						// celement: cmp._M_imag.V(19, 0)
						{
							// carray: (0) => (1023) @ (1)
							for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
							{
								if (&(cmp[0].imag()) != NULL) // check the null address if the c port is array or others
								{
									cmp__M_imag_V_lv0_0_1023_1[hls_map_index++].range(19, 0) = sc_bv<20>(cmp_pc_buffer[hls_map_index].range(39, 20));
								}
							}
						}
					}

					// bitslice(19, 0)
					{
						int hls_map_index = 0;
						// celement: cmp._M_real.V(19, 0)
						{
							// carray: (0) => (1023) @ (1)
							for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
							{
								// sub                    : i_0
								// ori_name               : cmp[i_0].real()
								// sub_1st_elem           : 0
								// ori_name_1st_elem      : cmp[0].real()
								// output_left_conversion : (cmp[i_0].real()).range()
								// output_type_conversion : (cmp__M_real_V_lv0_0_1023_1[hls_map_index++]).to_string(SC_BIN).c_str()
								if (&(cmp[0].real()) != NULL) // check the null address if the c port is array or others
								{
									(cmp[i_0].real()).range() = (cmp__M_real_V_lv0_0_1023_1[hls_map_index++]).to_string(SC_BIN).c_str();
								}
							}
						}
					}
					// bitslice(39, 20)
					{
						int hls_map_index = 0;
						// celement: cmp._M_imag.V(19, 0)
						{
							// carray: (0) => (1023) @ (1)
							for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
							{
								// sub                    : i_0
								// ori_name               : cmp[i_0].imag()
								// sub_1st_elem           : 0
								// ori_name_1st_elem      : cmp[0].imag()
								// output_left_conversion : (cmp[i_0].imag()).range()
								// output_type_conversion : (cmp__M_imag_V_lv0_0_1023_1[hls_map_index++]).to_string(SC_BIN).c_str()
								if (&(cmp[0].imag()) != NULL) // check the null address if the c port is array or others
								{
									(cmp[i_0].imag()).range() = (cmp__M_imag_V_lv0_0_1023_1[hls_map_index++]).to_string(SC_BIN).c_str();
								}
							}
						}
					}
				}
			}

			// release memory allocation
			delete [] cmp_pc_buffer;
		}

		AESL_transaction_pc++;
	}
	else
	{
		static unsigned AESL_transaction;

		static AESL_FILE_HANDLER aesl_fh;

		// "sig"
		char* tvin_sig = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_sig);

		// "sigRef"
		char* tvin_sigRef = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_sigRef);

		// "prealign_V"
		char* tvin_prealign_V = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_prealign_V);

		// "cmp"
		char* tvin_cmp = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_cmp);
		char* tvout_cmp = new char[50];
		aesl_fh.touch(AUTOTB_TVOUT_cmp);

		// "nL"
		char* tvin_nL = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_nL);

		// "factor_V"
		char* tvin_factor_V = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_factor_V);

		static INTER_TCL_FILE tcl_file(INTER_TCL);
		int leading_zero;

		// [[transaction]]
		sprintf(tvin_sig, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_sig, tvin_sig);

		sc_bv<24>* sig_tvin_wrapc_buffer = new sc_bv<24>[1024];

		// RTL Name: sig
		{
			// bitslice(9, 0)
			{
				int hls_map_index = 0;
				// celement: sig._M_real.V(9, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : sig[i_0].real()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : sig[0].real()
						// regulate_c_name       : sig__M_real_V
						// input_type_conversion : (sig[i_0].real()).range().to_string(SC_BIN).c_str()
						if (&(sig[0].real()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<10> sig__M_real_V_tmp_mem;
							sig__M_real_V_tmp_mem = (sig[i_0].real()).range().to_string(SC_BIN).c_str();
							sig_tvin_wrapc_buffer[hls_map_index++].range(9, 0) = sig__M_real_V_tmp_mem.range(9, 0);
						}
					}
				}
			}
			// bitslice(19, 10)
			{
				int hls_map_index = 0;
				// celement: sig._M_imag.V(9, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : sig[i_0].imag()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : sig[0].imag()
						// regulate_c_name       : sig__M_imag_V
						// input_type_conversion : (sig[i_0].imag()).range().to_string(SC_BIN).c_str()
						if (&(sig[0].imag()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<10> sig__M_imag_V_tmp_mem;
							sig__M_imag_V_tmp_mem = (sig[i_0].imag()).range().to_string(SC_BIN).c_str();
							sig_tvin_wrapc_buffer[hls_map_index++].range(19, 10) = sig__M_imag_V_tmp_mem.range(9, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1024; i++)
		{
			sprintf(tvin_sig, "%s\n", (sig_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_sig, tvin_sig);
		}

		tcl_file.set_num(1024, &tcl_file.sig_depth);
		sprintf(tvin_sig, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_sig, tvin_sig);

		// release memory allocation
		delete [] sig_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_sigRef, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_sigRef, tvin_sigRef);

		sc_bv<24>* sigRef_tvin_wrapc_buffer = new sc_bv<24>[2048];

		// RTL Name: sigRef
		{
			// bitslice(9, 0)
			{
				int hls_map_index = 0;
				// celement: sigRef._M_real.V(9, 0)
				{
					// carray: (0) => (2047) @ (1)
					for (int i_0 = 0; i_0 <= 2047; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : sigRef[i_0].real()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : sigRef[0].real()
						// regulate_c_name       : sigRef__M_real_V
						// input_type_conversion : (sigRef[i_0].real()).range().to_string(SC_BIN).c_str()
						if (&(sigRef[0].real()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<10> sigRef__M_real_V_tmp_mem;
							sigRef__M_real_V_tmp_mem = (sigRef[i_0].real()).range().to_string(SC_BIN).c_str();
							sigRef_tvin_wrapc_buffer[hls_map_index++].range(9, 0) = sigRef__M_real_V_tmp_mem.range(9, 0);
						}
					}
				}
			}
			// bitslice(19, 10)
			{
				int hls_map_index = 0;
				// celement: sigRef._M_imag.V(9, 0)
				{
					// carray: (0) => (2047) @ (1)
					for (int i_0 = 0; i_0 <= 2047; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : sigRef[i_0].imag()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : sigRef[0].imag()
						// regulate_c_name       : sigRef__M_imag_V
						// input_type_conversion : (sigRef[i_0].imag()).range().to_string(SC_BIN).c_str()
						if (&(sigRef[0].imag()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<10> sigRef__M_imag_V_tmp_mem;
							sigRef__M_imag_V_tmp_mem = (sigRef[i_0].imag()).range().to_string(SC_BIN).c_str();
							sigRef_tvin_wrapc_buffer[hls_map_index++].range(19, 10) = sigRef__M_imag_V_tmp_mem.range(9, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 2048; i++)
		{
			sprintf(tvin_sigRef, "%s\n", (sigRef_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_sigRef, tvin_sigRef);
		}

		tcl_file.set_num(2048, &tcl_file.sigRef_depth);
		sprintf(tvin_sigRef, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_sigRef, tvin_sigRef);

		// release memory allocation
		delete [] sigRef_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_prealign_V, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_prealign_V, tvin_prealign_V);

		sc_bv<24>* prealign_V_tvin_wrapc_buffer = new sc_bv<24>[1024];

		// RTL Name: prealign_V
		{
			// bitslice(17, 0)
			{
				int hls_map_index = 0;
				// celement: prealign.V(17, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : prealign[i_0]
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : prealign[0]
						// regulate_c_name       : prealign_V
						// input_type_conversion : (prealign[i_0]).range().to_string(SC_BIN).c_str()
						if (&(prealign[0]) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<18> prealign_V_tmp_mem;
							prealign_V_tmp_mem = (prealign[i_0]).range().to_string(SC_BIN).c_str();
							prealign_V_tvin_wrapc_buffer[hls_map_index++].range(17, 0) = prealign_V_tmp_mem.range(17, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1024; i++)
		{
			sprintf(tvin_prealign_V, "%s\n", (prealign_V_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_prealign_V, tvin_prealign_V);
		}

		tcl_file.set_num(1024, &tcl_file.prealign_V_depth);
		sprintf(tvin_prealign_V, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_prealign_V, tvin_prealign_V);

		// release memory allocation
		delete [] prealign_V_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_cmp, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_cmp, tvin_cmp);

		sc_bv<40>* cmp_tvin_wrapc_buffer = new sc_bv<40>[1024];

		// RTL Name: cmp
		{
			// bitslice(19, 0)
			{
				int hls_map_index = 0;
				// celement: cmp._M_real.V(19, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : cmp[i_0].real()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : cmp[0].real()
						// regulate_c_name       : cmp__M_real_V
						// input_type_conversion : (cmp[i_0].real()).range().to_string(SC_BIN).c_str()
						if (&(cmp[0].real()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<20> cmp__M_real_V_tmp_mem;
							cmp__M_real_V_tmp_mem = (cmp[i_0].real()).range().to_string(SC_BIN).c_str();
							cmp_tvin_wrapc_buffer[hls_map_index++].range(19, 0) = cmp__M_real_V_tmp_mem.range(19, 0);
						}
					}
				}
			}
			// bitslice(39, 20)
			{
				int hls_map_index = 0;
				// celement: cmp._M_imag.V(19, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : cmp[i_0].imag()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : cmp[0].imag()
						// regulate_c_name       : cmp__M_imag_V
						// input_type_conversion : (cmp[i_0].imag()).range().to_string(SC_BIN).c_str()
						if (&(cmp[0].imag()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<20> cmp__M_imag_V_tmp_mem;
							cmp__M_imag_V_tmp_mem = (cmp[i_0].imag()).range().to_string(SC_BIN).c_str();
							cmp_tvin_wrapc_buffer[hls_map_index++].range(39, 20) = cmp__M_imag_V_tmp_mem.range(19, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1024; i++)
		{
			sprintf(tvin_cmp, "%s\n", (cmp_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_cmp, tvin_cmp);
		}

		tcl_file.set_num(1024, &tcl_file.cmp_depth);
		sprintf(tvin_cmp, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_cmp, tvin_cmp);

		// release memory allocation
		delete [] cmp_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_nL, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_nL, tvin_nL);

		sc_bv<32> nL_tvin_wrapc_buffer;

		// RTL Name: nL
		{
			// bitslice(31, 0)
			{
				// celement: nL(31, 0)
				{
					// carray: (0) => (0) @ (0)
					{
						// sub                   : 
						// ori_name              : nL
						// sub_1st_elem          : 
						// ori_name_1st_elem     : nL
						// regulate_c_name       : nL
						// input_type_conversion : nL
						if (&(nL) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<32> nL_tmp_mem;
							nL_tmp_mem = nL;
							nL_tvin_wrapc_buffer.range(31, 0) = nL_tmp_mem.range(31, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_nL, "%s\n", (nL_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_nL, tvin_nL);
		}

		tcl_file.set_num(1, &tcl_file.nL_depth);
		sprintf(tvin_nL, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_nL, tvin_nL);

		// [[transaction]]
		sprintf(tvin_factor_V, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_factor_V, tvin_factor_V);

		sc_bv<10> factor_V_tvin_wrapc_buffer;

		// RTL Name: factor_V
		{
			// bitslice(9, 0)
			{
				// celement: factor.V(9, 0)
				{
					// carray: (0) => (0) @ (0)
					{
						// sub                   : 
						// ori_name              : factor
						// sub_1st_elem          : 
						// ori_name_1st_elem     : factor
						// regulate_c_name       : factor_V
						// input_type_conversion : (factor).range().to_string(SC_BIN).c_str()
						if (&(factor) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<10> factor_V_tmp_mem;
							factor_V_tmp_mem = (factor).range().to_string(SC_BIN).c_str();
							factor_V_tvin_wrapc_buffer.range(9, 0) = factor_V_tmp_mem.range(9, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_factor_V, "%s\n", (factor_V_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_factor_V, tvin_factor_V);
		}

		tcl_file.set_num(1, &tcl_file.factor_V_depth);
		sprintf(tvin_factor_V, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_factor_V, tvin_factor_V);

// [call_c_dut] ---------->

		AESL_ORIG_DUT_cmpy_complex_top(sig, sigRef, prealign, cmp, nL, nLExp, nLen, factor);


		// [[transaction]]
		sprintf(tvout_cmp, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVOUT_cmp, tvout_cmp);

		sc_bv<40>* cmp_tvout_wrapc_buffer = new sc_bv<40>[1024];

		// RTL Name: cmp
		{
			// bitslice(19, 0)
			{
				int hls_map_index = 0;
				// celement: cmp._M_real.V(19, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : cmp[i_0].real()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : cmp[0].real()
						// regulate_c_name       : cmp__M_real_V
						// input_type_conversion : (cmp[i_0].real()).range().to_string(SC_BIN).c_str()
						if (&(cmp[0].real()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<20> cmp__M_real_V_tmp_mem;
							cmp__M_real_V_tmp_mem = (cmp[i_0].real()).range().to_string(SC_BIN).c_str();
							cmp_tvout_wrapc_buffer[hls_map_index++].range(19, 0) = cmp__M_real_V_tmp_mem.range(19, 0);
						}
					}
				}
			}
			// bitslice(39, 20)
			{
				int hls_map_index = 0;
				// celement: cmp._M_imag.V(19, 0)
				{
					// carray: (0) => (1023) @ (1)
					for (int i_0 = 0; i_0 <= 1023; i_0 += 1)
					{
						// sub                   : i_0
						// ori_name              : cmp[i_0].imag()
						// sub_1st_elem          : 0
						// ori_name_1st_elem     : cmp[0].imag()
						// regulate_c_name       : cmp__M_imag_V
						// input_type_conversion : (cmp[i_0].imag()).range().to_string(SC_BIN).c_str()
						if (&(cmp[0].imag()) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<20> cmp__M_imag_V_tmp_mem;
							cmp__M_imag_V_tmp_mem = (cmp[i_0].imag()).range().to_string(SC_BIN).c_str();
							cmp_tvout_wrapc_buffer[hls_map_index++].range(39, 20) = cmp__M_imag_V_tmp_mem.range(19, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1024; i++)
		{
			sprintf(tvout_cmp, "%s\n", (cmp_tvout_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVOUT_cmp, tvout_cmp);
		}

		tcl_file.set_num(1024, &tcl_file.cmp_depth);
		sprintf(tvout_cmp, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVOUT_cmp, tvout_cmp);

		// release memory allocation
		delete [] cmp_tvout_wrapc_buffer;

		// release memory allocation: "sig"
		delete [] tvin_sig;
		// release memory allocation: "sigRef"
		delete [] tvin_sigRef;
		// release memory allocation: "prealign_V"
		delete [] tvin_prealign_V;
		// release memory allocation: "cmp"
		delete [] tvout_cmp;
		delete [] tvin_cmp;
		// release memory allocation: "nL"
		delete [] tvin_nL;
		// release memory allocation: "factor_V"
		delete [] tvin_factor_V;

		AESL_transaction++;

		tcl_file.set_num(AESL_transaction , &tcl_file.trans_num);
	}
}
void MAT_Multiply (int* A, int* B, long long* C, int mA, int nA, int mB, int nB, int mC, int nC)
{
	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;


		// output port post check: "C"
		aesl_fh.read(AUTOTB_TVOUT_PC_C, AESL_token); // [[transaction]]
		if (AESL_token != "[[transaction]]")
		{
			exit(1);
		}
		aesl_fh.read(AUTOTB_TVOUT_PC_C, AESL_num); // transaction number

		if (atoi(AESL_num.c_str()) == AESL_transaction_pc)
		{
			aesl_fh.read(AUTOTB_TVOUT_PC_C, AESL_token); // data

			sc_bv<64> *C_pc_buffer = new sc_bv<64>[1];
			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 'C', 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 'C', 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 != "")
				{
					C_pc_buffer[i] = AESL_token.c_str();
					i++;
				}

				aesl_fh.read(AUTOTB_TVOUT_PC_C, AESL_token); // data or [[/transaction]]

				if (AESL_token == "[[[/runtime]]]" || aesl_fh.eof(AUTOTB_TVOUT_PC_C))
				{
					exit(1);
				}
			}

			// ***********************************
			if (i > 0)
			{
				sc_lv<64>* C_lv0_0_0_1 = new sc_lv<64>[1];
				AESL_i = 0;
				for (int i_0 = 0; i_0 <= 0; i_0 += 1)
				{
					if (&(C[0]) != NULL)
					{
						C_lv0_0_0_1[0 + AESL_i].range(63, 0) = sc_bv<64>(C_pc_buffer[0 + AESL_i].range(63, 0));
					}

					AESL_i++;
				}
				AESL_i = 0;

				for (int i_0 = 0; i_0 <= 0; i_0 += 1)
				{

					if (&(C[0]) != NULL)
					{
						C[i_0] = (C_lv0_0_0_1[0 + AESL_i]).to_uint64();
					}

					AESL_i++;
				}
			}

			// release memory allocation
			delete [] C_pc_buffer;
		}

		AESL_transaction_pc++;
	}
	else
	{
		static unsigned AESL_transaction;

		static AESL_FILE_HANDLER aesl_fh;

		// "A"
		char* tvin_A = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_A);

		// "B"
		char* tvin_B = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_B);

		// "C"
		char* tvin_C = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_C);
		char* tvout_C = new char[50];
		aesl_fh.touch(AUTOTB_TVOUT_C);

		// "mA"
		char* tvin_mA = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_mA);

		// "nA"
		char* tvin_nA = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_nA);

		// "mB"
		char* tvin_mB = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_mB);

		// "nB"
		char* tvin_nB = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_nB);

		// "mC"
		char* tvin_mC = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_mC);

		// "nC"
		char* tvin_nC = new char[50];
		aesl_fh.touch(AUTOTB_TVIN_nC);

		static INTER_TCL_FILE tcl_file(INTER_TCL);
		int leading_zero;

		// [[transaction]]
		sprintf(tvin_A, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_A, tvin_A);

		sc_bv<32>* A_tvin_wrapc_buffer = new sc_bv<32>[1];

		// Name: A
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: A(31, 0)
				{
					// carray: (0) => (0) @ (1)
					for (int i_0 = 0; i_0 <= 0; i_0 += 1)
					{
						if (&(A[0]) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<32> A_tmp_mem;
							A_tmp_mem = A[i_0];
							A_tvin_wrapc_buffer[hls_map_index++].range(31, 0) = A_tmp_mem.range(31, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_A, "%s\n", (A_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_A, tvin_A);
		}

		tcl_file.set_num(1, &tcl_file.A_depth);
		sprintf(tvin_A, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_A, tvin_A);

		// release memory allocation
		delete [] A_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_B, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_B, tvin_B);

		sc_bv<32>* B_tvin_wrapc_buffer = new sc_bv<32>[1];

		// Name: B
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: B(31, 0)
				{
					// carray: (0) => (0) @ (1)
					for (int i_0 = 0; i_0 <= 0; i_0 += 1)
					{
						if (&(B[0]) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<32> B_tmp_mem;
							B_tmp_mem = B[i_0];
							B_tvin_wrapc_buffer[hls_map_index++].range(31, 0) = B_tmp_mem.range(31, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_B, "%s\n", (B_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_B, tvin_B);
		}

		tcl_file.set_num(1, &tcl_file.B_depth);
		sprintf(tvin_B, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_B, tvin_B);

		// release memory allocation
		delete [] B_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_C, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_C, tvin_C);

		sc_bv<64>* C_tvin_wrapc_buffer = new sc_bv<64>[1];

		// Name: C
		{
			// bitslice(63, 0)
			{
				int hls_map_index = 0;
				// celement: C(63, 0)
				{
					// carray: (0) => (0) @ (1)
					for (int i_0 = 0; i_0 <= 0; i_0 += 1)
					{
						if (&(C[0]) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<64> C_tmp_mem;
							C_tmp_mem = C[i_0];
							C_tvin_wrapc_buffer[hls_map_index++].range(63, 0) = C_tmp_mem.range(63, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_C, "%s\n", (C_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_C, tvin_C);
		}

		tcl_file.set_num(1, &tcl_file.C_depth);
		sprintf(tvin_C, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_C, tvin_C);

		// release memory allocation
		delete [] C_tvin_wrapc_buffer;

		// [[transaction]]
		sprintf(tvin_mA, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_mA, tvin_mA);

		sc_bv<32> mA_tvin_wrapc_buffer;

		// Name: mA
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: mA(31, 0)
				{
					// carray: (0) => (0) @ (0)
					if (&(mA) != NULL) // check the null address if the c port is array or others
					{
						sc_lv<32> mA_tmp_mem;
						mA_tmp_mem = mA;
						mA_tvin_wrapc_buffer.range(31, 0) = mA_tmp_mem.range(31, 0);
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_mA, "%s\n", (mA_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_mA, tvin_mA);
		}

		tcl_file.set_num(1, &tcl_file.mA_depth);
		sprintf(tvin_mA, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_mA, tvin_mA);

		// [[transaction]]
		sprintf(tvin_nA, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_nA, tvin_nA);

		sc_bv<32> nA_tvin_wrapc_buffer;

		// Name: nA
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: nA(31, 0)
				{
					// carray: (0) => (0) @ (0)
					if (&(nA) != NULL) // check the null address if the c port is array or others
					{
						sc_lv<32> nA_tmp_mem;
						nA_tmp_mem = nA;
						nA_tvin_wrapc_buffer.range(31, 0) = nA_tmp_mem.range(31, 0);
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_nA, "%s\n", (nA_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_nA, tvin_nA);
		}

		tcl_file.set_num(1, &tcl_file.nA_depth);
		sprintf(tvin_nA, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_nA, tvin_nA);

		// [[transaction]]
		sprintf(tvin_mB, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_mB, tvin_mB);

		sc_bv<32> mB_tvin_wrapc_buffer;

		// Name: mB
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: mB(31, 0)
				{
					// carray: (0) => (0) @ (0)
					if (&(mB) != NULL) // check the null address if the c port is array or others
					{
						sc_lv<32> mB_tmp_mem;
						mB_tmp_mem = mB;
						mB_tvin_wrapc_buffer.range(31, 0) = mB_tmp_mem.range(31, 0);
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_mB, "%s\n", (mB_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_mB, tvin_mB);
		}

		tcl_file.set_num(1, &tcl_file.mB_depth);
		sprintf(tvin_mB, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_mB, tvin_mB);

		// [[transaction]]
		sprintf(tvin_nB, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_nB, tvin_nB);

		sc_bv<32> nB_tvin_wrapc_buffer;

		// Name: nB
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: nB(31, 0)
				{
					// carray: (0) => (0) @ (0)
					if (&(nB) != NULL) // check the null address if the c port is array or others
					{
						sc_lv<32> nB_tmp_mem;
						nB_tmp_mem = nB;
						nB_tvin_wrapc_buffer.range(31, 0) = nB_tmp_mem.range(31, 0);
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_nB, "%s\n", (nB_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_nB, tvin_nB);
		}

		tcl_file.set_num(1, &tcl_file.nB_depth);
		sprintf(tvin_nB, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_nB, tvin_nB);

		// [[transaction]]
		sprintf(tvin_mC, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_mC, tvin_mC);

		sc_bv<32> mC_tvin_wrapc_buffer;

		// Name: mC
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: mC(31, 0)
				{
					// carray: (0) => (0) @ (0)
					if (&(mC) != NULL) // check the null address if the c port is array or others
					{
						sc_lv<32> mC_tmp_mem;
						mC_tmp_mem = mC;
						mC_tvin_wrapc_buffer.range(31, 0) = mC_tmp_mem.range(31, 0);
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_mC, "%s\n", (mC_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_mC, tvin_mC);
		}

		tcl_file.set_num(1, &tcl_file.mC_depth);
		sprintf(tvin_mC, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_mC, tvin_mC);

		// [[transaction]]
		sprintf(tvin_nC, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVIN_nC, tvin_nC);

		sc_bv<32> nC_tvin_wrapc_buffer;

		// Name: nC
		{
			// bitslice(31, 0)
			{
				int hls_map_index = 0;
				// celement: nC(31, 0)
				{
					// carray: (0) => (0) @ (0)
					if (&(nC) != NULL) // check the null address if the c port is array or others
					{
						sc_lv<32> nC_tmp_mem;
						nC_tmp_mem = nC;
						nC_tvin_wrapc_buffer.range(31, 0) = nC_tmp_mem.range(31, 0);
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvin_nC, "%s\n", (nC_tvin_wrapc_buffer).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVIN_nC, tvin_nC);
		}

		tcl_file.set_num(1, &tcl_file.nC_depth);
		sprintf(tvin_nC, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVIN_nC, tvin_nC);

// [call_c_dut] ---------->

		AESL_ORIG_DUT_MAT_Multiply(A, B, C, mA, nA, mB, nB, mC, nC);


		// [[transaction]]
		sprintf(tvout_C, "[[transaction]] %d\n", AESL_transaction);
		aesl_fh.write(AUTOTB_TVOUT_C, tvout_C);

		sc_bv<64>* C_tvout_wrapc_buffer = new sc_bv<64>[1];

		// Name: C
		{
			// bitslice(63, 0)
			{
				int hls_map_index = 0;
				// celement: C(63, 0)
				{
					// carray: (0) => (0) @ (1)
					for (int i_0 = 0; i_0 <= 0; i_0 += 1)
					{
						if (&(C[0]) != NULL) // check the null address if the c port is array or others
						{
							sc_lv<64> C_tmp_mem;
							C_tmp_mem = C[i_0];
							C_tvout_wrapc_buffer[hls_map_index++].range(63, 0) = C_tmp_mem.range(63, 0);
						}
					}
				}
			}
		}

		// dump tv to file
		for (int i = 0; i < 1; i++)
		{
			sprintf(tvout_C, "%s\n", (C_tvout_wrapc_buffer[i]).to_string(SC_HEX).c_str());
			aesl_fh.write(AUTOTB_TVOUT_C, tvout_C);
		}

		tcl_file.set_num(1, &tcl_file.C_depth);
		sprintf(tvout_C, "[[/transaction]] \n");
		aesl_fh.write(AUTOTB_TVOUT_C, tvout_C);

		// release memory allocation
		delete [] C_tvout_wrapc_buffer;

		// release memory allocation: "A"
		delete [] tvin_A;
		// release memory allocation: "B"
		delete [] tvin_B;
		// release memory allocation: "C"
		delete [] tvout_C;
		delete [] tvin_C;
		// release memory allocation: "mA"
		delete [] tvin_mA;
		// release memory allocation: "nA"
		delete [] tvin_nA;
		// release memory allocation: "mB"
		delete [] tvin_mB;
		// release memory allocation: "nB"
		delete [] tvin_nB;
		// release memory allocation: "mC"
		delete [] tvin_mC;
		// release memory allocation: "nC"
		delete [] tvin_nC;

		AESL_transaction++;

		tcl_file.set_num(AESL_transaction , &tcl_file.trans_num);
	}
}
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);
    }
}
void hls_cropping_strm ( hls::stream< ap_int<8> > & src,  hls::stream< ap_int<16> > & dst) {

    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;

        aesl_fh.read(WRAPC_STREAM_SIZE_IN_src_V_V, AESL_token); //[[transaction]]

        aesl_fh.read(WRAPC_STREAM_SIZE_IN_src_V_V, AESL_num); //transaction number

        if (atoi(AESL_num.c_str()) == AESL_transaction_pc ) {

            aesl_fh.read(WRAPC_STREAM_SIZE_IN_src_V_V, AESL_token); //pop_size

            int aesl_tmp_1 = atoi(AESL_token.c_str());

            for (int i = 0 ; i < aesl_tmp_1  ; i++) {

                src.read();

            }

            aesl_fh.read(WRAPC_STREAM_SIZE_IN_src_V_V, AESL_token); //[[/transaction]]

        }

        int aesl_tmp_4;

        int aesl_tmp_5 = 0;

        aesl_fh.read(WRAPC_STREAM_SIZE_OUT_dst_V_V, AESL_token); //[[transaction]]

        aesl_fh.read(WRAPC_STREAM_SIZE_OUT_dst_V_V, AESL_num); //transaction number

        if (atoi(AESL_num.c_str()) == AESL_transaction_pc ) {

            aesl_fh.read(WRAPC_STREAM_SIZE_OUT_dst_V_V, AESL_token); //pop_size

            aesl_tmp_4 = atoi(AESL_token.c_str());

            aesl_fh.read(WRAPC_STREAM_SIZE_OUT_dst_V_V, AESL_token); //[[/transaction]]

        }

        std::vector<ap_int<16> > aesl_tmp_3;

        aesl_fh.read(AUTOTB_TVOUT_PC_dst_V_V, AESL_token); //[[transaction]]

        if ( AESL_token != "[[transaction]]") {

           exit(1);

        }

        aesl_fh.read(AUTOTB_TVOUT_PC_dst_V_V, AESL_num); //transaction number

        if (atoi(AESL_num.c_str()) == AESL_transaction_pc ) {

            aesl_fh.read(AUTOTB_TVOUT_PC_dst_V_V, AESL_token); //data

            std::vector < sc_bv<16> > dst_V_V_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 'dst_V_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;

                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 'dst_V_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;

                }

                }

                if (AESL_token != "") {

                    dst_V_V_pc_buffer.push_back( AESL_token.c_str() );

                    i++;

                }

                aesl_fh.read(AUTOTB_TVOUT_PC_dst_V_V, AESL_token); //data or [[/transaction]]

                if (AESL_token == "[[[/runtime]]]" || aesl_fh.eof(AUTOTB_TVOUT_PC_dst_V_V)) {

                   exit(1);

                }

            }

            if (i != aesl_tmp_4) {

               aesl_tmp_4 = i;

            }

            if (aesl_tmp_4 > 0 && aesl_tmp_3.size() < aesl_tmp_4) {

                int aesl_tmp_3_size = aesl_tmp_3.size();

                for (int tmp_aesl_tmp_3 = 0 ; tmp_aesl_tmp_3 < aesl_tmp_4 - aesl_tmp_3_size ; tmp_aesl_tmp_3 ++ ) {

                    ap_int<16> tmp;

                    aesl_tmp_3.push_back(tmp);

                }

            }

            if (i > 0) {

                sc_lv<16> *dst_V_V_lv0_0_0_1 = new sc_lv<16>[aesl_tmp_4 - aesl_tmp_5];

                AESL_i = 0; //subscript for rtl array

                for (int i_0 = 0; i_0 <= aesl_tmp_4 - aesl_tmp_5 - 1 ; i_0+= 1) {

                    if(&(aesl_tmp_3[0]) != 0) {

                       dst_V_V_lv0_0_0_1[0 + AESL_i].range(15, 0) = sc_bv<16>(dst_V_V_pc_buffer[0 + AESL_i].range(15, 0));

                    }

                    AESL_i++;

                }

                AESL_i = 0; //subscript for rtl array

                for (int i_0 = 0; i_0 <= aesl_tmp_4 - aesl_tmp_5 - 1 ; i_0+= 1) {

                    if(&(aesl_tmp_3[0]) != 0) {

                       aesl_tmp_3[i_0] = (dst_V_V_lv0_0_0_1[0 + AESL_i]).to_string(SC_BIN).c_str();

                    }

                    AESL_i++;

                }

                }

        }

        for (int i = 0; i < aesl_tmp_4; i++) {

            dst.write(aesl_tmp_3[i]);

        }

        AESL_transaction_pc ++ ;

    } else {

        static unsigned AESL_transaction;

        static AESL_FILE_HANDLER aesl_fh;

        char* tvin_src_V_V = new char[50];

        char* wrapc_stream_size_in_src_V_V = new char[50];

        char* tvout_dst_V_V = new char[50];

        char* tvin_dst_V_V = new char[50];

        aesl_fh.touch(AUTOTB_TVIN_dst_V_V);

        char* wrapc_stream_size_out_dst_V_V = new char[50];

        static INTER_TCL_FILE tcl_file(INTER_TCL);


        int leading_zero;

        std::vector<ap_int<8> > aesl_tmp_0;

        int aesl_tmp_1 = 0;

        while (!src.empty()) {

            aesl_tmp_0.push_back(src.read());

            aesl_tmp_1 ++;

        }

        std::vector<ap_int<16> > aesl_tmp_3;

        int aesl_tmp_4 = 0;

        while (!dst.empty()) {

            aesl_tmp_3.push_back(dst.read());

            aesl_tmp_4 ++;

        }

        for (int i = 0; i < aesl_tmp_1; i++) {

            src.write(aesl_tmp_0[i]);

        }

        AESL_ORIG_DUT_hls_cropping_strm(src,dst);

        int aesl_tmp_2 = src.size();

        int aesl_tmp_5 = aesl_tmp_4;

        while (!dst.empty()) {

            aesl_tmp_3.push_back(dst.read());

            aesl_tmp_4 ++;

        }

        sprintf(tvin_src_V_V, "[[transaction]] %d\n", AESL_transaction);

        aesl_fh.write(AUTOTB_TVIN_src_V_V, tvin_src_V_V);

        sc_bv<8> *src_V_V_tvin_wrapc_buffer = new sc_bv<8>[aesl_tmp_1 - aesl_tmp_2];

        AESL_i = 0; //subscript for rtl array

        for (int i_0 = 0; i_0 <= aesl_tmp_1 - aesl_tmp_2 - 1 ; i_0+= 1) {

        sc_lv<8> src_V_V_tmp_mem; 

            if(&(aesl_tmp_0[0]) != 0) {

            src_V_V_tmp_mem = (aesl_tmp_0[i_0]).to_string(2).c_str();

               src_V_V_tvin_wrapc_buffer[0 + AESL_i].range(7, 0) = src_V_V_tmp_mem.range(7, 0 ) ;

            }

            AESL_i++;

        }

        for (int i = 0; i < aesl_tmp_1 - aesl_tmp_2 ; i++) {

            sprintf(tvin_src_V_V, "%s\n", (src_V_V_tvin_wrapc_buffer[i]).to_string(SC_HEX).c_str());

            aesl_fh.write(AUTOTB_TVIN_src_V_V, tvin_src_V_V);

        }

        tcl_file.set_num(aesl_tmp_1 - aesl_tmp_2,&tcl_file.src_V_V_depth);

        sprintf(tvin_src_V_V, "[[/transaction]] \n");

        aesl_fh.write(AUTOTB_TVIN_src_V_V, tvin_src_V_V);

        delete [] src_V_V_tvin_wrapc_buffer;

        sprintf(wrapc_stream_size_in_src_V_V, "[[transaction]] %d\n", AESL_transaction);

        aesl_fh.write(WRAPC_STREAM_SIZE_IN_src_V_V, wrapc_stream_size_in_src_V_V);

        sprintf(wrapc_stream_size_in_src_V_V, "%d\n", aesl_tmp_1 - aesl_tmp_2);

        aesl_fh.write(WRAPC_STREAM_SIZE_IN_src_V_V, wrapc_stream_size_in_src_V_V);

        sprintf(wrapc_stream_size_in_src_V_V, "[[/transaction]] \n");

        aesl_fh.write(WRAPC_STREAM_SIZE_IN_src_V_V, wrapc_stream_size_in_src_V_V);

        sprintf(tvout_dst_V_V, "[[transaction]] %d\n", AESL_transaction);

        aesl_fh.write(AUTOTB_TVOUT_dst_V_V, tvout_dst_V_V);

        sc_bv<16> *dst_V_V_tvout_wrapc_buffer = new sc_bv<16>[aesl_tmp_4 - aesl_tmp_5];

        AESL_i = 0; //subscript for rtl array

        for (int i_0 = 0; i_0 <= aesl_tmp_4 - aesl_tmp_5 - 1 ; i_0+= 1) {

        sc_lv<16> dst_V_V_tmp_mem; 

            if(&(aesl_tmp_3[0]) != 0) {

            dst_V_V_tmp_mem = (aesl_tmp_3[i_0]).to_string(2).c_str();

               dst_V_V_tvout_wrapc_buffer[0 + AESL_i].range(15, 0) = dst_V_V_tmp_mem.range(15, 0 ) ;

            }

            AESL_i++;

        }

        for (int i = 0; i < aesl_tmp_4 - aesl_tmp_5 ; i++) {

            sprintf(tvout_dst_V_V, "%s\n", (dst_V_V_tvout_wrapc_buffer[i]).to_string(SC_HEX).c_str());

            aesl_fh.write(AUTOTB_TVOUT_dst_V_V, tvout_dst_V_V);

        }

        tcl_file.set_num(aesl_tmp_4 - aesl_tmp_5,&tcl_file.dst_V_V_depth);

        sprintf(tvout_dst_V_V, "[[/transaction]] \n");

        aesl_fh.write(AUTOTB_TVOUT_dst_V_V, tvout_dst_V_V);

        delete [] dst_V_V_tvout_wrapc_buffer;

        sprintf(wrapc_stream_size_out_dst_V_V, "[[transaction]] %d\n", AESL_transaction);

        aesl_fh.write(WRAPC_STREAM_SIZE_OUT_dst_V_V, wrapc_stream_size_out_dst_V_V);

        sprintf(wrapc_stream_size_out_dst_V_V, "%d\n", aesl_tmp_4 - aesl_tmp_5);

        aesl_fh.write(WRAPC_STREAM_SIZE_OUT_dst_V_V, wrapc_stream_size_out_dst_V_V);

        sprintf(wrapc_stream_size_out_dst_V_V, "[[/transaction]] \n");

        aesl_fh.write(WRAPC_STREAM_SIZE_OUT_dst_V_V, wrapc_stream_size_out_dst_V_V);

        for (int i = 0; i < aesl_tmp_4; i++) {

            dst.write(aesl_tmp_3[i]);

        }

        delete [] tvin_src_V_V;

        delete [] wrapc_stream_size_in_src_V_V;

        delete [] tvout_dst_V_V;

        delete [] tvin_dst_V_V;

        delete [] wrapc_stream_size_out_dst_V_V;

        AESL_transaction++;

        tcl_file.set_num(AESL_transaction , &tcl_file.trans_num);

    }
}
 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;
	}
}