Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
1fc5e482
Commit
1fc5e482
authored
Aug 09, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update several parameters for search
parent
49b4fd83
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
27 deletions
+28
-27
main.cpp
hls/ZU3EG_test/main.cpp
+1
-1
main.cpp
hls/lines256_length128/main.cpp
+1
-1
router.cpp
hls/lines256_length128/router.cpp
+23
-22
router.hpp
hls/lines256_length128/router.hpp
+3
-3
No files found.
hls/ZU3EG_test/main.cpp
View file @
1fc5e482
...
...
@@ -58,7 +58,7 @@ int main(int argc, char *argv[]) {
ap_int
<
32
>
status
;
clock_t
clock_start
,
clock_done
;
clock_start
=
clock
();
bool
result
=
pynqrouter
(
boardstr
,
seed
,
&
status
);
bool
result
=
pynqrouter
_zu3eg_test
(
boardstr
,
seed
,
&
status
);
clock_done
=
clock
();
if
(
result
)
{
cout
<<
endl
<<
"Test Passed!"
<<
endl
;
...
...
hls/lines256_length128/main.cpp
View file @
1fc5e482
...
...
@@ -58,7 +58,7 @@ int main(int argc, char *argv[]) {
ap_int
<
32
>
status
;
clock_t
clock_start
,
clock_done
;
clock_start
=
clock
();
bool
result
=
pynqrouter
(
boardstr
,
seed
,
&
status
);
bool
result
=
pynqrouter
_256x128
(
boardstr
,
seed
,
&
status
);
clock_done
=
clock
();
if
(
result
)
{
cout
<<
endl
<<
"Test Passed!"
<<
endl
;
...
...
hls/lines256_length128/router.cpp
View file @
1fc5e482
...
...
@@ -84,7 +84,7 @@ static ap_uint<7> size_x; // ボードの X サイズ
static
ap_uint
<
7
>
size_y
;
// ボードの Y サイズ
static
ap_uint
<
4
>
size_z
;
// ボードの Z サイズ
static
ap_uint
<
7
>
line_num
=
0
;
// ラインの総数
static
ap_uint
<
8
>
line_num
=
0
;
// ラインの総数
// グローバル変数で定義する
#ifdef GLOBALVARS
...
...
@@ -131,7 +131,7 @@ bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<3
// ループカウンタは1ビット余分に用意しないと終了判定できない
INIT_ADJACENTS:
for
(
ap_uint
<
8
>
i
=
0
;
i
<
(
ap_uint
<
8
>
)(
MAX_LINES
);
i
++
)
{
for
(
ap_uint
<
9
>
i
=
0
;
i
<
(
ap_uint
<
9
>
)(
MAX_LINES
);
i
++
)
{
adjacents
[
i
]
=
false
;
}
...
...
@@ -208,8 +208,9 @@ bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<3
// [Step 1] 初期ルーティング
cout
<<
"Initial Routing"
<<
endl
;
FIRST_ROUTING:
for
(
ap_uint
<
8
>
i
=
0
;
i
<
(
ap_uint
<
8
>
)(
line_num
);
i
++
)
{
#pragma HLS LOOP_TRIPCOUNT min=2 max=127 avg=50
for
(
ap_uint
<
9
>
i
=
0
;
i
<
(
ap_uint
<
9
>
)(
line_num
);
i
++
)
{
#pragma HLS LOOP_TRIPCOUNT min=2 max=255 avg=50
//#pragma HLS LOOP_TRIPCOUNT min=2 max=127 avg=50
//#pragma HLS PIPELINE
//#pragma HLS UNROLL factor=2
...
...
@@ -231,9 +232,9 @@ bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<3
#ifndef USE_MOD_CALC
// line_num_2: line_num 以上で最小の2のべき乗数
ap_uint
<
8
>
line_num_2
;
ap_uint
<
9
>
line_num_2
;
CALC_LINE_NUM_2:
for
(
line_num_2
=
1
;
line_num_2
<
(
ap_uint
<
8
>
)
line_num
;
line_num_2
*=
2
)
{
for
(
line_num_2
=
1
;
line_num_2
<
(
ap_uint
<
9
>
)
line_num
;
line_num_2
*=
2
)
{
#pragma HLS LOOP_TRIPCOUNT min=1 max=8 avg=4
;
}
...
...
@@ -291,8 +292,8 @@ bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<3
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
for
(
ap_uint
<
9
>
i
=
0
;
i
<
(
ap_uint
<
9
>
)(
line_num
);
i
++
)
{
#pragma HLS LOOP_TRIPCOUNT min=2 max=
255
avg=50
// 数字が隣接する場合スキップ、そうでない場合は実行
if
(
adjacents
[
i
]
==
false
&&
i
!=
target
)
{
...
...
@@ -322,9 +323,9 @@ bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<3
overlap_checks
[
i
]
=
0
;
}
OVERLAP_CHECK:
for
(
ap_uint
<
8
>
i
=
0
;
i
<
(
ap_uint
<
8
>
)(
line_num
);
i
++
)
{
for
(
ap_uint
<
9
>
i
=
0
;
i
<
(
ap_uint
<
9
>
)(
line_num
);
i
++
)
{
#pragma HLS LOOP_FLATTEN off
#pragma HLS LOOP_TRIPCOUNT min=2 max=
127
avg=50
#pragma HLS LOOP_TRIPCOUNT min=2 max=
255
avg=50
overlap_checks
[
starts
[
i
]]
=
1
;
overlap_checks
[
goals
[
i
]]
=
1
;
...
...
@@ -376,8 +377,8 @@ bool pynqrouter_256x128(char boardstr[BOARDSTR_SIZE], ap_uint<32> seed, ap_int<3
// このソルバでのラインIDを+1して表示する
// なぜなら空白を 0 で表すことにするからライン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
for
(
ap_uint
<
9
>
i
=
0
;
i
<
(
ap_uint
<
9
>
)(
line_num
);
i
++
)
{
#pragma HLS LOOP_TRIPCOUNT min=2 max=
255
avg=50
boardstr
[
starts
[
i
]]
=
(
i
+
1
);
boardstr
[
goals
[
i
]]
=
(
i
+
1
);
OUTPUT_LINE_PATH:
...
...
@@ -438,14 +439,14 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start
}
// プライオリティ・キュー
ap_uint
<
1
2
>
pq_len
=
0
;
ap_uint
<
1
3
>
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
// キューの最大長さチェック用
ap_uint
<
1
2
>
max_pq_len
=
0
;
ap_uint
<
1
3
>
max_pq_len
=
0
;
#endif
#ifdef USE_ASTAR
...
...
@@ -671,12 +672,12 @@ void search(ap_uint<8> *path_size, ap_uint<16> path[MAX_PATH], ap_uint<16> start
// ノードの挿入は,末尾に追加してから優先度が正しい高さの位置までノードを上げていく
// 探索の都合上,同じ優先度では後から入れた方を先に出したいから,
// ループの終了条件は挿入ノードの優先度が比較対象の優先度よりも小さくなったとき
void
pq_push
(
ap_uint
<
16
>
priority
,
ap_uint
<
16
>
data
,
ap_uint
<
1
2
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
])
{
void
pq_push
(
ap_uint
<
16
>
priority
,
ap_uint
<
16
>
data
,
ap_uint
<
1
3
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
])
{
#pragma HLS INLINE
(
*
pq_len
)
++
;
ap_uint
<
1
2
>
i
=
(
*
pq_len
);
// target
ap_uint
<
1
2
>
p
=
(
*
pq_len
)
>>
1
;
// i.e., (*pq_len) / 2; // 親
ap_uint
<
1
3
>
i
=
(
*
pq_len
);
// target
ap_uint
<
1
3
>
p
=
(
*
pq_len
)
>>
1
;
// i.e., (*pq_len) / 2; // 親
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
...
...
@@ -694,15 +695,15 @@ void pq_push(ap_uint<16> priority, ap_uint<16> data, ap_uint<12> *pq_len, ap_uin
// まず,末尾のノードをルートに移動する
// 両方の子で優先度が小さい方を上にもっていく (ルートを適切な高さまで下げる)
// これを再帰的に繰り返す
void
pq_pop
(
ap_uint
<
16
>
*
ret_priority
,
ap_uint
<
16
>
*
ret_data
,
ap_uint
<
1
2
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
])
{
void
pq_pop
(
ap_uint
<
16
>
*
ret_priority
,
ap_uint
<
16
>
*
ret_data
,
ap_uint
<
1
3
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
])
{
#pragma HLS INLINE
*
ret_priority
=
(
ap_uint
<
16
>
)(
pq_nodes
[
1
]
&
PQ_PRIORITY_MASK
);
*
ret_data
=
(
ap_uint
<
16
>
)(
pq_nodes
[
1
]
>>
PQ_PRIORITY_WIDTH
);
//pq_nodes[1] = pq_nodes[*pq_len];
ap_uint
<
1
2
>
i
=
1
;
// 親ノード
//ap_uint<1
2
> t = 1; // 交換対象ノード
ap_uint
<
1
3
>
i
=
1
;
// 親ノード
//ap_uint<1
3
> t = 1; // 交換対象ノード
ap_uint
<
16
>
last_priority
=
(
ap_uint
<
16
>
)(
pq_nodes
[
*
pq_len
]
&
PQ_PRIORITY_MASK
);
// 末尾ノードの優先度
...
...
@@ -711,8 +712,8 @@ void pq_pop(ap_uint<16> *ret_priority, ap_uint<16> *ret_data, ap_uint<12> *pq_le
#pragma HLS LOOP_TRIPCOUNT min=1 max=8 avg=4
//#pragma HLS PIPELINE
//#pragma HLS UNROLL factor=2
ap_uint
<
1
2
>
c1
=
i
<<
1
;
// i.e., 2 * i; // 左の子
ap_uint
<
1
2
>
c2
=
c1
+
1
;
// i.e., 2 * i + 1; // 右の子
ap_uint
<
1
3
>
c1
=
i
<<
1
;
// i.e., 2 * i; // 左の子
ap_uint
<
1
3
>
c2
=
c1
+
1
;
// i.e., 2 * i + 1; // 右の子
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
];
...
...
hls/lines256_length128/router.hpp
View file @
1fc5e482
...
...
@@ -31,7 +31,7 @@ using namespace std;
#define MAX_CELLS 41472 // セルの総数 =72*72*8 (16ビットで収まる)
#define MAX_LINES 256 // ライン数の最大値 (7ビット)
#define MAX_PATH 128 // 1つのラインが対応するセル数の最大値 (8ビット)
#define MAX_PQ
4096
// 探索時のプライオリティ・キューの最大サイズ (12ビット) 足りないかも?
#define MAX_PQ
8192
// 探索時のプライオリティ・キューの最大サイズ (12ビット) 足りないかも?
#define PQ_PRIORITY_WIDTH 16
#define PQ_PRIORITY_MASK 65535 // 0000 0000 0000 0000 1111 1111 1111 1111
...
...
@@ -56,7 +56,7 @@ ap_uint<3> abs_uint3(ap_uint<3> a, ap_uint<3> b);
#endif
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_WEIGHT
]);
void
pq_push
(
ap_uint
<
16
>
priority
,
ap_uint
<
16
>
data
,
ap_uint
<
1
2
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
]);
void
pq_pop
(
ap_uint
<
16
>
*
ret_priority
,
ap_uint
<
16
>
*
ret_data
,
ap_uint
<
1
2
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
]);
void
pq_push
(
ap_uint
<
16
>
priority
,
ap_uint
<
16
>
data
,
ap_uint
<
1
3
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
]);
void
pq_pop
(
ap_uint
<
16
>
*
ret_priority
,
ap_uint
<
16
>
*
ret_data
,
ap_uint
<
1
3
>
*
pq_len
,
ap_uint
<
32
>
pq_nodes
[
MAX_PQ
]);
#endif
/* __ROUTER_HPP__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment