Skip to content

Commit

Permalink
Merge branch 'The-OpenROAD-Project:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xtofalex authored Sep 11, 2024
2 parents f003cf9 + d012f05 commit 056875a
Show file tree
Hide file tree
Showing 24 changed files with 674 additions and 110 deletions.
60 changes: 60 additions & 0 deletions bazel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# OpenROAD-flow-scripts and Bazel integration

`bazel-orfs` is a Bazel package containing the definitions and logic governing the build process of ORFS designs.
The module uses the `openroad/orfs` docker image to extract the flow scripts with dependencies, builds the Bazel environment around them and defines the methods of calling the ORFS Makefiles with selected designs.

## Run examples

`flow/BUILD.bazel` contains definitions for various flows to serve as examples.

It is recommended to run the utility [Bazelisk](https://github.com/bazelbuild/bazelisk) to manage the version of `bazel` installed on the system.
Details on installation can be found in the `bazel-orfs` [README](https://github.com/The-OpenROAD-Project/bazel-orfs?tab=readme-ov-file#requirements)

The flow can be ran with the following call structure:

```bash
bazel build <target_name>_<stage_name>
```

For example, to run the stage `final`, along with all the dependent stages, call:
```bash
bazel build gcd_final
```

Details on usage and defining of the flows are presented in the Usage section of the `bazel-orfs` [README](https://github.com/The-OpenROAD-Project/bazel-orfs?tab=readme-ov-file#usage)

## Dependency version management

In the flow scipts, the `bazel-orfs` version is defined as

```starlark
bazel_dep(name = "bazel-orfs")
git_override(
module_name = "bazel-orfs",
commit = "<Hash of the default bazel-orfs commit>",
remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
)
```
However, as the referenced documentation shows, the git-based dependency can be overridden with a local repository.
First, remove the `git_override` call entirely and replace it with a `local_path_override` call following this convention:

```starlark
local_path_override(
module_name = "bazel-orfs",
path = "/replace/with/path/to/local/orfs/repository"
)
```

`bazel-orfs` sets a default version of the docker image used to create the Bazel environment.
This selection can be overridden by a following snippet inserted below the `bazel-orfs` declaration and override.

```starlark
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
orfs.default(
image = "tag-name",
sha256 = "the-hash",
)
```

Substitute `tag-name` with the tag of the version needed and `the-hash` with the digest corresponding to the selected tag (without the `sha256:` prefix).

31 changes: 23 additions & 8 deletions etc/DependencyInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ _installUbuntuPackages() {
zlib1g-dev

# install KLayout
if _versionCompare $1 -ge 23.04; then
if [[ $1 == "rodete" || $(_versionCompare "$1") -ge 23.04 ]]; then
apt-get -y install --no-install-recommends klayout python3-pandas
else
arch=$(uname -m)
Expand Down Expand Up @@ -160,6 +160,14 @@ _installUbuntuPackages() {
rm -rf "${baseDir}"
fi

if command -v docker &> /dev/null; then
# The user can uninstall docker if they want to reinstall it,
# and also this allows the user to choose drop in replacements
# for docker, such as podman-docker
echo "Docker is already installed, skip docker reinstall."
return 0
fi

# Add Docker's official GPG key:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
Expand All @@ -172,11 +180,13 @@ _installUbuntuPackages() {
tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get -y update
apt-get -y install --no-install-recommends \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin
if [[ $1 != "rodete" ]]; then
apt-get -y install --no-install-recommends \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin
fi
}

_installDarwinPackages() {
Expand Down Expand Up @@ -315,8 +325,11 @@ case "${os}" in
_installCommon
fi
;;
"Ubuntu" )
"Ubuntu" | "Debian GNU/Linux rodete" )
version=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g')
if [[ -z ${version} ]]; then
version=$(awk -F= '/^VERSION_CODENAME/{print $2}' /etc/os-release | sed 's/"//g')
fi
if [[ ${CI} == "yes" ]]; then
echo "Installing CI Tools"
_installCI
Expand All @@ -327,7 +340,9 @@ case "${os}" in
_installUbuntuCleanUp
fi
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
if _versionCompare ${version} -lt 23.04 ; then
if [[ $version == "rodete" ]]; then
echo "Skip common for rodete"
elif _versionCompare ${version} -lt 23.04 ; then
_installCommon
fi
fi
Expand Down
2 changes: 2 additions & 0 deletions flow/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build --incompatible_strict_action_env
try-import %workspace%/.user-bazelrc
1 change: 1 addition & 0 deletions flow/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.2.1
265 changes: 265 additions & 0 deletions flow/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
load("@bazel-orfs//:openroad.bzl", "orfs_flow")

filegroup(
name = "constraints-gcd",
srcs = [
"designs/asap7/gcd/constraint.sdc",
],
visibility = [":__subpackages__"],
)

orfs_flow(
name = "gcd",
stage_args = {
"synth": {
"SDC_FILE": "$(location :constraints-gcd)",
},
"floorplan": {
"DIE_AREA": "0 0 16.2 16.2",
"CORE_AREA": "1.08 1.08 15.12 15.12",
},
"place": {
"PLACE_DENSITY": "0.35",
},
},
stage_sources = {
"synth": [":constraints-gcd"],
},
verilog_files = glob(include=["designs/src/gcd/*.v"]),
)


filegroup(
name = "constraints-swerv",
srcs = [
"designs/asap7/swerv_wrapper/constraint.sdc",
],
visibility = [":__subpackages__"],
)

filegroup(
name = "swerv-fastroute",
srcs = [
"designs/asap7/swerv_wrapper/fastroute.tcl",
],
visibility = [":__subpackages__"],
)

filegroup(
name = "additional_lefs",
srcs = glob(include=["designs/asap7/swerv_wrapper/lef/*.lef"])
)
filegroup(
name = "additional_libs",
srcs = glob(include=["designs/asap7/swerv_wrapper/lib/*.lib"])
)

SWERV_ALL = {
"LIB_MODEL":"CCS",
"ADDITIONAL_LEFS": "$(locations :additional_lefs)",
"ADDITIONAL_LIBS": "$(locations :additional_libs)",
}

all_sources = [":additional_lefs", ":additional_libs"]

orfs_flow(
name = "swerv_wrapper",
stage_args = {
"synth": SWERV_ALL | {
"SYNTH_HIERARCHICAL": "1",
"SDC_FILE": "$(location :constraints-swerv)",
},
"floorplan": SWERV_ALL | {
"RTLMP_FLOW": "1",
"RTLMP_MAX_INST": "30000",
"RTLMP_MIN_INST": "5000",
"RTLMP_MAX_MACRO": "30",
"RTLMP_MIN_MACRO": "4",
"DIE_AREA": "0 0 550 600",
"CORE_AREA": "5 5 545 595",
"PLACE_PINS_ARGS": "-exclude left:* -exclude right:*"
},
"place": SWERV_ALL | {
"PLACE_PINS_ARGS": "-exclude left:* -exclude right:*",
"PLACE_DENSITY_LB_ADDON": "0.20",
},
"cts": SWERV_ALL | {
"TNS_END_PERCENT": "100",
},
"route": SWERV_ALL | {
"FASTROUTE_TCL": "$(location :swerv-fastroute)",
},
"final": SWERV_ALL | {
"PWR_NETS_VOLTAGEsS": "",
"GND_NETS_VOLTAGES": "",
}
},
verilog_files = glob(include=[
"designs/src/swerv/swerv_wrapper.sv2v.v",
"designs/asap7/swerv_wrapper/macros.v"
]),
stage_sources = {
"synth": all_sources + [":constraints-swerv"],
"floorplan": all_sources,
"place": all_sources,
"cts": all_sources,
"route": all_sources + [":swerv-fastroute"],
"final": all_sources,
},
)


filegroup(
name = "mock-array-constraints",
srcs = [
"designs/asap7/mock-array/constraints.sdc",
],
visibility = [":__subpackages__"],
)

filegroup(
name = "mock-array-io",
srcs = [
"designs/asap7/mock-array/io.tcl"
],
data = [
"designs/src/mock-array/util.tcl",
],
visibility = [":__subpackages__"],
)

filegroup(
name = "mock-array-fastroute",
srcs = [
"designs/asap7/mock-array/fastroute.tcl",
],
visibility = [":__subpackages__"],
)

MOCK_ARRAY_FLOORPLAN_PLACE = {
"PLACE_PINS_ARGS": "-annealing",
"IO_CONSTRAINTS": "$(location :mock-array-io)",
"PLACE_DENSITY": "0.30",
"DIE_AREA": "0 0 358.56 388.8",
"CORE_AREA": "2.16 2.16 356.40000000000003 386.64000000000004",
"MACRO_PLACE_HALO": "0 2.16",
"RTLMP_BOUNDARY_WT": "0",
"RTLMP_FLOW": "1",
"PDN_TCL": "$(PLATFORM_DIR)/openRoad/pdn/BLOCKS_grid_strategy.tcl",
"MACRO_HALO_X": "0.5",
"MACRO_HALO_Y": "0.5",
"MACRO_BLOCKAGE_HALO": "0",
"ADDITIONAL_FILES": "$(locations :mock-array-io)",
}

orfs_flow(
name = "MockArray",
macros = ["Element_generate_abstract"],
stage_args = {
"synth": {
"SDC_FILE": "$(location :mock-array-constraints)",
},
"floorplan": MOCK_ARRAY_FLOORPLAN_PLACE | {
},
"place": MOCK_ARRAY_FLOORPLAN_PLACE | {
},
"cts": {
"CTS_BUF_DISTANCE": "60"
},
"route": {
"FASTROUTE_TCL": "$(location :mock-array-fastroute)",
# works with 28 or more iterations as of writing, so give it a few more.
"GLOBAL_ROUTE_ARGS" : "-congestion_iterations 40 -verbose",
# If this design isn't quickly done in detailed routing, something is wrong.
# At time of adding this option, only 12 iterations were needed for 0
# violations.
"DETAILED_ROUTE_ARGS": "-bottom_routing_layer M2 -top_routing_layer M7 -save_guide_updates -verbose 1 -droute_end_iter 15",
# since we are specifying DETAILED_ROUTE_ARGS, we need to communicate the
# same information to other stages in the flow.
"MIN_ROUTING_LAYER": "M2",
"MAX_ROUTING_LAYER": "M7",
},
"final": {
"GDS_ALLOW_EMPTY": "Element",
"PWR_NETS_VOLTAGEsS": "",
"GND_NETS_VOLTAGES": "",
}
},
verilog_files = glob(include=["designs/src/mock-array/*.v"]),
stage_sources = {
"synth": all_sources + [":mock-array-constraints"] + [":mock-array-io"],
"floorplan": all_sources + [":mock-array-io"],
"place": all_sources + [":mock-array-io"],
"cts": all_sources,
"route": all_sources + [":mock-array-fastroute"],
"final": all_sources,
},
)


filegroup(
name = "mock-array-element-io",
srcs = [
"designs/asap7/mock-array/Element/io.tcl"
],
data = [
"designs/src/mock-array/util.tcl",
],
visibility = [":__subpackages__"],
)

MOCK_ARRAY_ELEMENT_FLOORPLAN_PLACE = {
"IO_CONSTRAINTS": "$(location :mock-array-element-io)",
"PLACE_DENSITY": "0.50",
"PLACE_PINS_ARGS": "-annealing",
}

MOCK_ARRAY_ELEMENT_ALL = {
"MOCK_ARRAY_ROWS" : "8",
"MOCK_ARRAY_COLS" : "8",
}

mock_array_all_sources = ["designs/src/mock-array/util.tcl"]

orfs_flow(
name = "Element",
abstract_stage = "route",
stage_args = {
"synth": MOCK_ARRAY_ELEMENT_ALL | {
"SDC_FILE": "$(location :mock-array-constraints)",
},
"floorplan": MOCK_ARRAY_ELEMENT_ALL | MOCK_ARRAY_ELEMENT_FLOORPLAN_PLACE | {
"DIE_AREA": "0 0 43.2 43.2",
"CORE_AREA": "1.08 1.08 42.120000000000005 42.120000000000005",
"PDN_TCL": "$(PLATFORM_DIR)/openRoad/pdn/BLOCK_grid_strategy.tcl",
},
"place": MOCK_ARRAY_ELEMENT_ALL | MOCK_ARRAY_ELEMENT_FLOORPLAN_PLACE | {
},
"cts": MOCK_ARRAY_ELEMENT_ALL | {
},
"route": MOCK_ARRAY_ELEMENT_ALL | {
# If this design isn't quickly done in detailed routing, something is wrong.
# At time of adding this option, only 3 iterations were needed for 0
# violations.
"DETAILED_ROUTE_ARGS": "-bottom_routing_layer M2 -top_routing_layer M5 -save_guide_updates -verbose 1 -droute_end_iter 10",
# since we are specifying DETAILED_ROUTE_ARGS, we need to communicate the
# same information to other stages in the flow.
"MIN_ROUTING_LAYER": "M2",
"MAX_ROUTING_LAYER": "M5",
},
"final": MOCK_ARRAY_ELEMENT_ALL | {
"PWR_NETS_VOLTAGES": "",
"GND_NETS_VOLTAGES": "",
}
},
verilog_files = glob(include=["designs/src/mock-array/*.v"]),
stage_sources = {
"synth": mock_array_all_sources + [":mock-array-constraints"],
"floorplan": mock_array_all_sources + [":mock-array-element-io"],
"place": mock_array_all_sources + [":mock-array-element-io"],
"cts": mock_array_all_sources,
"route": mock_array_all_sources + [":mock-array-fastroute"],
"final": mock_array_all_sources,
},
)

Loading

0 comments on commit 056875a

Please sign in to comment.