Skip to content

Commit 4798cb0

Browse files
committed
util: bazel plot_congestion
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent dae95e0 commit 4798cb0

File tree

6 files changed

+52
-43
lines changed

6 files changed

+52
-43
lines changed

flow/BUILD.bazel

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@bazel-orfs//:openroad.bzl", "orfs_flow")
2-
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
32

43
filegroup(
54
name = "constraints-gcd",
@@ -250,9 +249,3 @@ filegroup(
250249
srcs = glob(include = ["designs/src/ethmac_lvt/*.v"]),
251250
visibility = [":__subpackages__"],
252251
)
253-
254-
compile_pip_requirements(
255-
name = "requirements",
256-
src = "util/requirements.in",
257-
requirements_txt = "util/requirements_lock.txt",
258-
)

flow/designs/asap7/ethmac_lvt/BUILD.bazel

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@bazel-orfs//:sweep.bzl", "orfs_sweep")
2-
load("@orfs-pip//:requirements.bzl", "requirement")
2+
load("//util:plot_congestion.bzl", "plot_congestion")
33

44
# Format densities, rounding to 2 decimal places.
55
SWEEPS = {
@@ -51,35 +51,9 @@ orfs_sweep(
5151
verilog_files = ["//:ethmac_lvt_src"],
5252
)
5353

54-
[filegroup(
55-
name = "ethmac_lvt_{value}_congestion".format(value = value),
56-
srcs = [":ethmac_lvt_{value}_grt".format(value = value)],
57-
output_group = "congestion.rpt",
58-
) for value in SWEEPS[SWEEP]]
59-
60-
filegroup(
61-
name = "congestion",
62-
srcs = [":ethmac_lvt_{value}_congestion".format(value = value) for value in SWEEPS[SWEEP]],
63-
)
64-
65-
py_binary(
66-
name = "plot_congestion",
67-
srcs = ["plot_congestion.py"],
68-
main = "plot_congestion.py",
69-
deps = [requirement("matplotlib")],
70-
)
71-
72-
genrule(
73-
name = "plot_pdf",
74-
srcs = [":congestion"],
75-
outs = ["congestion.pdf"],
76-
cmd = "$(execpath :plot_congestion) {value} $@ $(locations :congestion)".format(value = SWEEP),
77-
tools = [":plot_congestion"],
78-
)
79-
80-
sh_binary(
54+
plot_congestion(
8155
name = "plot",
82-
srcs = [":open_plots.sh"],
83-
args = ["$(location :plot_pdf)"],
84-
data = [":plot_pdf"],
56+
srcs = [":ethmac_lvt_{value}_grt".format(value = value) for value in SWEEPS[SWEEP]],
57+
argument = SWEEP,
58+
values = SWEEPS[SWEEP],
8559
)

flow/util/BUILD.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@orfs-pip//:requirements.bzl", "requirement")
2+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
3+
4+
exports_files(["open_plots.sh"])
5+
6+
py_binary(
7+
name = "plot_congestion",
8+
srcs = ["plot_congestion.py"],
9+
main = "plot_congestion.py",
10+
deps = [requirement("matplotlib")],
11+
visibility = ["//visibility:public"],
12+
)
13+
14+
compile_pip_requirements(
15+
name = "requirements",
16+
src = "requirements.in",
17+
requirements_txt = "requirements_lock.txt",
18+
)
File renamed without changes.

flow/util/plot_congestion.bzl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Plots congestion against some parameter such as PLACE_DENSITY"""
2+
3+
def plot_congestion(name, srcs, argument, values):
4+
native.filegroup(
5+
name = "{name}_congestion".format(name = name),
6+
srcs = srcs,
7+
output_group = "congestion.rpt",
8+
)
9+
10+
native.genrule(
11+
name = "{}_pdf".format(name),
12+
srcs = ["{name}_congestion".format(name = name)],
13+
outs = ["{}.pdf".format(name)],
14+
cmd = "$(execpath //util:plot_congestion) {argument} $@ $(locations :{name}_congestion) {values}".format(values = " ".join(values), argument = argument, name=name),
15+
tools = ["//util:plot_congestion"],
16+
)
17+
18+
native.sh_binary(
19+
name = name,
20+
srcs = ["//util:open_plots.sh"],
21+
args = ["$(location :{}.pdf)".format(name)],
22+
data = ["{}.pdf".format(name)],
23+
)

flow/designs/asap7/ethmac_lvt/plot_congestion.py renamed to flow/util/plot_congestion.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77

88
sweep = sys.argv[1]
99
output = sys.argv[2]
10-
files = sys.argv[3:]
10+
remainder = sys.argv[3:]
11+
files = remainder[:len(remainder) // 2]
12+
values = remainder[len(remainder) // 2:]
1113

1214
# count lines in each file and divide by 3 and create a list of those
1315
# numbers
1416
congestion = []
1517
for file in files:
1618
with open(file, "r") as f:
1719
lines = f.readlines()
18-
print(file)
19-
density = re.search(r"(\d+\.?\d+)", file).group(1)
20-
congestion.append((float(density), len(lines) // 4))
20+
congestion.append(len(lines) // 4)
2121

2222
# xy plot of density vs DRC errors
23-
x, y = zip(*congestion)
23+
x = list(map(float, values))
24+
y = congestion
2425
plt.plot(x, y, "o-")
2526
plt.xlabel(sweep)
2627
plt.ylabel("DRC Errors")

0 commit comments

Comments
 (0)