From 5430e8a2a408e90f055a05b69cbbbd9ccf9c9094 Mon Sep 17 00:00:00 2001 From: KazushiKawamura Date: Sun, 26 Aug 2018 21:50:14 +0900 Subject: [PATCH] Add pragma for Vivado-HLS --- hls_2018/router_01/router.cpp | 10 ++++++++++ hls_2018/router_02/router.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/hls_2018/router_01/router.cpp b/hls_2018/router_01/router.cpp index de396f1..19e47cf 100755 --- a/hls_2018/router_01/router.cpp +++ b/hls_2018/router_01/router.cpp @@ -68,6 +68,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat INIT_WEIGHTS: for (ap_uint i = 0; i < (ap_uint)(MAX_CELLS); i++) { +#pragma HLS UNROLL factor=2 weights[i] = 1; } @@ -151,6 +152,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat // Memories for Overlap Check ap_uint<1> overlap_checks[MAX_CELLS]; +#pragma HLS ARRAY_PARTITION variable=overlap_checks cyclic factor=16 dim=1 bool has_overlap = false; // ================================ @@ -188,6 +190,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat // (Step.2-1) Reset weights of target line WEIGHT_RESET: for (ap_uint j = s_idx[target]; j != s_idx[next_target]; j++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=1 max=256 weights[paths[j]] = 1; } @@ -196,11 +199,13 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat ap_uint<8> current_round_weight = new_weight(round); WEIGHT_PATH: for (ap_uint j = s_idx[next_target]; j != pointer; j++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=1 max=8192 weights[paths[j]] = current_round_weight; } WEIGHT_TERMINAL: for (ap_uint i = 0; i < (ap_uint)(line_num); i++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=2 max=999 weights[starts[i]] = MAX_WEIGHT; weights[goals[i]] = MAX_WEIGHT; @@ -230,16 +235,19 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat has_overlap = false; OVERLAP_RESET: for (ap_uint i = 0; i < (ap_uint)(MAX_CELLS); i++) { +#pragma HLS UNROLL factor=32 overlap_checks[i] = 0; } OVERLAP_CHECK_LINE: for (ap_uint i = 0; i < (ap_uint)(line_num); i++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=2 max=999 overlap_checks[starts[i]] = 1; overlap_checks[goals[i]] = 1; } OVERLAP_CHECK_PATH: for (ap_uint j = s_idx[next_target]; j != pointer; j++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=1 max=8192 ap_uint cell_id = paths[j]; if (overlap_checks[cell_id]) { @@ -340,10 +348,12 @@ ap_uint<3> abs_uint3(ap_uint<3> a, ap_uint<3> b) { ap_uint search(ap_uint idx, ap_uint paths[MAX_BUFFER], ap_uint start, ap_uint goal, ap_uint<8> w[MAX_CELLS]) { ap_uint dist[MAX_CELLS]; +#pragma HLS ARRAY_PARTITION variable=dist cyclic factor=64 dim=1 ap_uint prev[MAX_CELLS]; SEARCH_INIT_DIST: for (ap_uint i = 0; i < (ap_uint)(MAX_CELLS); i++) { +#pragma HLS UNROLL factor=128 dist[i] = 65535; // = (2^16 - 1) } diff --git a/hls_2018/router_02/router.cpp b/hls_2018/router_02/router.cpp index cf50624..d6e76f3 100755 --- a/hls_2018/router_02/router.cpp +++ b/hls_2018/router_02/router.cpp @@ -68,6 +68,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat INIT_WEIGHTS: for (ap_uint i = 0; i < (ap_uint)(MAX_CELLS); i++) { +#pragma HLS UNROLL factor=2 weights[i] = 1; } @@ -151,6 +152,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat // Memories for Overlap Check ap_uint<1> overlap_checks[MAX_CELLS]; +#pragma HLS ARRAY_PARTITION variable=overlap_checks cyclic factor=16 dim=1 bool has_overlap = false; // ================================ @@ -188,6 +190,7 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat // (Step.2-1) Reset weights of target line WEIGHT_RESET: for (ap_uint j = s_idx[target]; j != s_idx[next_target]; j++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=1 max=256 weights[paths[j]] = 1; } @@ -196,11 +199,13 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat ap_uint<8> current_round_weight = new_weight(round); WEIGHT_PATH: for (ap_uint j = s_idx[next_target]; j != pointer; j++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=1 max=8192 weights[paths[j]] = current_round_weight; } WEIGHT_TERMINAL: for (ap_uint i = 0; i < (ap_uint)(line_num); i++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=2 max=999 weights[starts[i]] = MAX_WEIGHT; weights[goals[i]] = MAX_WEIGHT; @@ -230,16 +235,19 @@ bool pynqrouter(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<32> *stat has_overlap = false; OVERLAP_RESET: for (ap_uint i = 0; i < (ap_uint)(MAX_CELLS); i++) { +#pragma HLS UNROLL factor=32 overlap_checks[i] = 0; } OVERLAP_CHECK_LINE: for (ap_uint i = 0; i < (ap_uint)(line_num); i++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=2 max=999 overlap_checks[starts[i]] = 1; overlap_checks[goals[i]] = 1; } OVERLAP_CHECK_PATH: for (ap_uint j = s_idx[next_target]; j != pointer; j++) { +#pragma HLS UNROLL factor=2 #pragma HLS LOOP_TRIPCOUNT min=1 max=8192 ap_uint cell_id = paths[j]; if (overlap_checks[cell_id]) { @@ -340,10 +348,12 @@ ap_uint<3> abs_uint3(ap_uint<3> a, ap_uint<3> b) { ap_uint search(ap_uint idx, ap_uint paths[MAX_BUFFER], ap_uint start, ap_uint goal, ap_uint<8> w[MAX_CELLS]) { ap_uint dist[MAX_CELLS]; +#pragma HLS ARRAY_PARTITION variable=dist cyclic factor=64 dim=1 ap_uint prev[MAX_CELLS]; SEARCH_INIT_DIST: for (ap_uint i = 0; i < (ap_uint)(MAX_CELLS); i++) { +#pragma HLS UNROLL factor=128 dist[i] = 65535; // = (2^16 - 1) } -- 2.22.0