Skip to content

Commit

Permalink
asap7/ethmac_lvt: study placement densities and grt
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
  • Loading branch information
oharboe committed Jan 29, 2025
1 parent 6b38aee commit f643236
Show file tree
Hide file tree
Showing 9 changed files with 2,109 additions and 5 deletions.
13 changes: 13 additions & 0 deletions flow/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@bazel-orfs//:openroad.bzl", "orfs_flow")

filegroup(
Expand Down Expand Up @@ -261,3 +262,15 @@ orfs_flow(
},
)


filegroup(
name = "ethmac_lvt_src",
srcs = glob(include=["designs/src/ethmac_lvt/*.v"]),
visibility = [":__subpackages__"],
)

compile_pip_requirements(
name = "requirements",
src = "requirements.in",
requirements_txt = "requirements_lock.txt",
)
41 changes: 40 additions & 1 deletion flow/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""ORFS bazel setup."""

module(
name = "orfs",
version = "0.0.1",
Expand All @@ -7,7 +9,7 @@ module(
bazel_dep(name = "bazel-orfs")
git_override(
module_name = "bazel-orfs",
commit = "b12fc7a172d4211315ec36214f872595e084ab25",
commit = "d30e1987275cb54163a4dfde421392c31d0a7148",
remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
)

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


bazel_dep(name = "rules_python", version = "0.31.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
ignore_root_user_error = True,
python_version = "3.12",
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "orfs-pip",
python_version = "3.12",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "orfs-pip")


orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
orfs.default(
# To build an ORFS image from a PR:
# ./build_openroad.sh --latest
#
# Check out the PRs and modify the local repository as needed
# ./build_openroad.sh --no_init
#
# docker tag docker.io/openroad/flow-ubuntu22.04-builder:c46d41 gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:c46d41
# docker push gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:c46d41
# image = "gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:c46d41",
#
# Official image https://hub.docker.com/r/openroad/orfs/tags
image = "docker.io/openroad/orfs:v3.0-2130-g6b38aeeb",
# image = "gcr.io/ascenium/orfs-megaboom/flow-ubuntu22.04-builder:3d2c3d-2",
sha256 = "f5b573d244862bc59f858e2a3586c48aef70989e98f6541099bd15a720e28e7e",
)
use_repo(orfs, "com_github_nixos_patchelf_download")
use_repo(orfs, "docker_orfs")
1,414 changes: 1,410 additions & 4 deletions flow/MODULE.bazel.lock

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions flow/cred_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env python3
#
# Returns information about user's GCP entitlements
#
# Usage: cred_helper.py [get|test]
#
# get prints the GCP auth token
# test prints the user's GCP entitlements
#
# Calling script without arguments prints out usage information and then exits with a non-zero code (per spec)
#

import subprocess
import requests
import json
import re
import sys


def get_gcloud_auth_token(test):
"""
Returns the gcloud auth token based on the .user-bazelrc
"""

with open(".user-bazelrc") as f:
all = f.read()
match = re.search(r"# user: (.*)", all)
if match is None:
sys.exit('Did not find username in .user-bazelrc file as "# user: <username>"')
USER = match.group(1)

cmd = ["gcloud", "auth", "print-access-token", USER]
if test:
print("Running: " + subprocess.list2cmdline(cmd))
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
token = result.stdout.strip()
return token


def generate_credentials(test):
"""
Generate the credentials in a form that Bazel wants, which is the
Authorization key points to a list
"""

bearer_token = get_gcloud_auth_token(test)

# Create the JSON object with the required format
credentials = {"headers": {"Authorization": [f"Bearer {bearer_token}"]}}
return credentials


def test_permissions(credentials, bucket_name):
"""
Tests the user's entitlements for this bucket
Note that the call to check the permissions needs the Authorization key to
point to a string and not a list. So, take the first element in the list
and make it the only value
"""

credentials["headers"]["Authorization"] = credentials["headers"]["Authorization"][0]
url = (
f"https://storage.googleapis.com/storage/v1/b/{bucket_name}/iam/testPermissions"
)
permissions = {"permissions": ["storage.buckets.get", "storage.objects.create"]}

response = requests.get(url, params=permissions, headers=credentials["headers"])
response.raise_for_status()
return response.json()


def main():
if (
len(sys.argv) <= 1
or (len(sys.argv) == 2 and sys.argv[1] not in ["get", "test"])
or len(sys.argv) >= 3
):
sys.exit("Usage: python cred_helper.py [get|test]")
test = sys.argv[1] == "test"

credentials = generate_credentials(test)
if not test:
print(json.dumps(credentials, indent=2))
return

permissions = test_permissions(credentials, "megaboom-bazel-artifacts")

print(json.dumps(permissions, indent=2))


if __name__ == "__main__":
main()
81 changes: 81 additions & 0 deletions flow/designs/asap7/ethmac_lvt/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
load("@bazel-orfs//:sweep.bzl", "orfs_sweep")
load("@orfs-pip//:requirements.bzl", "requirement")

# Format densities, rounding to 2 decimal places.
PLACEMENT_DENSITIES = [str(0.60 + x * 0.01 + 0.005)[:4] for x in range(20)]
#PLACEMENT_DENSITIES.remove("0.67")

orfs_sweep(
name = "ethmac_lvt",
arguments = {
# Faster builds
"SKIP_INCREMENTAL_REPAIR": "1",
"GPL_TIMING_DRIVEN": "0",
# Various
"SDC_FILE": "$(location :constraint.sdc)",
"ABC_AREA": "1",
"CORE_UTILIZATION": "40",
"CORE_ASPECT_RATIO": "1",
"CORE_MARGIN": "2",
"PLACE_DENSITY": "0.60",
"ASAP7_USELVT": "1",
"RECOVER_POWER": "1",
"ADDITIONAL_LIBS": "$(LIB_DIR)/asap7sc7p5t_AO_RVT_FF_nldm_211120.lib.gz \
$(LIB_DIR)/asap7sc7p5t_INVBUF_RVT_FF_nldm_220122.lib.gz \
$(LIB_DIR)/asap7sc7p5t_OA_RVT_FF_nldm_211120.lib.gz \
$(LIB_DIR)/asap7sc7p5t_SIMPLE_RVT_FF_nldm_211120.lib.gz \
$(LIB_DIR)/asap7sc7p5t_SEQ_RVT_FF_nldm_220123.lib",
"ADDITIONAL_GDS": "$(PLATFORM_DIR)/gds/asap7sc7p5t_28_R_220121a.gds",
"ADDITIONAL_LEFS": "$(PLATFORM_DIR)/lef/asap7sc7p5t_28_R_1x_220121a.lef",
},
other_variants = {"base": {}},
sources = {
"SDC_FILE": [":constraint.sdc"],
},
sweep = {
density: {
"arguments": {
"PLACE_DENSITY": density,
},
"previous_stage": {
"floorplan": "ethmac_lvt_synth",
},
}
for density in PLACEMENT_DENSITIES
},
top = "ethmac",
verilog_files = ["//:ethmac_lvt_src"],
)

[filegroup(
name = "ethmac_lvt_{density}_congestion".format(density = density),
srcs = [":ethmac_lvt_{density}_grt".format(density = density)],
output_group = "congestion.rpt",
) for density in PLACEMENT_DENSITIES]

filegroup(
name = "congestion",
srcs = [":ethmac_lvt_{density}_congestion".format(density = density) for density in PLACEMENT_DENSITIES],
)

py_binary(
name = "plot_congestion",
srcs = ["plot_congestion.py"],
main = "plot_congestion.py",
deps = [requirement("matplotlib")],
)

genrule(
name = "plot_pdf",
srcs = [":congestion"],
outs = ["congestion.pdf"],
cmd = "$(execpath :plot_congestion) $@ $(locations :congestion)",
tools = [":plot_congestion"],
)

sh_binary(
name = "plot",
srcs = [":open_plots.sh"],
args = ["$(location :plot_pdf)"],
data = [":plot_pdf"],
)
2 changes: 2 additions & 0 deletions flow/designs/asap7/ethmac_lvt/open_plots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
xdg-open $1
29 changes: 29 additions & 0 deletions flow/designs/asap7/ethmac_lvt/plot_congestion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import matplotlib.pyplot as plt
import numpy as np
import sys
import re
import os


output = sys.argv[1]
files = sys.argv[2:]

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

# xy plot of density vs DRC errors
x, y = zip(*congestion)
plt.plot(x, y, "o-")
plt.xlabel("Density")
plt.ylabel("DRC Errors")
plt.title("Density vs DRC Errors")
plt.grid()
plt.yscale("log")
plt.savefig(output)
2 changes: 2 additions & 0 deletions flow/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
matplotlib==3.10.0
PyYAML==6.0.2
Loading

0 comments on commit f643236

Please sign in to comment.