diff --git a/hls/lines256_length128/router.cpp b/hls/lines256_length128/router.cpp index 83d45f9440c0eb66effe738a6ccbe658dd384cca..40901076227fafd97bf9836e0ffd883a5b996743 100644 --- a/hls/lines256_length128/router.cpp +++ b/hls/lines256_length128/router.cpp @@ -17,7 +17,7 @@ // LFST // ================================ // -// ŽQ�l https://highlevel-synthesis.com/2017/02/10/lfsr-in-hls/ +// �Q�l https://highlevel-synthesis.com/2017/02/10/lfsr-in-hls/ static ap_uint<32> lfsr; void lfsr_random_init(ap_uint<32> seed) { @@ -38,15 +38,15 @@ ap_uint<32> lfsr_random() { return lfsr.to_uint(); } -// A‚©‚çB‚Ì”ÍˆÍ (A‚ÆB‚ðŠÜ‚Þ) ‚Ì�®�”‚Ì—��”‚ª—~‚µ‚¢‚Æ‚« -// ŽQ�l http://www.sat.t.u-tokyo.ac.jp/~omi/random_variables_generation.html +// A����B�͈̔� (A��B���܂�) �Ì�����̗������~�����Ƃ� +// �Q�l http://www.sat.t.u-tokyo.ac.jp/~omi/random_variables_generation.html /*ap_uint<32> lfsr_random_uint32(ap_uint<32> a, ap_uint<32> b) { #pragma HLS INLINE return lfsr_random() % (b - a + 1) + a; }*/ -// 0‚©‚çB‚Ì”ÍˆÍ (A‚ÆB‚ðŠÜ‚Þ) ‚Ì�®�”‚Ì—��”‚ª—~‚µ‚¢‚Æ‚« -// ŽQ�l http://www.sat.t.u-tokyo.ac.jp/~omi/random_variables_generation.html +// 0����B�͈̔� (A��B���܂�) �Ì�����̗������~�����Ƃ� +// �Q�l http://www.sat.t.u-tokyo.ac.jp/~omi/random_variables_generation.html /*ap_uint<32> lfsr_random_uint32_0(ap_uint<32> b) { #pragma HLS INLINE return lfsr_random() % (b + 1); @@ -54,21 +54,21 @@ ap_uint<32> lfsr_random() { // ================================ // -// ƒ�ƒCƒ“ƒ‚ƒWƒ…�[ƒ‹ +// ���C�����W���[�� // ================================ // -// �d‚Ý‚Ì�X�V -// TODO ’²�® -// min_uint8(r, MAX_WEIGHT) ‚Æ“¯‚¶ +// �d�݂Ì�X�V +// TODO ���� +// min_uint8(r, MAX_WEIGHT) �Ɠ��� ap_uint<8> new_weight(ap_uint<16> x) { #pragma HLS INLINE #if 1 - // ‰ºˆÊ8ƒrƒbƒg (�Å‘å 255) ‚𔲂«�o‚µ‚Ä�A1/8 ‚ð‚©‚¯‚Ä�Å‘å 31 (32) ‚É‚·‚é + // ����8�r�b�g (�ő� 255) �𔲂��o���Ä�A1/8 �������Ä�ő� 31 (32) �ɂ��� ap_uint<8> y = x & 255; return (ap_uint<8>)(y / 8 + 1); #endif #if 0 - // ‰ºˆÊ10ƒrƒbƒg (�Å‘å 1023) ‚𔲂«�o‚µ‚Ä�A1/32 ‚ð‚©‚¯‚Ä�Å‘å 31 (32) ‚É‚·‚é + // ����10�r�b�g (�ő� 1023) �𔲂��o���Ä�A1/32 �������Ä�ő� 31 (32) �ɂ��� ap_uint<10> y = x & 1023; return (ap_uint<8>)(y / 32 + 1); #endif @@ -79,26 +79,26 @@ ap_uint<8> new_weight(ap_uint<16> x) { #endif } -// ƒ{�[ƒh‚ÉŠÖ‚·‚é•Ï�” -static ap_uint<7> size_x; // ƒ{�[ƒh‚Ì X ƒTƒCƒY -static ap_uint<7> size_y; // ƒ{�[ƒh‚Ì Y ƒTƒCƒY -static ap_uint<4> size_z; // ƒ{�[ƒh‚Ì Z ƒTƒCƒY +// �{�[�h�Ɋւ���Ï�� +static ap_uint<7> size_x; // �{�[�h�� X �T�C�Y +static ap_uint<7> size_y; // �{�[�h�� Y �T�C�Y +static ap_uint<4> size_z; // �{�[�h�� Z �T�C�Y -static ap_uint<7> line_num = 0; // ƒ‰ƒCƒ“‚Ì‘��” +static ap_uint<7> line_num = 0; // ���C���̑��� -// ƒOƒ��[ƒoƒ‹•Ï�”‚Å’è‹`‚·‚é +// �O���[�o���Ï���Œ�`���� #ifdef GLOBALVARS - ap_uint<16> starts[MAX_LINES]; // ƒ‰ƒCƒ“‚̃Xƒ^�[ƒgƒŠƒXƒg - ap_uint<16> goals[MAX_LINES]; // ƒ‰ƒCƒ“‚̃S�[ƒ‹ƒŠƒXƒg + ap_uint<16> starts[MAX_LINES]; // ���C���̃X�^�[�g���X�g + ap_uint<16> goals[MAX_LINES]; // ���C���̃S�[�����X�g - ap_uint<8> weights[MAX_CELLS]; // ƒZƒ‹‚Ì�d‚Ý + ap_uint<8> weights[MAX_CELLS]; // �Z���Ì�d�� - ap_uint<8> paths_size[MAX_LINES]; // ƒ‰ƒCƒ“‚ª‘Ήž‚·‚éƒZƒ‹ID‚̃TƒCƒY - ap_uint<16> paths[MAX_LINES][MAX_PATH]; // ƒ‰ƒCƒ“‚ª‘Ήž‚·‚éƒZƒ‹ID‚Ì�W�‡ (ƒXƒ^�[ƒg‚ƃS�[ƒ‹‚Í�œ‚­) - bool adjacents[MAX_LINES]; // ƒXƒ^�[ƒg‚ƃS�[ƒ‹‚ª—×�Ú‚µ‚Ä‚¢‚郉ƒCƒ“ + ap_uint<8> paths_size[MAX_LINES]; // ���C�����Ή�����Z��ID�̃T�C�Y + ap_uint<16> paths[MAX_LINES][MAX_PATH]; // ���C�����Ή�����Z��ID�Ì�W�� (�X�^�[�g�ƃS�[���Í����) + bool adjacents[MAX_LINES]; // �X�^�[�g�ƃS�[�����×�ڂ��Ă��郉�C�� #endif -bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status) { +bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status) { #pragma HLS INTERFACE s_axilite port=boardstr bundle=AXI4LS #pragma HLS INTERFACE s_axilite port=seed bundle=AXI4LS #pragma HLS INTERFACE s_axilite port=status bundle=AXI4LS @@ -106,30 +106,30 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat *status = -1; -// ƒOƒ��[ƒoƒ‹•Ï�”‚ł͒è‹`‚µ‚È‚¢ +// �O���[�o���Ï���ł͒�`���Ȃ� #ifndef GLOBALVARS - ap_uint<16> starts[MAX_LINES]; // ƒ‰ƒCƒ“‚̃Xƒ^�[ƒgƒŠƒXƒg + ap_uint<16> starts[MAX_LINES]; // ���C���̃X�^�[�g���X�g #pragma HLS ARRAY_PARTITION variable=starts complete dim=1 - ap_uint<16> goals[MAX_LINES]; // ƒ‰ƒCƒ“‚̃S�[ƒ‹ƒŠƒXƒg + ap_uint<16> goals[MAX_LINES]; // ���C���̃S�[�����X�g #pragma HLS ARRAY_PARTITION variable=goals complete dim=1 - ap_uint<8> weights[MAX_CELLS]; // ƒZƒ‹‚Ì�d‚Ý + ap_uint<8> weights[MAX_CELLS]; // �Z���Ì�d�� //#pragma HLS ARRAY_PARTITION variable=weights cyclic factor=8 dim=1 partition -// Note: weights ‚Í—l�X‚È�‡”ԂŃAƒNƒZƒX‚³‚ê‚é‚©‚çƒp�[ƒeƒBƒVƒ‡ƒ“‚µ‚Ä‚à‘S‘RŒø‰Ê‚È‚¢ +// Note: weights �͗l�X�È���ԂŃA�N�Z�X����邩��p�[�e�B�V���������S�R���ʂȂ� - ap_uint<8> paths_size[MAX_LINES]; // ƒ‰ƒCƒ“‚ª‘Ήž‚·‚éƒZƒ‹ID‚̃TƒCƒY + ap_uint<8> paths_size[MAX_LINES]; // ���C�����Ή�����Z��ID�̃T�C�Y //#pragma HLS ARRAY_PARTITION variable=paths_size complete dim=1 - ap_uint<16> paths[MAX_LINES][MAX_PATH]; // ƒ‰ƒCƒ“‚ª‘Ήž‚·‚éƒZƒ‹ID‚Ì�W�‡ (ƒXƒ^�[ƒg‚ƃS�[ƒ‹‚Í�œ‚­) + ap_uint<16> paths[MAX_LINES][MAX_PATH]; // ���C�����Ή�����Z��ID�Ì�W�� (�X�^�[�g�ƃS�[���Í����) //#pragma HLS ARRAY_PARTITION variable=paths cyclic factor=16 dim=2 partition - bool adjacents[MAX_LINES]; // ƒXƒ^�[ƒg‚ƃS�[ƒ‹‚ª—×�Ú‚µ‚Ä‚¢‚郉ƒCƒ“ + bool adjacents[MAX_LINES]; // �X�^�[�g�ƃS�[�����×�ڂ��Ă��郉�C�� //#pragma HLS ARRAY_PARTITION variable=adjacents complete dim=1 #endif // ================================ - // �‰Šú‰» BEGIN + // ������ BEGIN // ================================ - // ƒ‹�[ƒvƒJƒEƒ“ƒ^‚Í1ƒrƒbƒg—]•ª‚É—pˆÓ‚µ‚È‚¢‚Æ�I—¹”»’è‚Å‚«‚È‚¢ + // ���[�v�J�E���^��1�r�b�g�]���ɗp�ӂ��Ȃ��Æ�I������ł��Ȃ� INIT_ADJACENTS: for (ap_uint<8> i = 0; i < (ap_uint<8>)(MAX_LINES); i++) { adjacents[i] = false; @@ -142,7 +142,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat weights[i] = 1; } - // ƒ{�[ƒhƒXƒgƒŠƒ“ƒO‚̉ðŽß + // �{�[�h�X�g�����O�̉��� size_x = (boardstr[1] - '0') * 10 + (boardstr[2] - '0'); size_y = (boardstr[4] - '0') * 10 + (boardstr[5] - '0'); @@ -152,7 +152,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat for (ap_uint<16> idx = 8; idx < BOARDSTR_SIZE; idx+=11) { //#pragma HLS LOOP_TRIPCOUNT min=100 max=32768 avg=1000 - // �I’[ (null) •¶Žš + // �I�[ (null) ���� if (boardstr[idx] == 0) { break; } @@ -166,16 +166,16 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat //cout << "L " << line_num << ": (" << s_x << ", " << s_y << ", " << s_z << ") " // "(" << g_x << ", " << g_y << ", " << g_z << ")" << endl; - // ƒXƒ^�[ƒg‚ƃS�[ƒ‹ + // �X�^�[�g�ƃS�[�� ap_uint<16> start_id = (((ap_uint<16>)s_x * MAX_WIDTH + (ap_uint<16>)s_y) << BITWIDTH_Z) | (ap_uint<16>)s_z; ap_uint<16> goal_id = (((ap_uint<16>)g_x * MAX_WIDTH + (ap_uint<16>)g_y) << BITWIDTH_Z) | (ap_uint<16>)g_z; starts[line_num] = start_id; goals[line_num] = goal_id; - // �‰Šú�ó‘Ô‚Å�”Žš‚ª—×�Ú‚µ‚Ä‚¢‚é‚©”»’f - ap_int<8> dx = (ap_int<8>)g_x - (ap_int<8>)s_x; // �Å�¬-71 �Å‘å71 (-> •„�†•t‚«8ƒrƒbƒg) - ap_int<8> dy = (ap_int<8>)g_y - (ap_int<8>)s_y; // �Å�¬-71 �Å‘å71 (-> •„�†•t‚«8ƒrƒbƒg) - ap_int<4> dz = (ap_int<4>)g_z - (ap_int<4>)s_z; // �Å�¬-7 �Å‘å7 (-> •„�†•t‚«4ƒrƒbƒg) + // ������ԂÅ�������×�ڂ��Ă��邩���f + ap_int<8> dx = (ap_int<8>)g_x - (ap_int<8>)s_x; // �Å��-71 �ő�71 (-> �����t��8�r�b�g) + ap_int<8> dy = (ap_int<8>)g_y - (ap_int<8>)s_y; // �Å��-71 �ő�71 (-> �����t��8�r�b�g) + ap_int<4> dz = (ap_int<4>)g_z - (ap_int<4>)s_z; // �Å��-7 �ő�7 (-> �����t��4�r�b�g) if ((dx == 0 && dy == 0 && (dz == 1 || dz == -1)) || (dx == 0 && (dy == 1 || dy == -1) && dz == 0) || ((dx == 1 || dx == -1) && dy == 0 && dz == 0)) { adjacents[line_num] = true; paths_size[line_num] = 0; @@ -191,21 +191,21 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } //cout << size_x << " " << size_y << " " << size_z << endl; - // —��”‚Ì�‰Šú‰» + // �����Ì������ lfsr_random_init(seed); // TODO - // ‚·‚ׂẴ‰ƒCƒ“‚ª—×�Ú‚µ‚Ä‚½‚çƒ\ƒ‹ƒo‚ð�I‚í‚è‚É‚·‚é + // ���ׂẴ��C�����×�ڂ��Ă���\���o���I���ɂ��� // ================================ - // �‰Šú‰» END + // ������ END // ================================ // ================================ - // ƒ‹�[ƒeƒBƒ“ƒO BEGIN + // ���[�e�B���O BEGIN // ================================ - // [Step 1] �‰Šúƒ‹�[ƒeƒBƒ“ƒO + // [Step 1] �������[�e�B���O cout << "Initial Routing" << endl; FIRST_ROUTING: for (ap_uint<8> i = 0; i < (ap_uint<8>)(line_num); i++) { @@ -213,10 +213,10 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat //#pragma HLS PIPELINE //#pragma HLS UNROLL factor=2 - // �”Žš‚ª—×�Ú‚·‚é�ê�‡ƒXƒLƒbƒv�A‚»‚¤‚łȂ¢�ê�‡‚ÍŽÀ�s + // �������×�ڂ���ê�‡ï¿½X�L�b�v�A�����łȂ��ê�‡ï¿½ÍŽï¿½ï¿½s if (adjacents[i] == false) { - // Œo˜H’T�õ + // �o�H�T�� #ifdef DEBUG_PRINT cout << "LINE #" << (int)(i + 1) << endl; #endif @@ -230,7 +230,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat bool has_overlap = false; #ifndef USE_MOD_CALC - // line_num_2: line_num ˆÈ�ã‚Å�Å�¬‚Ì2‚ׂ̂«�æ�” + // line_num_2: line_num �È��Å�Å����2�ׂ̂��æ�” ap_uint<8> line_num_2; CALC_LINE_NUM_2: for (line_num_2 = 1; line_num_2 < (ap_uint<8>)line_num; line_num_2 *= 2) { @@ -243,7 +243,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat ap_uint<8> last_target = 255; - // [Step 2] Rip-up �ă‹�[ƒeƒBƒ“ƒO + // [Step 2] Rip-up ��[�e�B���O ROUTING: for (ap_uint<16> round = 1; round <= 32768 /* = (2048 * 16) */; round++) { #pragma HLS LOOP_TRIPCOUNT min=1 max=4000 avg=50 @@ -252,12 +252,12 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat //cout << "ITERATION " << round; //#endif - // ‘Î�Ûƒ‰ƒCƒ“‚ð‘I‘ð + // �Î�ۃ��C����I�� #ifdef USE_MOD_CALC - // (1) �è—]‰‰ŽZ‚ð—p‚¢‚é•û–@ + // (1) ��]���Z��p������@ ap_uint<8> target = lfsr_random() % line_num; // i.e., lfsr_random_uint32(0, line_num - 1); #else - // (2) �è—]‰‰ŽZ‚ð—p‚¢‚È‚¢•û–@ + // (2) ��]���Z��p���Ȃ����@ ap_uint<8> target = lfsr_random() & (line_num_2 - 1); if (line_num <= target) { //cout << endl; @@ -265,36 +265,36 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } #endif - // �”Žš‚ª—×�Ú‚·‚é�ê�‡ƒXƒLƒbƒv�A‚»‚¤‚łȂ¢�ê�‡‚ÍŽÀ�s + // �������×�ڂ���ê�‡ï¿½X�L�b�v�A�����łȂ��ê�‡ï¿½ÍŽï¿½ï¿½s if (adjacents[target] == true) { //cout << endl; continue; } - // ’¼‘O‚̃CƒeƒŒ�[ƒVƒ‡ƒ“ (ƒ‰ƒEƒ“ƒh) ‚Æ“¯‚¶‘Î�Ûƒ‰ƒCƒ“‚¾‚Á‚½‚烋�[ƒeƒBƒ“ƒOƒXƒLƒbƒv‚·‚é + // ���O�̃C�e���[�V���� (���E���h) �Ɠ����Î�ۃ��C���������烋�[�e�B���O�X�L�b�v���� if (target == last_target) { //cout << endl; continue; } last_target = target; - // (1) ˆø‚«‚Í‚ª‚·ƒ‰ƒCƒ“‚Ì�d‚Ý‚ðƒŠƒZƒbƒg + // (1) �����͂������C���Ì�d�݂����Z�b�g ROUTING_RESET: for (ap_uint<9> j = 0; j < (ap_uint<9>)(paths_size[target]); j++) { #pragma HLS LOOP_TRIPCOUNT min=1 max=255 avg=50 weights[paths[target][j]] = 1; } - // ‘Î�Ûƒ‰ƒCƒ“‚̃Xƒ^�[ƒg‚Ì�d‚Ý‚àˆê’UƒŠƒZƒbƒg ‚ ‚ƂŠ(*) ‚Å–ß‚· + // �Î�ۃ��C���̃X�^�[�g�Ì�d�݂���U���Z�b�g ���Ƃ� (*) �Ŗ߂� weights[starts[target]] = 1; - // (2) �d‚Ý‚ð�X�V + // (2) �d�݂��X�V ap_uint<8> current_round_weight = new_weight(round); //cout << " weight " << current_round_weight << endl; ROUTING_UPDATE: for (ap_uint<8> i = 0; i < (ap_uint<8>)(line_num); i++) { #pragma HLS LOOP_TRIPCOUNT min=2 max=127 avg=50 - // �”Žš‚ª—×�Ú‚·‚é�ê�‡ƒXƒLƒbƒv�A‚»‚¤‚łȂ¢�ê�‡‚ÍŽÀ�s + // �������×�ڂ���ê�‡ï¿½X�L�b�v�A�����łȂ��ê�‡ï¿½ÍŽï¿½ï¿½s if (adjacents[i] == false && i != target) { ROUTING_UPDATE_PATH: for (ap_uint<9> j = 0; j < (ap_uint<9>)(paths_size[i]); j++) { @@ -304,17 +304,17 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } } - // Œo˜H’T�õ + // �o�H�T�� #ifdef DEBUG_PRINT cout << "LINE #" << (int)(target + 1) << endl; #endif search(&(paths_size[target]), paths[target], starts[target], goals[target], weights); - // (*) ‘Î�Ûƒ‰ƒCƒ“‚̃Xƒ^�[ƒg‚Ì�d‚Ý‚ð–ß‚· + // (*) �Î�ۃ��C���̃X�^�[�g�Ì�d�݂�߂� weights[starts[target]] = MAX_WEIGHT; - // ƒ‹�[ƒeƒBƒ“ƒOŒã - // ƒI�[ƒo�[ƒ‰ƒbƒv‚̃`ƒFƒbƒN + // ���[�e�B���O�� + // �I�[�o�[���b�v�̃`�F�b�N has_overlap = false; OVERLAP_RESET: for (ap_uint<16> i = 0; i < (ap_uint<16>)(MAX_CELLS); i++) { @@ -328,7 +328,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat overlap_checks[starts[i]] = 1; overlap_checks[goals[i]] = 1; - // �”Žš‚ª—×�Ú‚·‚é�ê�‡ƒXƒLƒbƒv�A‚»‚¤‚łȂ¢�ê�‡‚ÍŽÀ�s + // �������×�ڂ���ê�‡ï¿½X�L�b�v�A�����łȂ��ê�‡ï¿½ÍŽï¿½ï¿½s //if (adjacents[i] == false) { OVERLAP_CHECK_PATH: @@ -346,35 +346,35 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } //} } - // ƒI�[ƒo�[ƒ‰ƒbƒv‚È‚¯‚ê‚Î’T�õ�I—¹ + // �I�[�o�[���b�v�Ȃ���ΒT���I�� if (has_overlap == false) { break; } } - // ‰ð“±�o‚Å‚«‚È‚©‚Á‚½�ê�‡ + // �ð“±�o�ł��Ȃ������ê�‡ if (has_overlap == true) { *status = 1; return false; } // ================================ - // ƒ‹�[ƒeƒBƒ“ƒO END + // ���[�e�B���O END // ================================ // ================================ - // ‰ð�¶�¬ BEGIN + // �ð�¶�� BEGIN // ================================ - // ‹ó”’ + // �� OUTPUT_INIT: for (ap_uint<16> i = 0; i < (ap_uint<16>)(MAX_CELLS); i++) { boardstr[i] = 0; } - // ƒ‰ƒCƒ“ - // ‚±‚̃\ƒ‹ƒo‚ł̃‰ƒCƒ“ID‚ð+1‚µ‚Ä•\ަ‚·‚é - // ‚È‚º‚È‚ç‹ó”’‚ð 0 ‚Å•\‚·‚±‚Ƃɂ·‚é‚©‚烉ƒCƒ“ID‚Í 1 ˆÈ�ã‚É‚µ‚½‚¢ + // ���C�� + // ���̃\���o�ł̃��C��ID��+1���ĕ\������ + // �Ȃ��Ȃ�󔒂� 0 �ŕ\�����Ƃɂ��邩�烉�C��ID�� 1 �È��ɂ����� OUTPUT_LINE: for (ap_uint<8> i = 0; i < (ap_uint<8>)(line_num); i++) { #pragma HLS LOOP_TRIPCOUNT min=2 max=127 avg=50 @@ -388,7 +388,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat } // ================================ - // ‰ð�¶�¬ END + // �ð�¶�� END // ================================ *status = 0; @@ -397,18 +397,18 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat // ================================ // -// ’T�õ +// �T�� // ================================ // #ifdef USE_ASTAR -// A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN—p -// �Å‘å71 �Å�¬0 +// A* �q���[���X�e�B�b�N�p +// �ő�71 �Å��0 ap_uint<7> abs_uint7(ap_uint<7> a, ap_uint<7> b) { #pragma HLS INLINE if (a < b) { return b - a; } else { return a - b; } } -// �Å‘å7 �Å�¬0 +// �ő�7 �Å��0 ap_uint<3> abs_uint3(ap_uint<3> a, ap_uint<3> b) { #pragma HLS INLINE if (a < b) { return b - a; } @@ -416,20 +416,20 @@ ap_uint<3> abs_uint3(ap_uint<3> a, ap_uint<3> b) { } #endif -// * Python‚Ń_ƒCƒNƒXƒgƒ‰ƒAƒ‹ƒSƒŠƒYƒ€‚ðŽÀ‘•‚µ‚½ - ƒtƒc�[‚Á‚ÄŒ¾‚¤‚È‚Ÿ�I +// * Python�Ń_�C�N�X�g���A���S���Y������������ - �t�c�[���Č����Ȃ��I // http://lethe2211.hatenablog.com/entry/2014/12/30/011030 // * Implementation of A* // http://www.redblobgames.com/pathfinding/a-star/implementation.html -// ‚ðƒx�[ƒX +// ���x�[�X void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start, ap_uint<16> goal, ap_uint<8> w[MAX_CELLS]) { -//#pragma HLS INLINE // searchŠÖ�”‚̓Cƒ“ƒ‰ƒCƒ“‚·‚邯’x‚­‚Ȃ邵BRAM‘«‚è‚È‚­‚È‚é +//#pragma HLS INLINE // search�Ö���̓C�����C������ƒx���Ȃ邵BRAM����Ȃ��Ȃ� //#pragma HLS FUNCTION_INSTANTIATE variable=start //#pragma HLS FUNCTION_INSTANTIATE variable=goal - ap_uint<16> dist[MAX_CELLS]; // Žn“_‚©‚çŠe’¸“_‚܂łÌ�Å’Z‹——£‚ðŠi”[‚·‚é + ap_uint<16> dist[MAX_CELLS]; // �n�_����e���_�܂łÌ�Å’Z�������i�[���� #pragma HLS ARRAY_PARTITION variable=dist cyclic factor=64 dim=1 partition -// Note: dist ‚̃p�[ƒeƒBƒVƒ‡ƒ“‚Ì factor ‚Í 128 ‚É‚·‚邯BRAM‚ª‘«‚è‚È‚­‚È‚é - ap_uint<16> prev[MAX_CELLS]; // �Å’ZŒo˜H‚É‚¨‚¯‚é�C‚»‚Ì’¸“_‚Ì‘O‚Ì’¸“_‚ÌID‚ðŠi”[‚·‚é +// Note: dist �̃p�[�e�B�V������ factor �� 128 �ɂ����BRAM������Ȃ��Ȃ� + ap_uint<16> prev[MAX_CELLS]; // �ŒZ�o�H�ɂ�����C���̒��_�̑O�̒��_��ID���i�[���� SEARCH_INIT_DIST: for (ap_uint<16> i = 0; i < MAX_CELLS; i++) { @@ -437,19 +437,19 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start dist[i] = 65535; // = (2^16 - 1) } - // ƒvƒ‰ƒCƒIƒŠƒeƒB�EƒLƒ…�[ + // �v���C�I���e�B�E�L���[ ap_uint<12> pq_len = 0; ap_uint<32> pq_nodes[MAX_PQ]; //#pragma HLS ARRAY_PARTITION variable=pq_nodes complete dim=1 //#pragma HLS ARRAY_PARTITION variable=pq_nodes cyclic factor=2 dim=1 partition #ifdef DEBUG_PRINT - // ƒLƒ…�[‚Ì�ő咷‚³ƒ`ƒFƒbƒN—p + // �L���[�Ì�ő咷���`�F�b�N�p ap_uint<12> max_pq_len = 0; #endif #ifdef USE_ASTAR - // ƒS�[ƒ‹‚Ì�À•W + // �S�[���Ì���W ap_uint<13> goal_xy = (ap_uint<13>)(goal >> BITWIDTH_Z); ap_uint<7> goal_x = (ap_uint<7>)(goal_xy / MAX_WIDTH); ap_uint<7> goal_y = (ap_uint<7>)(goal_xy - goal_x * MAX_WIDTH); @@ -457,7 +457,7 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start #endif dist[start] = 0; - pq_push(0, start, &pq_len, pq_nodes); // Žn“_‚ðpush + pq_push(0, start, &pq_len, pq_nodes); // �n�_��push #ifdef DEBUG_PRINT if (max_pq_len < pq_len) { max_pq_len = pq_len; } #endif @@ -480,86 +480,86 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start ap_uint<16> dist_src = dist[src]; #ifndef USE_ASTAR - // ƒvƒ‰ƒCƒIƒŠƒeƒBƒLƒ…�[‚ÉŠi”[‚³‚ê‚Ä‚¢‚é�Å’Z‹——£‚ª�CŒ»�ÝŒvŽZ‚Å‚«‚Ä‚¢‚é�Å’Z‹——£‚æ‚è‘å‚«‚¯‚ê‚Î�Cdist‚Ì�X�V‚ð‚·‚é•K—v‚͂Ȃ¢ + // �v���C�I���e�B�L���[�Ɋi�[����Ă���ŒZ�������C���݌v�Z�ł��Ă���ŒZ�������傫����Î�Cdist�Ì�X�V������K�v�͂Ȃ� if (dist_src < prov_cost) { continue; } #endif - // PQ‚Ì�擪‚ªƒS�[ƒ‹‚Ì�ê�‡‚ÉPQ‚ª‚Ü‚¾‹ó‚¶‚á‚È‚­‚Ä‚à’T�õ�I‚í‚点‚µ‚Ü‚¤ + // PQ�Ì�擪���S�[���Ì�ê�‡ï¿½ï¿½PQ���܂��󂶂�Ȃ��Ă��T���I��点���܂� if (src == goal) { break; } - // —×�Ú‚·‚鑼‚Ì’¸“_‚Ì’T�õ - // (0) ƒRƒXƒg + // �×�ڂ��鑼�̒��_�̒T�� + // (0) �R�X�g ap_uint<8> cost = w[src]; - // (1) ƒm�[ƒhID‚©‚ç3ŽŸŒ³�À•W‚ðƒ}ƒXƒN‚µ‚Ä”²‚«�o‚· + // (1) �m�[�hID����3�������W���}�X�N���Ĕ����o�� ap_uint<13> src_xy = (ap_uint<13>)(src >> BITWIDTH_Z); ap_uint<7> src_x = (ap_uint<7>)(src_xy / MAX_WIDTH); ap_uint<7> src_y = (ap_uint<7>)(src_xy - src_x * MAX_WIDTH); ap_uint<3> src_z = (ap_uint<3>)(src & BITMASK_Z); //cout << src << " " << src_x << " " << src_y << " " << src_z << endl; - // (2) 3ŽŸŒ³�À•W‚Å—×�Ú‚·‚éƒm�[ƒh (6ŒÂ) ‚𒲂ׂé // Žè“®ƒ‹�[ƒv“WŠJ + // (2) 3�������W�ŗ×�ڂ���m�[�h (6��) �𒲂ׂ� // �蓮���[�v�W�J /*********************************************************** - if (src_x > 0) { // x-‚ð’²�¸ + if (src_x > 0) { // x-�ð’²�� ap_uint<16> dest = (((ap_uint<16>)(src_x-1) * MAX_WIDTH + (ap_uint<16>)(src_y)) << BITWIDTH_Z) | (ap_uint<16>)(src_z); ap_uint<16> dist_new = dist_src + cost; if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ - dist_new += abs_uint7(src_x-1, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ + dist_new += abs_uint7(src_x-1, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z, goal_z); // A* �q���[���X�e�B�b�N + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push } } - if (src_x < (size_x-1)) { // x+‚ð’²�¸ + if (src_x < (size_x-1)) { // x+�ð’²�� ap_uint<16> dest = (((ap_uint<16>)(src_x+1) * MAX_WIDTH + (ap_uint<16>)(src_y)) << BITWIDTH_Z) | (ap_uint<16>)(src_z); ap_uint<16> dist_new = dist_src + cost; if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ - dist_new += abs_uint7(src_x+1, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ + dist_new += abs_uint7(src_x+1, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z, goal_z); // A* �q���[���X�e�B�b�N + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push } } - if (src_y > 0) { // y-‚ð’²�¸ + if (src_y > 0) { // y-�ð’²�� ap_uint<16> dest = (((ap_uint<16>)(src_x) * MAX_WIDTH + (ap_uint<16>)(src_y-1)) << BITWIDTH_Z) | (ap_uint<16>)(src_z); ap_uint<16> dist_new = dist_src + cost; if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ - dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y-1, goal_y) + abs_uint3(src_z, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ + dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y-1, goal_y) + abs_uint3(src_z, goal_z); // A* �q���[���X�e�B�b�N + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push } } - if (src_y < (size_y-1)) { // y+‚ð’²�¸ + if (src_y < (size_y-1)) { // y+�ð’²�� ap_uint<16> dest = (((ap_uint<16>)(src_x) * MAX_WIDTH + (ap_uint<16>)(src_y+1)) << BITWIDTH_Z) | (ap_uint<16>)(src_z); ap_uint<16> dist_new = dist_src + cost; if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ - dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y+1, goal_y) + abs_uint3(src_z, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ + dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y+1, goal_y) + abs_uint3(src_z, goal_z); // A* �q���[���X�e�B�b�N + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push } } - if (src_z > 0) { // z-‚ð’²�¸ + if (src_z > 0) { // z-�ð’²�� ap_uint<16> dest = (((ap_uint<16>)(src_x) * MAX_WIDTH + (ap_uint<16>)(src_y)) << BITWIDTH_Z) | (ap_uint<16>)(src_z-1); ap_uint<16> dist_new = dist_src + cost; if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ - dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z-1, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ + dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z-1, goal_z); // A* �q���[���X�e�B�b�N + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push } } - if (src_z < (size_z-1)) { // y+‚ð’²�¸ + if (src_z < (size_z-1)) { // y+�ð’²�� ap_uint<16> dest = (((ap_uint<16>)(src_x) * MAX_WIDTH + (ap_uint<16>)(src_y)) << BITWIDTH_Z) | (ap_uint<16>)(src_z+1); ap_uint<16> dist_new = dist_src + cost; if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ - dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z+1, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ + dist_new += abs_uint7(src_x, goal_x) + abs_uint7(src_y, goal_y) + abs_uint3(src_z+1, goal_z); // A* �q���[���X�e�B�b�N + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push } } ***********************************************************/ @@ -568,9 +568,9 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start for (ap_uint<3> a = 0; a < 6; a++) { //#pragma HLS PIPELINE //#pragma HLS UNROLL factor=2 - ap_int<8> dest_x = (ap_int<8>)src_x; // �Å�¬-1 �Å‘å72 (->•„�†•t‚«8ƒrƒbƒg) - ap_int<8> dest_y = (ap_int<8>)src_y; // �Å�¬-1 �Å‘å72 (->•„�†•t‚«8ƒrƒbƒg) - ap_int<5> dest_z = (ap_int<5>)src_z; // �Å�¬-1 �Å‘å8 (->•„�†•t‚«5ƒrƒbƒg) + ap_int<8> dest_x = (ap_int<8>)src_x; // �Å��-1 �ő�72 (->�����t��8�r�b�g) + ap_int<8> dest_y = (ap_int<8>)src_y; // �Å��-1 �ő�72 (->�����t��8�r�b�g) + ap_int<5> dest_z = (ap_int<5>)src_z; // �Å��-1 �ő�8 (->�����t��5�r�b�g) if (a == 0) { dest_x -= 1; } if (a == 1) { dest_x += 1; } if (a == 2) { dest_y -= 1; } @@ -585,12 +585,12 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start //cout << " adjacent " << (int)dest << " (" << (int)dest_x << "," << (int)dest_y << "," << (int)dest_z << ") dist_new=" << (int)dist_new; #endif if (dist[dest] > dist_new) { - dist[dest] = dist_new; // dist‚Ì�X�V - prev[dest] = src; // ‘O‚Ì’¸“_‚ð‹L˜^ + dist[dest] = dist_new; // dist�Ì�X�V + prev[dest] = src; // �O�̒��_���L�^ #ifdef USE_ASTAR - dist_new += abs_uint7(dest_x, goal_x) + abs_uint7(dest_y, goal_y) + abs_uint3(dest_z, goal_z); // A* ƒqƒ…�[ƒŠƒXƒeƒBƒbƒN + dist_new += abs_uint7(dest_x, goal_x) + abs_uint7(dest_y, goal_y) + abs_uint3(dest_z, goal_z); // A* �q���[���X�e�B�b�N #endif - pq_push(dist_new, dest, &pq_len, pq_nodes); // ƒLƒ…�[‚É�V‚½‚ȉ¼‚Ì‹——£‚Ì�î•ñ‚ðpush + pq_push(dist_new, dest, &pq_len, pq_nodes); // �L���[�É�V���ȉ��̋����Ì����push #ifdef DEBUG_PRINT //cout << " h=" << (int)(abs_uint7(dest_x, goal_x) + abs_uint7(dest_y, goal_y) + abs_uint3(dest_z, goal_z)) << endl; //cout << (int)dest_x << " " << (int)goal_x << " " << (int)abs_uint7(dest_x, goal_x) << endl; @@ -606,8 +606,8 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start } } - // Œo˜H‚ð�o—Í - // ƒS�[ƒ‹‚©‚çƒXƒ^�[ƒg‚Ö‚Ì�‡”Ô‚Å•\ަ‚³‚ê‚é (ƒS�[ƒ‹‚ƃXƒ^�[ƒg‚͊܂܂ê‚È‚¢) + // �o�H���o�� + // �S�[������X�^�[�g�ւÌ���Ԃŕ\������� (�S�[���ƃX�^�[�g�͊܂܂�Ȃ�) ap_uint<16> t = prev[goal]; #ifdef DEBUG_PRINT @@ -625,7 +625,7 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start << "(" << dbg_goal_x << ", " << dbg_goal_y << ", " << dbg_goal_z << ") #" << goal << endl; #endif - // ƒoƒbƒNƒgƒ‰ƒbƒN + // �o�b�N�g���b�N ap_uint<8> p = 0; SEARCH_BACKTRACK: while (t != start) { @@ -640,10 +640,10 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start cout << " via " << "(" << t_x << ", " << t_y << ", " << t_z << ") #" << prev[t] << " dist=" << dist[t] << endl; #endif - path[p] = t; // ‹L˜^ + path[p] = t; // �L�^ p++; - t = prev[t]; // ŽŸ‚Ɉړ® + t = prev[t]; // ���Ɉړ� } *path_size = p; @@ -654,29 +654,29 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start } -// ƒvƒ‰ƒCƒIƒŠƒeƒB�EƒLƒ…�[ (ƒq�[ƒv‚ÅŽÀ‘•) -// —D�æ“x‚Ì�Å�¬’l‚ªƒq�[ƒv‚̃‹�[ƒg‚É—ˆ‚é -// ŽQ�l -// * ƒq�[ƒv - Wikipedia https://ja.wikipedia.org/wiki/%E3%83%92%E3%83%BC%E3%83%97 -// * “ñ•ªƒq�[ƒv - Wikipedia https://ja.wikipedia.org/wiki/%E4%BA%8C%E5%88%86%E3%83%92%E3%83%BC%E3%83%97 -// * ƒq�[ƒv‚Ì�³‘Ì - http://www.maroontress.com/Heap/ +// �v���C�I���e�B�E�L���[ (�q�[�v�Ŏ���) +// �D��x�Ì�Å���l���q�[�v�̃��[�g�ɗ��� +// �Q�l +// * �q�[�v - Wikipedia https://ja.wikipedia.org/wiki/%E3%83%92%E3%83%BC%E3%83%97 +// * �ñ•ªƒq�[�v - Wikipedia https://ja.wikipedia.org/wiki/%E4%BA%8C%E5%88%86%E3%83%92%E3%83%BC%E3%83%97 +// * �q�[�v�Ì���� - http://www.maroontress.com/Heap/ // * Priority queue - Rosetta Code https://rosettacode.org/wiki/Priority_queue#C // Note -// ƒCƒ“ƒfƒbƒNƒX‚ª0‚©‚çŽn‚܂邯‚« (0-origin index) -// --> �e: (n-1)/2, �¶‚ÌŽq: 2n+1, ‰E‚ÌŽq: 2n+2 -// ƒCƒ“ƒfƒbƒNƒX‚ª1‚©‚çŽn‚܂邯‚« (1-origin index) -// --> �e: n/2, �¶‚ÌŽq: 2n, ‰E‚ÌŽq: 2n+1 -// FPGA“I‚ɂ͂ǂ¿‚ç‚à’x‰„‚Í“¯‚¶‚¾‚¯‚Ç 1-origin ‚Ì•û‚ªLUTƒŠƒ\�[ƒX�­‚È‚­‚Ä�Ï‚Þ (‚½‚¾‚µ”z—ñ‚Ì0—v‘f‚ª–³‘ʂɂȂé) - -// ƒm�[ƒh‚Ì‘}“ü‚Í�C––”ö‚ɒljÁ‚µ‚Ä‚©‚ç—D�æ“x‚ª�³‚µ‚¢�‚‚³‚̈ʒu‚܂Ńm�[ƒh‚ð�ã‚°‚Ä‚¢‚­ -// ’T�õ‚Ì“s�‡�ã�C“¯‚¶—D�æ“x‚ł͌ォ‚ç“ü‚ꂽ•û‚ð�æ‚É�o‚µ‚½‚¢‚©‚ç�C -// ƒ‹�[ƒv‚Ì�I—¹�ðŒ�‚Í‘}“üƒm�[ƒh‚Ì—D�æ“x‚ª”äŠr‘Î�Û‚Ì—D�æ“x‚æ‚è‚à�¬‚³‚­‚È‚Á‚½‚Æ‚« +// �C���f�b�N�X��0����n�܂�Ƃ� (0-origin index) +// --> �e: (n-1)/2, ���̎q: 2n+1, �E�̎q: 2n+2 +// �C���f�b�N�X��1����n�܂�Ƃ� (1-origin index) +// --> �e: n/2, ���̎q: 2n, �E�̎q: 2n+1 +// FPGA�I�ɂ͂ǂ�����x���͓��������� 1-origin �̕���LUT���\�[�X���Ȃ��Ä�ς� (�������z���0�v�f�����ʂɂȂ�) + +// �m�[�h�̑}���Í�C�����ɒlj����Ă���D��x�������������̈ʒu�܂Ńm�[�h���グ�Ă��� +// �T���̓s����C�����D��x�ł͌ォ����ꂽ�����É�o����������C +// ���[�v�Ì�I�������͑}���m�[�h�̗D��x����r�Î�Û‚Ì—D��x�����������Ȃ����Ƃ� void pq_push(ap_uint<16> priority, ap_uint<16> data, ap_uint<12> *pq_len, ap_uint<32> pq_nodes[MAX_PQ]) { #pragma HLS INLINE (*pq_len)++; ap_uint<12> i = (*pq_len); // target - ap_uint<12> p = (*pq_len) >> 1; // i.e., (*pq_len) / 2; // �e + ap_uint<12> p = (*pq_len) >> 1; // i.e., (*pq_len) / 2; // �e PQ_PUSH_LOOP: while (i > 1 && (ap_uint<16>)(pq_nodes[p] & PQ_PRIORITY_MASK) >= priority) { #pragma HLS LOOP_TRIPCOUNT min=1 max=8 avg=4 @@ -684,16 +684,16 @@ void pq_push(ap_uint<16> priority, ap_uint<16> data, ap_uint<12> *pq_len, ap_uin //#pragma HLS UNROLL factor=2 pq_nodes[i] = pq_nodes[p]; i = p; - p = p >> 1; // i.e., p / 2; // �e + p = p >> 1; // i.e., p / 2; // �e } pq_nodes[i] = ((ap_uint<32>)data << 16) | (ap_uint<32>)priority; } -// ƒm�[ƒh‚ÌŽæ‚è�o‚µ‚Í�Cƒ‹�[ƒg‚ðŽæ‚Á‚Ä‚­‚邾‚¯ -// ŽŸ‚É�Å�¬‚Ì—D�æ“x‚ð‚à‚ƒm�[ƒh‚ðƒ‹�[ƒg‚Ɉړ®‚³‚¹‚邽‚ß‚É�C -// ‚Ü‚¸�C––”ö‚̃m�[ƒh‚ðƒ‹�[ƒg‚Ɉړ®‚·‚é -// —¼•û‚ÌŽq‚Å—D�æ“x‚ª�¬‚³‚¢•û‚ð�ã‚É‚à‚Á‚Ä‚¢‚­ (ƒ‹�[ƒg‚ð“K�Ø‚È�‚‚³‚܂ʼnº‚°‚é) -// ‚±‚ê‚ð�Ä‹A“I‚ÉŒJ‚è•Ô‚· +// �m�[�h�̎��o���Í�C���[�g������Ă��邾�� +// ���É�Å���̗D��x�����ƒm�[�h�����[�g�Ɉړ������邽�߂É�C +// �܂��C�����̃m�[�h�����[�g�Ɉړ����� +// �����̎q�ŗD��x��������������ɂ����Ă��� (���[�g��K�؂È�����܂ʼn�����) +// ������ċA�I�ɌJ��Ԃ� void pq_pop(ap_uint<16> *ret_priority, ap_uint<16> *ret_data, ap_uint<12> *pq_len, ap_uint<32> pq_nodes[MAX_PQ]) { #pragma HLS INLINE @@ -701,18 +701,18 @@ void pq_pop(ap_uint<16> *ret_priority, ap_uint<16> *ret_data, ap_uint<12> *pq_le *ret_data = (ap_uint<16>)(pq_nodes[1] >> PQ_PRIORITY_WIDTH); //pq_nodes[1] = pq_nodes[*pq_len]; - ap_uint<12> i = 1; // �eƒm�[ƒh - //ap_uint<12> t = 1; // ŒðŠ·‘Î�Ûƒm�[ƒh + ap_uint<12> i = 1; // �e�m�[�h + //ap_uint<12> t = 1; // �����Î�Ûƒm�[�h - ap_uint<16> last_priority = (ap_uint<16>)(pq_nodes[*pq_len] & PQ_PRIORITY_MASK); // ––”öƒm�[ƒh‚Ì—D�æ“x + ap_uint<16> last_priority = (ap_uint<16>)(pq_nodes[*pq_len] & PQ_PRIORITY_MASK); // �����m�[�h�̗D��x PQ_POP_LOOP: while (1) { #pragma HLS LOOP_TRIPCOUNT min=1 max=8 avg=4 //#pragma HLS PIPELINE //#pragma HLS UNROLL factor=2 - ap_uint<12> c1 = i << 1; // i.e., 2 * i; // �¶‚ÌŽq - ap_uint<12> c2 = c1 + 1; // i.e., 2 * i + 1; // ‰E‚ÌŽq + ap_uint<12> c1 = i << 1; // i.e., 2 * i; // ���̎q + ap_uint<12> c2 = c1 + 1; // i.e., 2 * i + 1; // �E�̎q if (c1 < *pq_len && (ap_uint<16>)(pq_nodes[c1] & PQ_PRIORITY_MASK) <= last_priority) { if (c2 < *pq_len && (ap_uint<16>)(pq_nodes[c2] & PQ_PRIORITY_MASK) <= (ap_uint<16>)(pq_nodes[c1] & PQ_PRIORITY_MASK)) { pq_nodes[i] = pq_nodes[c2]; diff --git a/hls/lines256_length128/router.hpp b/hls/lines256_length128/router.hpp index de3fabd3a12e3ea27c999c81354f8e407df44c4c..08d69241fae0a9010b1bbcbffffc99455a4dee0d 100644 --- a/hls/lines256_length128/router.hpp +++ b/hls/lines256_length128/router.hpp @@ -13,33 +13,33 @@ #include #endif -//#define DEBUG_PRINT // ‚¢‚ë‚¢‚ë•\ަ‚·‚é -#define USE_ASTAR // A* ’T�õ‚ðŽg‚¤ -#define USE_MOD_CALC // ƒ^�[ƒQƒbƒgƒ‰ƒCƒ“‚Ì‘I‘ð‚É�è—]‰‰ŽZ‚ð—p‚¢‚é +//#define DEBUG_PRINT // ���낢��\������ +#define USE_ASTAR // A* �T�����g�� +#define USE_MOD_CALC // �^�[�Q�b�g���C���̑I���É��]���Z��p���� using namespace std; -// ŠeŽí�Ý’è’l -#define MAX_WIDTH 72 // X, Y ‚Ì�Å‘å’l (7ƒrƒbƒg‚ÅŽû‚Ü‚é) +// �e��ݒ�l +#define MAX_WIDTH 72 // X, Y �Ì�ő�l (7�r�b�g�Ŏ��܂�) #define BITWIDTH_XY 13 #define BITMASK_XY 65528 // 1111 1111 1111 1000 -#define MAX_LAYER 8 // Z ‚Ì�Å‘å’l (3ƒrƒbƒg) +#define MAX_LAYER 8 // Z �Ì�ő�l (3�r�b�g) #define BITWIDTH_Z 3 #define BITMASK_Z 7 // 0000 0000 0000 0111 -#define MAX_CELLS 41472 // ƒZƒ‹‚Ì‘��” =72*72*8 (16ƒrƒbƒg‚ÅŽû‚Ü‚é) -#define MAX_LINES 256 // ƒ‰ƒCƒ“�”‚Ì�Å‘å’l (7ƒrƒbƒg) -#define MAX_PATH 128 // 1‚‚̃‰ƒCƒ“‚ª‘Ήž‚·‚éƒZƒ‹�”‚Ì�Å‘å’l (8ƒrƒbƒg) -#define MAX_PQ 4096 // ’T�õŽž‚̃vƒ‰ƒCƒIƒŠƒeƒB�EƒLƒ…�[‚Ì�Å‘åƒTƒCƒY (12ƒrƒbƒg) ‘«‚è‚È‚¢‚©‚à�H +#define MAX_CELLS 41472 // �Z���̑��� =72*72*8 (16�r�b�g�Ŏ��܂�) +#define MAX_LINES 256 // ���C�����Ì�ő�l (7�r�b�g) +#define MAX_PATH 128 // 1�‚̃��C�����Ή�����Z�����Ì�ő�l (8�r�b�g) +#define MAX_PQ 4096 // �T�����̃v���C�I���e�B�E�L���[�Ì�ő�T�C�Y (12�r�b�g) ����Ȃ������H #define PQ_PRIORITY_WIDTH 16 #define PQ_PRIORITY_MASK 65535 // 0000 0000 0000 0000 1111 1111 1111 1111 #define PQ_DATA_WIDTH 16 #define PQ_DATA_MASK 4294901760 // 1111 1111 1111 1111 0000 0000 0000 0000 -#define MAX_WEIGHT 255 // �d‚Ý‚Ì�Å‘å’l (8ƒrƒbƒg‚ÅŽû‚Ü‚é) -#define BOARDSTR_SIZE 41472 // ƒ{�[ƒhƒXƒgƒŠƒ“ƒO‚Ì�Å‘å•¶Žš�” (ƒZƒ‹�” 72*72*8 ‚ ‚ê‚Ηǂ¢) +#define MAX_WEIGHT 255 // �d�݂Ì�ő�l (8�r�b�g�Ŏ��܂�) +#define BOARDSTR_SIZE 41472 // �{�[�h�X�g�����O�Ì�ő啶���� (�Z���� 72*72*8 ����Ηǂ�) void lfsr_random_init(ap_uint<32> seed); @@ -48,7 +48,7 @@ ap_uint<32> lfsr_random(); //ap_uint<32> lfsr_random_uint32_0(ap_uint<32> b); ap_uint<8> new_weight(ap_uint<16> x); -bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status); +bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *status); #ifdef USE_ASTAR ap_uint<7> abs_uint7(ap_uint<7> a, ap_uint<7> b);