Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
macroplacement
Overview
Overview
Details
Activity
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
lvzhengyang
macroplacement
Commits
bcbeacdb
Commit
bcbeacdb
authored
Jul 09, 2022
by
sakundu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added script to generate init.plc from pb
Signed-off-by: sakundu <sakundu@ucsd.edu>
parent
cc0f2c6a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
Flows/util/gen_plc_from_pb.py
+98
-0
No files found.
Flows/util/gen_plc_from_pb.py
0 → 100644
View file @
bcbeacdb
import
sys
import
numpy
as
np
class
pb_object
:
def
__init__
(
self
,
id
):
self
.
name
=
None
self
.
node_id
=
id
self
.
height
=
0
self
.
width
=
0
self
.
weight
=
0
self
.
x
=
-
1
self
.
x_offset
=
0
self
.
y
=
-
1
self
.
y_offset
=
0
self
.
m_name
=
None
self
.
pb_type
=
None
self
.
side
=
None
self
.
orientation
=
None
pb_file
=
sys
.
argv
[
1
]
print
(
f
'Protocol buffer file {pb_file}'
)
fp
=
open
(
pb_file
,
"r"
)
lines
=
fp
.
readlines
()
key1
=
[
'"height"'
,
'"weight"'
,
'"width"'
,
'"x"'
,
'"x_offset"'
,
'"y"'
,
'"y_offset"'
]
key2
=
[
'"macro_name"'
,
'"orientation"'
,
'"side"'
,
'"type"'
]
node_list
=
[]
node_id
=
0
key
=
""
keys
=
set
()
for
line
in
lines
:
words
=
line
.
split
()
if
words
[
0
]
==
'node'
:
node_list
.
append
(
pb_object
(
node_id
))
node_id
+=
1
elif
words
[
0
]
==
'name:'
:
node_list
[
-
1
]
.
name
=
words
[
1
]
elif
words
[
0
]
==
'key:'
:
key
=
words
[
1
]
keys
.
add
(
key
)
elif
words
[
0
]
==
'placeholder:'
:
if
key
==
key2
[
0
]:
node_list
[
-
1
]
.
m_name
=
words
[
1
]
elif
key
==
key2
[
1
]:
node_list
[
-
1
]
.
orientation
=
words
[
1
]
elif
key
==
key2
[
2
]:
node_list
[
-
1
]
.
side
=
words
[
1
]
elif
key
==
key2
[
3
]:
node_list
[
-
1
]
.
pb_type
=
words
[
1
]
elif
words
[
0
]
==
'f:'
:
if
key
==
key1
[
0
]:
node_list
[
-
1
]
.
height
=
words
[
1
]
elif
key
==
key1
[
1
]:
node_list
[
-
1
]
.
weight
=
words
[
1
]
elif
key
==
key1
[
2
]:
node_list
[
-
1
]
.
width
=
words
[
1
]
elif
key
==
key1
[
3
]:
node_list
[
-
1
]
.
x
=
words
[
1
]
elif
key
==
key1
[
4
]:
node_list
[
-
1
]
.
x_offset
=
words
[
1
]
elif
key
==
key1
[
5
]:
node_list
[
-
1
]
.
y
=
words
[
1
]
elif
key
==
key1
[
6
]:
node_list
[
-
1
]
.
y_offset
=
words
[
1
]
fp
.
close
()
fp
=
open
(
"init.plc"
,
"w"
)
hard_macro_list
=
[]
soft_macro_list
=
[]
port_list
=
[]
for
node
in
node_list
:
if
node
.
pb_type
==
'"MACRO"'
:
hard_macro_list
.
append
(
node
)
elif
node
.
pb_type
==
'"macro"'
:
soft_macro_list
.
append
(
node
)
elif
node
.
pb_type
==
'"port"'
or
node
.
pb_type
==
'"PORT"'
:
port_list
.
append
(
node
)
area1
=
0
area2
=
0
for
node
in
port_list
:
fp
.
write
(
f
"{node.node_id} {node.x} {node.y} - 1
\n
"
)
for
node
in
hard_macro_list
:
fp
.
write
(
f
"{node.node_id} {np.round(float(node.x),3)} {np.round(float(node.y),3)} N 0
\n
"
)
area1
+=
float
(
node
.
height
)
*
float
(
node
.
width
)
for
node
in
soft_macro_list
:
fp
.
write
(
f
"{node.node_id} {np.round(float(node.x),3)} {np.round(float(node.y),3)} N 0
\n
"
)
area2
+=
float
(
node
.
height
)
*
float
(
node
.
width
)
area
=
area1
+
area2
fp
.
write
(
f
"# Area: {area}
\n
"
)
fp
.
close
()
\ 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