Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: openroad hierarchical macro placer #537

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[mypy]
mypy_path = "./mypy_stubs"
exclude = venv|build|odbpy|scripts/klayout|docs|designs|setup.py|test|sandbox
exclude = venv|build|odbpy|scripts/klayout|scripts/pyosys|docs|designs|setup.py|test|sandbox
30 changes: 19 additions & 11 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
nix-gitignore,
# Tools
klayout,
klayout-pymod,
libparse,
magic-vlsi,
netgen,
Expand Down Expand Up @@ -57,6 +56,22 @@
ioplace-parser,
poetry-core,
}: let
yosys-env =
(yosys.withPlugins ([
yosys-sby
yosys-eqy
yosys-lighter
yosys-synlig-sv
yosys-f4pga-sdc
]
++ lib.optionals (builtins.elem system ["x86_64-linux" "x86_64-darwin"]) [yosys-ghdl]));
openroad-env =
(openroad.withPythonPackages(ps: with ps; [
click
rich
pyyaml
ioplace-parser
]));
self = buildPythonPackage {
pname = "openlane";
version = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).tool.poetry.version;
Expand All @@ -69,16 +84,9 @@
];

includedTools = [
(yosys.withPlugins ([
yosys-sby
yosys-eqy
yosys-lighter
yosys-synlig-sv
yosys-f4pga-sdc
]
++ lib.optionals (system == "x86_64-linux") [yosys-ghdl]))
yosys-env
opensta
openroad
openroad-env
klayout
netgen
magic-vlsi
Expand All @@ -104,7 +112,7 @@
deprecated
libparse
psutil
klayout-pymod
klayout.pymod
rapidfuzz
ioplace-parser
]
Expand Down
7 changes: 4 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
};

