Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kawamura-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
kawamura-solver
Commits
8c6fd6aa
Commit
8c6fd6aa
authored
Aug 26, 2019
by
kazushi.kawamura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upload scripts
parent
da31831a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
171 additions
and
0 deletions
+171
-0
README.md
scripts/README.md
+0
-0
main.py
scripts/main.py
+115
-0
sample_A.txt
scripts/sample_A.txt
+19
-0
sample_Q.txt
scripts/sample_Q.txt
+37
-0
No files found.
scripts/README.md
0 → 100644
View file @
8c6fd6aa
scripts/main.py
0 → 100644
View file @
8c6fd6aa
import
numpy
as
np
from
argparse
import
ArgumentParser
import
time
import
mySolverModule
from
pynq
import
Overlay
from
pynq
import
Xlnk
from
pynq
import
MMIO
def
commandParsing
():
parser
=
ArgumentParser
()
parser
.
add_argument
(
'-p'
,
'--problem'
,
help
=
'Problem file name'
,
required
=
True
)
# Required
parser
.
add_argument
(
'-s'
,
'--seed'
,
help
=
'seed value'
)
# Option
parser
.
add_argument
(
'-o'
,
'--output'
,
help
=
'Output file name'
)
# Option
args
=
vars
(
parser
.
parse_args
())
return
args
def
main
(
args
):
print
(
'Download overlay ...'
,
flush
=
True
)
OL
=
Overlay
(
'/home/xilinx/pynq/overlays/190826_solver/design_1.bit'
)
ip
=
'solver_0'
print
(
hex
(
OL
.
ip_dict
[
ip
][
'phys_addr'
]))
seed_v
=
3
if
args
[
'seed'
]
is
not
None
:
seed_v
=
int
(
args
[
'seed'
])
seed
=
mySolverModule
.
seed_generator
(
seed_v
)
# ndarray
info
=
mySolverModule
.
check_problem
(
args
[
'problem'
])
# extract info (block, line, ...)
## Global placement
p
=
mySolverModule
.
placer
(
seed
,
info
[
'W'
][
0
],
info
[
'H'
][
0
],
info
[
'blocks'
][
0
],
info
[
'line_num'
][
0
],
info
[
'block_info'
],
info
[
'line_info'
])
print
(
p
[
'block_place'
][
1
:
info
[
'blocks'
][
0
]])
## Allocate contiguous blocks
xlnk
=
Xlnk
()
print
(
xlnk
.
cma_stats
())
seed_buf
=
xlnk
.
cma_array
(
shape
=
(
3
,),
dtype
=
np
.
uint32
)
B_num_buf
=
xlnk
.
cma_array
(
shape
=
(
1
,),
dtype
=
np
.
int16
)
L_num_buf
=
xlnk
.
cma_array
(
shape
=
(
1
,),
dtype
=
np
.
int16
)
B_info_buf
=
xlnk
.
cma_array
(
shape
=
(
129
,
5
,
3
),
dtype
=
np
.
int16
)
W_ext_buf
=
xlnk
.
cma_array
(
shape
=
(
1
,),
dtype
=
np
.
int16
)
H_ext_buf
=
xlnk
.
cma_array
(
shape
=
(
1
,),
dtype
=
np
.
int16
)
B_place_buf
=
xlnk
.
cma_array
(
shape
=
(
129
,
2
),
dtype
=
np
.
int16
)
result_buf
=
xlnk
.
cma_array
(
shape
=
(
16384
,),
dtype
=
np
.
int16
)
print
(
xlnk
.
cma_stats
())
xlnk
.
cma_memcopy
(
seed_buf
,
p
[
'seed'
],
12
)
xlnk
.
cma_memcopy
(
B_num_buf
,
info
[
'blocks'
],
2
)
xlnk
.
cma_memcopy
(
L_num_buf
,
info
[
'line_num'
],
2
)
xlnk
.
cma_memcopy
(
B_info_buf
,
info
[
'block_info'
],
3870
)
xlnk
.
cma_memcopy
(
B_place_buf
,
p
[
'block_place'
],
516
)
phy_addr_0
=
seed_buf
.
physical_address
phy_addr_1
=
B_num_buf
.
physical_address
phy_addr_2
=
L_num_buf
.
physical_address
phy_addr_3
=
B_info_buf
.
physical_address
phy_addr_4
=
W_ext_buf
.
physical_address
phy_addr_5
=
H_ext_buf
.
physical_address
phy_addr_6
=
B_place_buf
.
physical_address
phy_addr_7
=
result_buf
.
physical_address
print
(
hex
(
phy_addr_0
),
hex
(
phy_addr_1
),
hex
(
phy_addr_2
),
hex
(
phy_addr_3
))
print
(
hex
(
phy_addr_4
),
hex
(
phy_addr_5
),
hex
(
phy_addr_6
),
hex
(
phy_addr_7
))
## Write pointers
lite_base_addr
=
OL
.
ip_dict
[
ip
][
'phys_addr'
]
# IP_BASE_ADDRESS
lite_size
=
OL
.
ip_dict
[
ip
][
'addr_range'
]
# ADDRESS_RANGE
mmio
=
MMIO
(
lite_base_addr
,
lite_size
)
mmio
.
write
(
0x18
,
phy_addr_0
)
mmio
.
write
(
0x20
,
phy_addr_1
)
mmio
.
write
(
0x28
,
phy_addr_2
)
mmio
.
write
(
0x30
,
phy_addr_3
)
mmio
.
write
(
0x38
,
phy_addr_4
)
mmio
.
write
(
0x40
,
phy_addr_5
)
mmio
.
write
(
0x48
,
phy_addr_6
)
mmio
.
write
(
0x50
,
phy_addr_7
)
## Local placement
print
(
'Solver start ...'
,
flush
=
True
)
mmio
.
write
(
0x00
,
1
)
while
mmio
.
read
(
0x00
)
!=
6
:
time
.
sleep
(
0.1
)
print
(
bin
(
mmio
.
read
(
0x00
)))
print
(
mmio
.
read
(
0x10
))
if
mmio
.
read
(
0x10
)
==
0
:
print
(
'Fail routing m(_ _)m'
)
return
# End function
W_ext
=
np
.
zeros
((
1
,),
dtype
=
np
.
int16
)
H_ext
=
np
.
zeros
((
1
,),
dtype
=
np
.
int16
)
result
=
np
.
zeros
((
16384
,),
dtype
=
np
.
int16
)
xlnk
.
cma_memcopy
(
W_ext
,
W_ext_buf
,
2
)
xlnk
.
cma_memcopy
(
H_ext
,
H_ext_buf
,
2
)
xlnk
.
cma_memcopy
(
result
,
result_buf
,
32768
)
xlnk
.
cma_memcopy
(
info
[
'block_info'
],
B_info_buf
,
3870
)
mySolverModule
.
show_result
(
W_ext
[
0
],
H_ext
[
0
],
info
[
'blocks'
][
0
],
info
[
'line_num'
][
0
],
info
[
'block_info'
],
result
)
if
W_ext
[
0
]
>
info
[
'W'
][
0
]
or
H_ext
[
0
]
>
info
[
'H'
][
0
]:
print
(
'Fail satisfying constraint T_T'
)
else
:
print
(
'Satisfy constraint ^_^'
)
if
args
[
'output'
]
is
not
None
:
mySolverModule
.
output_to_file
(
args
[
'output'
],
W_ext
[
0
],
H_ext
[
0
],
info
[
'blocks'
][
0
],
info
[
'line_num'
][
0
],
info
[
'block_info'
],
result
)
if
__name__
==
'__main__'
:
args
=
commandParsing
()
main
(
args
)
scripts/sample_A.txt
0 → 100644
View file @
8c6fd6aa
SIZE 8X10
1, 1, 1, 2, 2, 2, 2, 0
0, 0, 4, 0, 0, 0, 2, 2
8, 8, 4, 4, 4, 0, 4, 2
7, 8, 0, 0, 4, 4, 4, 2
7, 6, 0, 0, 0, 0, 2, 2
0, 6, 6, 6, 5, 11, 0, 0
10, 10, 10, 6, 5, 11, 0, 0
0, 9, 5, 5, 5, 0, 0, 3
3, 9, 3, 3, 3, 3, 3, 3
3, 3, 3, 0, 0, 0, 0, 0
BLOCK#1 @(0,0)
BLOCK#2 @(0,3)
BLOCK#3 @(0,6)
BLOCK#4 @(2,0)
BLOCK#5 @(5,6)
BLOCK#6 @(4,4)
BLOCK#7 @(1,6)
BLOCK#8 @(4,1)
scripts/sample_Q.txt
0 → 100644
View file @
8c6fd6aa
SIZE 10X10
BLOCK_NUM 8
BLOCK#1 1X4
1
+
8
7
BLOCK#2 3X2
0,8,0
7,6,+
BLOCK#3 2X3
10,0
+,0
3,9
BLOCK#4 2X2
1,2
4,+
BLOCK#5 3X2
11,+,+
0,0,3
BLOCK#6 3X2
0, +,2
5,11,0
BLOCK#7 3X2
0,10,6
9, 5,0
BLOCK#8 3X2
+,+,0
0,+,4
\ No newline at end of file
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