-
Notifications
You must be signed in to change notification settings - Fork 504
Expand file tree
/
Copy pathplot_floorplan.py
More file actions
188 lines (149 loc) · 4.27 KB
/
Copy pathplot_floorplan.py
File metadata and controls
188 lines (149 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import os
import matplotlib.pyplot as plt
from math import log
#
# Helper function to visualize the rtlmp macro placement
# If run in ORFS rtlmp creates a dir in the objext/<platform>/<test_case>/<flow_variant>/rtlmp
# link that dir to ./rtlmp
# run python3 utils/plot_floorplan.py
#
file_name = "./rtlmp/final_floorplan.txt"
net_file = "./rtlmp/partition.txt.net"
net_threshold = 1500
cluster_list = []
cluster_lx_list = []
cluster_ly_list = []
cluster_ux_list = []
cluster_uy_list = []
macro_list = []
macro_lx_list = []
macro_ly_list = []
macro_ux_list = []
macro_uy_list = []
cluster_dict = {}
with open(file_name) as f:
content = f.read().splitlines()
f.close()
outline_width = float(content[0].split()[-1])
outline_height = float(content[1].split()[-1])
terminal_dict = {}
terminal_dict["LM"] = [0, outline_height / 2.0]
terminal_dict["RM"] = [outline_width, outline_height / 2.0]
terminal_dict["BM"] = [outline_width / 2.0, 0]
terminal_dict["TM"] = [outline_width / 2.0, outline_height]
terminal_dict["LL"] = [0, outline_height / 6.0]
terminal_dict["RL"] = [outline_width, outline_height / 6.0]
terminal_dict["BL"] = [outline_width / 6.0, 0.0]
terminal_dict["TL"] = [outline_width / 6.0, outline_height]
terminal_dict["LU"] = [0, outline_height * 5.0 / 6.0]
terminal_dict["RU"] = [outline_width, outline_height * 5.0 / 6.0]
terminal_dict["BU"] = [outline_width * 5.0 / 6.0, 0.0]
terminal_dict["TU"] = [outline_width * 5.0 / 6.0, outline_height]
i = 2
while i < len(content):
words = content[i].split()
if len(words) == 0:
break
else:
cluster_list.append(words[0])
cluster_lx_list.append(float(words[1]))
cluster_ly_list.append(float(words[2]))
cluster_ux_list.append(float(words[3]))
cluster_uy_list.append(float(words[4]))
cluster_dict[words[0]] = [
(float(words[1]) + float(words[3])) / 2.0,
(float(words[2]) + float(words[4])) / 2.0,
]
i = i + 1
i = i + 1
while i < len(content):
words = content[i].split()
macro_list.append(words[0])
macro_lx_list.append(float(words[1]))
macro_ly_list.append(float(words[2]))
macro_ux_list.append(float(words[3]))
macro_uy_list.append(float(words[4]))
i = i + 1
net_list = []
with open(net_file) as f:
content = f.read().splitlines()
f.close()
for line in content:
items = line.split()
if len(items) > 1:
source = items[1]
for j in range(2, len(items), 2):
target = items[j]
weight = float(items[j + 1])
net_list.append([source, target, weight])
plt.figure()
for i in range(len(cluster_list)):
rectangle = plt.Rectangle(
(cluster_lx_list[i], cluster_ly_list[i]),
cluster_ux_list[i] - cluster_lx_list[i],
cluster_uy_list[i] - cluster_ly_list[i],
fc="r",
ec="blue",
)
plt.gca().add_patch(rectangle)
for i in range(len(macro_list)):
rectangle = plt.Rectangle(
(macro_lx_list[i], macro_ly_list[i]),
macro_ux_list[i] - macro_lx_list[i],
macro_uy_list[i] - macro_ly_list[i],
fc="yellow",
ec="blue",
)
plt.gca().add_patch(rectangle)
for i in range(len(net_list)):
source = net_list[i][0]
target = net_list[i][1]
weight = net_list[i][2]
x = []
y = []
if source in cluster_dict:
x.append(cluster_dict[source][0])
y.append(cluster_dict[source][1])
else:
x.append(terminal_dict[source][0])
y.append(terminal_dict[source][1])
if target in cluster_list:
x.append(cluster_dict[target][0])
y.append(cluster_dict[target][1])
else:
x.append(terminal_dict[target][0])
y.append(terminal_dict[target][1])
if weight > net_threshold:
plt.plot(x, y, "k", lw=log(weight))
x = []
y = []
x.append(0)
y.append(0)
x.append(outline_width)
y.append(0)
plt.plot(x, y, "--k")
x = []
y = []
x.append(0)
y.append(0)
x.append(0)
y.append(outline_height)
plt.plot(x, y, "--k")
x = []
y = []
x.append(0)
y.append(outline_height)
x.append(outline_width)
y.append(outline_height)
plt.plot(x, y, "--k")
x = []
y = []
x.append(outline_width)
y.append(0)
x.append(outline_width)
y.append(outline_height)
plt.plot(x, y, "--k")
plt.xlim(0, outline_width)
plt.ylim(0, outline_height)
plt.axis("scaled")
plt.show()