inputs = {
nix-eda.url = github:efabless/nix-eda;
nix-eda.url = github:efabless/nix-eda/python_cleanup;
libparse.url = github:efabless/libparse-python;
ioplace-parser.url = github:efabless/ioplace_parser;
volare.url = github:efabless/volare;
Expand Down Expand Up @@ -70,7 +70,9 @@
colab-env = callPackage ./nix/colab-env.nix {};
opensta = callPackage ./nix/opensta.nix {};
openroad-abc = callPackage ./nix/openroad-abc.nix {};
openroad = callPythonPackage ./nix/openroad.nix {};
openroad = callPythonPackage ./nix/openroad.nix {
inherit (nix-eda) buildPythonEnvForInterpreter;
};
openlane = callPythonPackage ./default.nix {};
sphinx-tippy = callPythonPackage ./nix/sphinx-tippy.nix {};
sphinx-subfigure = callPythonPackage ./nix/sphinx-subfigure.nix {};
Expand Down
51 changes: 25 additions & 26 deletions nix/openroad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
opensta,
boost183,
eigen,
cudd,
ninja,
tcl,
python3,
readline,
Expand All @@ -41,20 +43,12 @@
flex,
bison,
clang-tools_14,
ioplace-parser,
rev ? "b16bda7e82721d10566ff7e2b68f1ff0be9f9e38",
sha256 ? "sha256-+JGyX81Km2XidptA3k1Y5ZPwv+4Ed39LCsPfIHWd6ac=",
}: let
pyenv = python3.withPackages (p:
with p; [
click
rich
pyyaml
ioplace-parser
]);
pyenv-sitepackages = "${pyenv}/${pyenv.sitePackages}";
in
clangStdenv.mkDerivation (finalAttrs: {
buildEnv,
makeBinaryWrapper,
buildPythonEnvForInterpreter,
rev ? "6b5937db431d2fa1023d3865f21ccd9b65781492",
sha256 ? "sha256-rpv3WkOahFFkW4g+8tRiPBfBFcLwJIqK/hTgWv2tkow=",
}: let self = clangStdenv.mkDerivation (finalAttrs: {
name = "openroad";
inherit rev;

Expand All @@ -69,9 +63,7 @@ in
"-DTCL_LIBRARY=${tcl}/lib/libtcl${clangStdenv.hostPlatform.extensions.sharedLibrary}"
"-DTCL_HEADER=${tcl}/include/tcl.h"
"-DUSE_SYSTEM_BOOST:BOOL=ON"
"-DCMAKE_CXX_FLAGS=-I${openroad-abc}/include"
"-DENABLE_TESTS:BOOL=OFF"
"-DVERBOSE=1"
];

cmakeFlags =
Expand All @@ -80,25 +72,25 @@ in
"-DUSE_SYSTEM_ABC:BOOL=ON"
"-DUSE_SYSTEM_OPENSTA:BOOL=ON"
"-DOPENSTA_HOME=${opensta}"
"-DCMAKE_CXX_FLAGS=-I${eigen}/include/eigen3"
"-DABC_LIBRARY=${openroad-abc}/lib/libabc.a"
];

preConfigure = ''
sed -i "s/GITDIR-NOTFOUND/${rev}/" ./cmake/GetGitRevisionDescription.cmake
patchShebangs ./etc/find_messages.py

sed -i 's@#include "base/abc/abc.h"@#include <base/abc/abc.h>@' src/rmp/src/Restructure.cpp
sed -i 's@#include "base/main/abcapis.h"@#include <base/main/abcapis.h>@' src/rmp/src/Restructure.cpp

sed -i 's@# tclReadline@target_link_libraries(openroad readline)@' src/CMakeLists.txt
sed -i 's@%include "../../src/Exception.i"@%include "../../Exception.i"@' src/dbSta/src/dbSta.i
sed -i 's@''${TCL_LIBRARY}@''${TCL_LIBRARY}\n${cudd}/lib/libcudd.a@' src/CMakeLists.txt
'';

buildInputs = [
openroad-abc
boost183
eigen
cudd
tcl
pyenv
python3
readline
tclreadline
spdlog-internal-fmt
Expand All @@ -121,6 +113,7 @@ in
swig4
pkg-config
cmake
ninja
gnumake
flex
bison
Expand All @@ -131,10 +124,16 @@ in
shellHook = ''
export DEVSHELL_CMAKE_FLAGS="${builtins.concatStringsSep " " finalAttrs.cmakeFlagsAll}"
'';

qtWrapperArgs = [
"--prefix PYTHONPATH : ${pyenv-sitepackages}"
];

passthru = {
inherit python3;
withPythonPackages = buildPythonEnvForInterpreter {
target = self;
inherit lib;
inherit buildEnv;
inherit makeBinaryWrapper;
};
};

meta = with lib; {
description = "OpenROAD's unified application implementing an RTL-to-GDS flow";
Expand All @@ -144,4 +143,4 @@ in
license = licenses.gpl3Plus;
platforms = platforms.linux ++ platforms.darwin;
};
})
}); in self
8 changes: 6 additions & 2 deletions nix/opensta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
flex,
bison,
tcl,
tclreadline,
zlib,
cudd,
eigen,
rev ? "e01d3f163f483f233db00410b6515a767a6ca03b",
sha256 ? "sha256-0LbY5RcM+11oV3iPfAUd7hpyFPwCfCjnG0EE1LkXg5E=",
rev ? "aafee90f8a21bf7867cef2e159929440cf45b2e5",
sha256 ? "sha256-omFHcgUpZZfyA1vuF/6/cuAhG1ToSm0z35/dQ0QwUUc=",
}:
clangStdenv.mkDerivation (finalAttrs: {
name = "opensta";
Expand All @@ -46,6 +48,8 @@ clangStdenv.mkDerivation (finalAttrs: {
buildInputs = [
eigen
tcl
tclreadline
cudd
zlib
];

Expand Down
21 changes: 12 additions & 9 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ new: old: {
};
};

## Alligned alloc not available on the default SDK for x86_64-darwin (10.12!!)
or-tools = (old.or-tools.override {
stdenv = if old.stdenv.isDarwin then (old.overrideSDK old.stdenv "11.0") else old.stdenv;
}).overrideAttrs(finalAttrs: previousAttrs: {
# Based on https://github.com/google/or-tools/commit/af44f98dbeb905656b5a9fc664b5fdcffcbe1f60
# Stops CMake going haywire on reconfigures
postPatch = previousAttrs.postPatch + ''
sed -Ei.bak 's/(NOT\s+\w+_FOUND\s+AND\s+)+//' cmake/ortoolsConfig.cmake.in
sed -Ei.bak 's/NOT absl_FOUND/NOT TARGET absl::base/' cmake/ortoolsConfig.cmake.in
'';
});

# Platform-specific
## Undeclared Platform
clp =
Expand Down Expand Up @@ -48,13 +60,4 @@ new: old: {
stdenv = old.gccStdenv;
}
else (old.jshon);

## Alligned alloc not available on the default SDK for x86_64-darwin (10.12!!)
or-tools =
if old.system == "x86_64-darwin"
then
(old.or-tools.override {
stdenv = old.overrideSDK old.stdenv "11.0";
})
else (old.or-tools);
}
7 changes: 5 additions & 2 deletions openlane/config/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ def _prefix_to_wildcard(prefixes_raw: Union[str, Sequence[str]]):
Optional[List[str]],
"Sets estimated signal wire RC values to the average of these layers'. If you provide more than two, the averages are grouped by preferred routing direction and you must provide at least one layer for each routing direction. If unset, tools should use the average of layers between RT_MIN_LAYER and RT_MAX_LAYER. This variable will be moved to the relevant step(s) in the next version of OpenLane.",
pdk=True,
deprecated_names=["WIRE_RC_LAYER", "DATA_WIRE_RC_LAYER"],
deprecated_names=[
("WIRE_RC_LAYER", lambda x: [x]),
("DATA_WIRE_RC_LAYER", lambda x: [x]),
],
),
Variable(
"CLOCK_WIRE_RC_LAYERS",
Optional[List[str]],
"Sets estimated clock wire RC values to the average of these layers'. If you provide more than two, the averages are grouped by preferred routing direction and you must provide at least one layer for each routing direction. If unset, tools should use the average of layers between RT_MIN_LAYER and RT_MAX_LAYER. This variable will be moved to the relevant step(s) in the next version of OpenLane.",
pdk=True,
deprecated_names=["CLOCK_WIRE_RC_LAYER"],
deprecated_names=[("CLOCK_WIRE_RC_LAYER", lambda x: [x])],
),
Variable(
"DEFAULT_CORNER",
Expand Down
2 changes: 1 addition & 1 deletion openlane/config/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def evaluate(expression: str, symbols: Mapping[str, Any]) -> Decimal:
eval_stack.pop()
eval_stack.pop()

result = Decimal(0.0)
result = Decimal("0")
if token.value == "**":
result = number1**number2
elif token.value == "*":
Expand Down
10 changes: 6 additions & 4 deletions openlane/flows/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ class Classic(SequentialFlow):
OpenROAD.Floorplan,
Odb.CheckMacroAntennaProperties,
Odb.SetPowerConnections,
OpenROAD.GlobalPlacementSkipIO,
OpenROAD.IOPlacement,
OpenROAD.UnplaceAll,
Odb.CustomIOPlacement,
Odb.ApplyDEFTemplate,
Odb.ManualMacroPlacement,
OpenROAD.HierarchicalMacroPlacer,
OpenROAD.CutRows,
OpenROAD.TapEndcapInsertion,
Odb.AddPDNObstructions,
OpenROAD.GeneratePDN,
Odb.RemovePDNObstructions,
Odb.AddRoutingObstructions,
OpenROAD.GlobalPlacementSkipIO,
OpenROAD.IOPlacement,
Odb.CustomIOPlacement,
Odb.ApplyDEFTemplate,
OpenROAD.GlobalPlacement,
Odb.WriteVerilogHeader,
Checker.PowerGridViolations,
Expand Down
10 changes: 5 additions & 5 deletions openlane/flows/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ def resolve_step(matchable: Optional[str], multiple_ok: bool = False):

if to_resolved and to_resolved == step.id:
executing = False
if len(deferred_errors) != 0:
raise FlowError(
"One or more deferred errors were encountered:\n"
+ "\n".join(deferred_errors)
)

assert self.run_dir is not None
debug(f"Run concluded ▶ '{self.run_dir}'")
Expand All @@ -347,5 +342,10 @@ def resolve_step(matchable: Optional[str], multiple_ok: bool = False):
current_state.save_snapshot(final_views_path)
except Exception as e:
raise FlowException(f"Failed to save final views: {e}")
if len(deferred_errors) != 0:
raise FlowError(
"One or more deferred errors were encountered:\n"
+ "\n".join(deferred_errors)
)
success("Flow complete.")
return (current_state, step_list)
Loading
Loading