/** * main.cpp * * for Vivado HLS */ #ifdef SOFTWARE #include "ap_int.h" #else #include #endif #ifdef CALCTIME #include #include #endif #include "router.hpp" #define PRINT_SOLUTION int main(int argc, char *argv[]) { using namespace std; // Test data // // NL_Q00.txt //char boardstr[BOARDSTR_SIZE] = "X10Y05Z3L0000107041L0004107002L0102102021L0900100003"; // NL_Q06.txt char boardstr[BOARDSTR_SIZE] = "X10Y18Z2L0900109002L0901105012L0902103052L0903103062L0904100102L0905106012L0906109022L0717109102L0808109112L0017209172L0401200072L0912208152L0009201092L0709209092L0901206052L0309204092L0701209072L0101201022L0011202152L0016202162"; // NL_Q08.txt //char boardstr[BOARDSTR_SIZE] = "X17Y20Z2L0000103022L1603115052L0916107032L0302108012L1104111042L1002100002L0919116162L1616113182L1001115012L0500201182L1603213152L0600210022"; char boardstr_high[BOARDSTR_SIZE] = {}; // Read boardstr from command line if (1 < argc) { // From stdin if(argv[1][0]!='X') { char* c_p=fgets(boardstr, BOARDSTR_SIZE, stdin); int length=strlen(c_p); boardstr[length-1]=0; } else { strcpy(boardstr, argv[1]); } } // Seed value int seed = 12345; if (2 < argc) { seed = atoi(argv[2]); } #ifdef PRINT_SOLUTION int size_x = (boardstr[1] - '0') * 10 + (boardstr[2] - '0'); int size_y = (boardstr[4] - '0') * 10 + (boardstr[5] - '0'); int size_z = (boardstr[7] - '0'); #endif // Solver ap_int<32> status; clock_t clock_start, clock_done; clock_start = clock(); bool result = pynqrouter(boardstr, boardstr_high, seed, &status); clock_done = clock(); if (result) { cout << endl << "Test Passed!" << endl; } else { cout << endl << "Test Failed!" << endl; } cout << "status = " << (int)status << endl; cout << "elapsed = " << ((double)(clock_done - clock_start) / CLOCKS_PER_SEC) << endl << endl; #ifdef PRINT_SOLUTION cout << "SOLUTION" << endl; cout << "========" << endl; cout << "SIZE " << size_x << "X" << size_y << "X" << size_z << endl; for (int z = 0; z < size_z; z++) { cout << "LAYER " << (z + 1) << endl; for (int y = 0; y < size_y; y++) { for (int x = 0; x < size_x; x++) { if (x != 0) { cout << ","; } int i = ((x * MAX_WIDTH + y) << BITWIDTH_Z) | z; unsigned int num = (unsigned char)(boardstr[i]) + ((unsigned char)(boardstr_high[i]) << 8); cout << setfill('0') << setw(3) << right << num; //cout << num; } cout << endl; } } #endif return 0; }