Skip to content

Commit 5c75714

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

File tree

9 files changed

+2114
-5
lines changed

9 files changed

+2114
-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: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
SWEEPS = {
6+
"PLACE_DENSITY": [str(0.60 + x * 0.01 + 0.005)[:4] for x in range(20)],
7+
"CORE_UTILIZATION": [str(40 + x * 5) for x in range(4)],
8+
}
9+
10+
SWEEP = "PLACE_DENSITY"
11+
12+
orfs_sweep(
13+
name = "ethmac_lvt",
14+
arguments = {
15+
# Faster builds
16+
"SKIP_INCREMENTAL_REPAIR": "1",
17+
"GPL_TIMING_DRIVEN": "0",
18+
# Various
19+
"SDC_FILE": "$(location :constraint.sdc)",
20+
"ABC_AREA": "1",
21+
"CORE_UTILIZATION": "40",
22+
"CORE_ASPECT_RATIO": "1",
23+
"CORE_MARGIN": "2",
24+
"PLACE_DENSITY": "0.60",
25+
"ASAP7_USELVT": "1",
26+
"RECOVER_POWER": "1",
27+
"ADDITIONAL_LIBS": "$(LIB_DIR)/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz \
28+
$(LIB_DIR)/asap7sc7p5t_INVBUF_RVT_FF_nldm_220122.lib.gz \
29+
$(LIB_DIR)/asap7sc7p5t_OA_RVT_FF_nldm_211120.lib.gz \
30+
$(LIB_DIR)/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz \
31+
$(LIB_DIR)/asap7sc7p5t_SEQ_RVT_FF_nldm_220123.lib",
32+
"ADDITIONAL_GDS": "$(PLATFORM_DIR)/gds/asap7sc7p5t_28_R_220121a.gds",
33+
"ADDITIONAL_LEFS": "$(PLATFORM_DIR)/lef/asap7sc7p5t_28_R_1x_220121a.lef",
34+
},
35+
other_variants = {"base": {}},
36+
sources = {
37+
"SDC_FILE": [":constraint.sdc"],
38+
},
39+
sweep = {
40+
value: {
41+
"arguments": {
42+
SWEEP: value,
43+
},
44+
"previous_stage": {
45+
"floorplan": "ethmac_lvt_synth",
46+
},
47+
}
48+
for value in SWEEPS[SWEEP]
49+
},
50+
top = "ethmac",
51+
verilog_files = ["//:ethmac_lvt_src"],
52+
)
53+
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(
81+
name = "plot",
82+
srcs = [":open_plots.sh"],
83+
args = ["$(location :plot_pdf)"],
84+
data = [":plot_pdf"],
85+
)
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import matplotlib.pyplot as plt
2+
import numpy as np
3+
import sys
4+
import re
5+
import os
6+
7+
8+
sweep = sys.argv[1]
9+
output = sys.argv[2]
10+
files = sys.argv[3:]
11+
12+
# count lines in each file and divide by 3 and create a list of those
13+
# numbers
14+
congestion = []
15+
for file in files:
16+
with open(file, "r") as f:
17+
lines = f.readlines()
18+
print(file)
19+
density = re.search(r"(\d+\.?\d+)", file).group(1)
20+
congestion.append((float(density), len(lines) // 4))
21+
22+
# xy plot of density vs DRC errors
23+
x, y = zip(*congestion)
24+
plt.plot(x, y, "o-")
25+
plt.xlabel(sweep)
26+
plt.ylabel("DRC Errors")
27+
plt.title(sweep + " vs DRC Errors")
28+
plt.grid()
29+
plt.yscale("log")
30+
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)