Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
solver
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
adc2019
solver
Commits
007e0ee9
Commit
007e0ee9
authored
Jul 16, 2019
by
kazushi.kawamura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
close
#1
and update functions
parent
eae29f6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
router.cpp
router/router.cpp
+19
-6
router.hpp
router/router.hpp
+1
-1
No files found.
router/router.cpp
View file @
007e0ee9
...
...
@@ -57,8 +57,12 @@ int router(short int size_x, short int size_y, short int line_num, short int boa
for
(
i
=
0
;
i
<
line_num
;
i
++
)
{
ap_uint
<
DATA_BIT
>
t1
=
terminals
[
i
][
0
];
ap_uint
<
DATA_BIT
>
t2
=
terminals
[
i
][
1
];
short
int
dist
=
abs
((
short
int
)
t2
-
(
short
int
)
t1
);
if
(
dist
==
1
||
dist
==
size_x
)
{
short
int
t1_x
=
t1
%
size_x
;
short
int
t1_y
=
t1
/
size_x
;
short
int
t2_x
=
t2
%
size_x
;
short
int
t2_y
=
t2
/
size_x
;
short
int
dist
=
abs
(
t1_x
-
t2_x
)
+
abs
(
t1_y
-
t2_y
);
// Manhattan dist.
if
(
dist
==
1
)
{
adjacents
[
i
]
=
true
;
#ifdef PRINT_BOARD
cout
<<
"Line #"
<<
i
+
1
<<
" needs no routing"
<<
endl
;
...
...
@@ -79,7 +83,7 @@ int router(short int size_x, short int size_y, short int line_num, short int boa
ap_uint
<
DATA_BIT
>
t1
=
terminals
[
i
][
0
];
ap_uint
<
DATA_BIT
>
t2
=
terminals
[
i
][
1
];
weights
[
t1
]
=
1
;
search
(
size_x
,
size_y
,
&
paths_size
[
i
],
paths
[
i
],
t1
,
t2
,
weights
);
if
(
search
(
size_x
,
size_y
,
&
paths_size
[
i
],
paths
[
i
],
t1
,
t2
,
weights
)
<
0
)
{
return
0
;
}
weights
[
t1
]
=
PRIO_MAX
;
}
...
...
@@ -147,7 +151,9 @@ int router(short int size_x, short int size_y, short int line_num, short int boa
return
0
;
}
int
total_wire_length
=
0
;
for
(
i
=
0
;
i
<
line_num
;
i
++
)
{
total_wire_length
+=
paths_size
[
i
];
for
(
p
=
0
;
p
<
paths_size
[
i
];
p
++
)
{
ap_uint
<
DATA_BIT
>
cell_id
=
paths
[
i
][
p
];
board_str
[
cell_id
]
=
i
+
1
;
...
...
@@ -169,7 +175,7 @@ int router(short int size_x, short int size_y, short int line_num, short int boa
}
#endif
return
1
;
return
total_wire_length
;
}
void
lfsr_random_init
(
ap_uint
<
32
>
seed
)
{
...
...
@@ -192,7 +198,7 @@ ap_uint<PRIO_BIT> new_weight(ap_uint<16> x) {
return
(
ap_uint
<
PRIO_BIT
>
)(
y
);
}
void
search
(
short
int
size_x
,
short
int
size_y
,
short
int
*
path_size
,
ap_uint
<
DATA_BIT
>
path
[
MAX_PATH
],
ap_uint
<
DATA_BIT
>
start
,
ap_uint
<
DATA_BIT
>
goal
,
ap_uint
<
PRIO_BIT
>
w
[
MAX_CELLS
]){
int
search
(
short
int
size_x
,
short
int
size_y
,
short
int
*
path_size
,
ap_uint
<
DATA_BIT
>
path
[
MAX_PATH
],
ap_uint
<
DATA_BIT
>
start
,
ap_uint
<
DATA_BIT
>
goal
,
ap_uint
<
PRIO_BIT
>
w
[
MAX_CELLS
]){
ap_uint
<
PRIO_BIT
>
dist
[
MAX_CELLS
];
ap_uint
<
DATA_BIT
>
prev
[
MAX_CELLS
];
...
...
@@ -212,6 +218,7 @@ void search(short int size_x, short int size_y, short int *path_size, ap_uint<DA
dist
[
start
]
=
0
;
enqueue
(
pq_nodes
,
0
,
start
,
&
pq_len
,
&
is_empty
);
bool
find_path
=
false
;
// No path exists
while
(
!
is_empty
)
{
ap_uint
<
PRIO_BIT
>
prev_cost
;
...
...
@@ -220,7 +227,10 @@ void search(short int size_x, short int size_y, short int *path_size, ap_uint<DA
ap_uint
<
PRIO_BIT
>
dist_s
=
dist
[
s
];
if
(
s
==
goal
)
break
;
if
(
s
==
goal
)
{
find_path
=
true
;
break
;
}
ap_uint
<
PRIO_BIT
>
cost
=
w
[
s
];
short
int
s_x
=
s
%
size_x
;
...
...
@@ -250,6 +260,7 @@ void search(short int size_x, short int size_y, short int *path_size, ap_uint<DA
}
}
}
if
(
!
find_path
){
return
-
1
;
}
ap_uint
<
DATA_BIT
>
t
=
prev
[
goal
];
short
int
p
=
0
;
...
...
@@ -268,6 +279,8 @@ void search(short int size_x, short int size_y, short int *path_size, ap_uint<DA
cout
<<
endl
;
#endif
*
path_size
=
p
;
return
0
;
}
// Enqueue (Insert an element)
...
...
router/router.hpp
View file @
007e0ee9
...
...
@@ -38,7 +38,7 @@ void lfsr_random_init(ap_uint<32> seed);
ap_uint
<
32
>
lfsr_random
();
ap_uint
<
PRIO_BIT
>
new_weight
(
ap_uint
<
16
>
x
);
void
search
(
short
int
size_x
,
short
int
size_y
,
short
int
*
path_size
,
ap_uint
<
DATA_BIT
>
path
[
MAX_PATH
],
ap_uint
<
DATA_BIT
>
start
,
ap_uint
<
DATA_BIT
>
goal
,
ap_uint
<
PRIO_BIT
>
w
[
MAX_CELLS
]);
int
search
(
short
int
size_x
,
short
int
size_y
,
short
int
*
path_size
,
ap_uint
<
DATA_BIT
>
path
[
MAX_PATH
],
ap_uint
<
DATA_BIT
>
start
,
ap_uint
<
DATA_BIT
>
goal
,
ap_uint
<
PRIO_BIT
>
w
[
MAX_CELLS
]);
void
enqueue
(
ap_uint
<
ELEM_BIT
>
pq_nodes
[
MAX_PQ
],
ap_uint
<
PRIO_BIT
>
priority
,
ap_uint
<
DATA_BIT
>
data
,
ap_uint
<
PQ_BIT
>
*
pq_len
,
bool
*
is_empty
);
void
dequeue
(
ap_uint
<
ELEM_BIT
>
pq_nodes
[
MAX_PQ
],
ap_uint
<
PRIO_BIT
>
*
ret_priority
,
ap_uint
<
DATA_BIT
>
*
ret_data
,
ap_uint
<
PQ_BIT
>
*
pq_len
,
bool
*
is_empty
);
...
...
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