Skip to content

Commit f643236

Browse files
committed
asap7/ethmac_lvt: study placement densities and grt
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 6b38aee commit f643236

File tree

9 files changed

+2109
-5
lines changed

9 files changed

+2109
-5
lines changed

flow/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
12
load("@bazel-orfs//:openroad.bzl", "orfs_flow")
23

34
filegroup(
@@ -261,3 +262,15 @@ orfs_flow(
261262
},
262263
)
263264

265+
266+
filegroup(
267+
name = "ethmac_lvt_src",
268+
srcs = glob(include=["designs/src/ethmac_lvt/*.v"]),
269+
visibility = [":__subpackages__"],
270+
)
271+
272+
compile_pip_requirements(
273+
name = "requirements",
274+
src = "requirements.in",
275+
requirements_txt = "requirements_lock.txt",
276+
)

flow/MODULE.bazel

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""ORFS bazel setup."""
2+
13
module(
24
name = "orfs",
35
version = "0.0.1",
@@ -7,7 +9,7 @@ module(
79
bazel_dep(name = "bazel-orfs")
810
git_override(
911
module_name = "bazel-orfs",
10-
commit = "b12fc7a172d4211315ec36214f872595e084ab25",
12+
commit = "d30e1987275cb54163a4dfde421392c31d0a7148",
1113
remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
1214
)
1315

@@ -22,3 +24,40 @@ git_override(
2224
# module_name = "bazel-orfs", path = "../bazel-orfs"
2325
#)
2426

27+
28+
bazel_dep(name = "rules_python", version = "0.31.0")
29+
30+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
31+
python.toolchain(
32+
ignore_root_user_error = True,
33+
python_version = "3.12",
34+
)
35+
36+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
37+
pip.parse(
38+
hub_name = "orfs-pip",
39+
python_version = "3.12",
40+
requirements_lock = "//:requirements_lock.txt",
41+
)
42+
use_repo(pip, "orfs-pip")
43+
44+
45+
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
46+
orfs.default(
47+
# To build an ORFS image from a PR:
48+
# ./build_openroad.sh --latest
49+
#
50+
# Check out the PRs and modify the local repository as needed
51+
# ./build_openroad.sh --no_init
52+
#
53+
# docker tag docker.io/openroad/flow-ubuntu22.04-builder:c46d41 gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:c46d41
54+
# docker push gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:c46d41
55+
# image = "gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:c46d41",
56+
#
57+
# Official image https://hub.docker.com/r/openroad/orfs/tags
58+
image = "docker.io/openroad/orfs:v3.0-2130-g6b38aeeb",
59+
# image = "gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:3d2c3d-2",
60+
sha256 = "f5b573d244862bc59f858e2a3586c48aef70989e98f6541099bd15a720e28e7e",
61+
)
62+
use_repo(orfs, "com_github_nixos_patchelf_download")
63+
use_repo(orfs, "docker_orfs")

flow/MODULE.bazel.lock

Lines changed: 1410 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flow/cred_helper.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Returns information about user's GCP entitlements
4+
#
5+
# Usage: cred_helper.py [get|test]
6+
#
7+
# get prints the GCP auth token
8+
# test prints the user's GCP entitlements
9+
#
10+
# Calling script without arguments prints out usage information and then exits with a non-zero code (per spec)
11+
#
12+
13+
import subprocess
14+
import requests
15+
import json
16+
import re
17+
import sys
18+
19+
20+
def get_gcloud_auth_token(test):
21+
"""
22+
Returns the gcloud auth token based on the .user-bazelrc
23+
"""
24+
25+
with open(".user-bazelrc") as f:
26+
all = f.read()
27+
match = re.search(r"# user: (.*)", all)
28+
if match is None:
29+
sys.exit('Did not find username in .user-bazelrc file as "# user: <username>"')
30+
USER = match.group(1)
31+
32+
cmd = ["gcloud", "auth", "print-access-token", USER]
33+
if test:
34+
print("Running: " + subprocess.list2cmdline(cmd))
35+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
36+
token = result.stdout.strip()
37+
return token
38+
39+
40+
def generate_credentials(test):
41+
"""
42+
Generate the credentials in a form that Bazel wants, which is the
43+
Authorization key points to a list
44+
"""
45+
46+
bearer_token = get_gcloud_auth_token(test)
47+
48+
# Create the JSON object with the required format
49+
credentials = {"headers": {"Authorization": [f"Bearer {bearer_token}"]}}
50+
return credentials
51+
52+
53+
def test_permissions(credentials, bucket_name):
54+
"""
55+
Tests the user's entitlements for this bucket
56+
57+
Note that the call to check the permissions needs the Authorization key to
58+
point to a string and not a list. So, take the first element in the list
59+
and make it the only value
60+
"""
61+
62+
credentials["headers"]["Authorization"] = credentials["headers"]["Authorization"][0]
63+
url = (
64+
f"https://storage.googleapis.com/storage/v1/b/{bucket_name}/iam/testPermissions"
65+
)
66+
permissions = {"permissions": ["storage.buckets.get", "storage.objects.create"]}
67+
68+
response = requests.get(url, params=permissions, headers=credentials["headers"])
69+
response.raise_for_status()
70+
return response.json()
71+
72+
73+
def main():
74+
if (
75+
len(sys.argv) <= 1
76+
or (len(sys.argv) == 2 and sys.argv[1] not in ["get", "test"])
77+
or len(sys.argv) >= 3
78+
):
79+
sys.exit("Usage: python cred_helper.py [get|test]")
80+
test = sys.argv[1] == "test"
81+
82+
credentials = generate_credentials(test)
83+
if not test:
84+
print(json.dumps(credentials, indent=2))
85+
return
86+
87+
permissions = test_permissions(credentials, "megaboom-bazel-artifacts")
88+
89+
print(json.dumps(permissions, indent=2))
90+
91+
92+
if __name__ == "__main__":
93+
main()
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
load("@bazel-orfs//:sweep.bzl", "orfs_sweep")
2+
load("@orfs-pip//:requirements.bzl", "requirement")
3+
4+
# Format densities, rounding to 2 decimal places.
5+
PLACEMENT_DENSITIES = [str(0.60 + x * 0.01 + 0.005)[:4] for x in range(20)]
6+
#PLACEMENT_DENSITIES.remove("0.67")
7+
8+
orfs_sweep(
9+
name = "ethmac_lvt",
10+
arguments = {
11+
# Faster builds
12+
"SKIP_INCREMENTAL_REPAIR": "1",
13+
"GPL_TIMING_DRIVEN": "0",
14+
# Various
15+
"SDC_FILE": "$(location :constraint.sdc)",
16+
"ABC_AREA": "1",
17+
"CORE_UTILIZATION": "40",
18+
"CORE_ASPECT_RATIO": "1",
19+
"CORE_MARGIN": "2",
20+
"PLACE_DENSITY": "0.60",
21+
"ASAP7_USELVT": "1",
22+
"RECOVER_POWER": "1",
23+
"ADDITIONAL_LIBS": "$(LIB_DIR)/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz \
24+
$(LIB_DIR)/asap7sc7p5t_INVBUF_RVT_FF_nldm_220122.lib.gz \
25+
$(LIB_DIR)/asap7sc7p5t_OA_RVT_FF_nldm_211120.lib.gz \
26+
$(LIB_DIR)/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz \
27+
$(LIB_DIR)/asap7sc7p5t_SEQ_RVT_FF_nldm_220123.lib",
28+
"ADDITIONAL_GDS": "$(PLATFORM_DIR)/gds/asap7sc7p5t_28_R_220121a.gds",
29+
"ADDITIONAL_LEFS": "$(PLATFORM_DIR)/lef/asap7sc7p5t_28_R_1x_220121a.lef",
30+
},
31+
other_variants = {"base": {}},
32+
sources = {
33+
"SDC_FILE": [":constraint.sdc"],
34+
},
35+
sweep = {
36+
density: {
37+
"arguments": {
38+
"PLACE_DENSITY": density,
39+
},
40+
"previous_stage": {
41+
"floorplan": "ethmac_lvt_synth",
42+
},
43+
}
44+
for density in PLACEMENT_DENSITIES
45+
},
46+
top = "ethmac",
47+
verilog_files = ["//:ethmac_lvt_src"],
48+
)
49+
50+
[filegroup(
51+
name = "ethmac_lvt_{density}_congestion".format(density = density),
52+
srcs = [":ethmac_lvt_{density}_grt".format(density = density)],
53+
output_group = "congestion.rpt",
54+
) for density in PLACEMENT_DENSITIES]
55+
56+
filegroup(
57+
name = "congestion",
58+
srcs = [":ethmac_lvt_{density}_congestion".format(density = density) for density in PLACEMENT_DENSITIES],
59+
)
60+
61+
py_binary(
62+
name = "plot_congestion",
63+
srcs = ["plot_congestion.py"],
64+
main = "plot_congestion.py",
65+
deps = [requirement("matplotlib")],
66+
)
67+
68+
genrule(
69+
name = "plot_pdf",
70+
srcs = [":congestion"],
71+
outs = ["congestion.pdf"],
72+
cmd = "$(execpath :plot_congestion) $@ $(locations :congestion)",
73+
tools = [":plot_congestion"],
74+
)
75+
76+
sh_binary(
77+
name = "plot",
78+
srcs = [":open_plots.sh"],
79+
args = ["$(location :plot_pdf)"],
80+
data = [":plot_pdf"],
81+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
xdg-open $1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import matplotlib.pyplot as plt
2+
import numpy as np
3+
import sys
4+
import re
5+
import os
6+
7+
8+
output = sys.argv[1]
9+
files = sys.argv[2:]
10+
11+
# count lines in each file and divide by 3 and create a list of those
12+
# numbers
13+
congestion = []
14+
for file in files:
15+
with open(file, "r") as f:
16+
lines = f.readlines()
17+
print(file)
18+
density = re.search(r"(\d+\.\d+)", file).group(1)
19+
congestion.append((float(density), len(lines) // 4))
20+
21+
# xy plot of density vs DRC errors
22+
x, y = zip(*congestion)
23+
plt.plot(x, y, "o-")
24+
plt.xlabel("Density")
25+
plt.ylabel("DRC Errors")
26+
plt.title("Density vs DRC Errors")
27+
plt.grid()
28+
plt.yscale("log")
29+
plt.savefig(output)

flow/requirements.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
matplotlib==3.10.0
2+
PyYAML==6.0.2

0 commit comments

Comments
 (0)