Skip to content

Commit ad29f5e

Browse files
committed
Merge branch 'master' of https://github.com/The-OpenROAD-Project-private/OpenROAD-flow-scripts into secure-enable-kf-lec-check
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
2 parents fc4af09 + af26ce3 commit ad29f5e

11 files changed

Lines changed: 197 additions & 30 deletions

File tree

‎BUILD.bazel‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
2+
3+
sh_binary(
4+
name = "install_for_bazel",
5+
srcs = ["bazel/install.sh"],
6+
)

‎MODULE.bazel‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ git_override(
1616
)
1717

1818
bazel_dep(name = "rules_python", version = "1.2.0")
19+
bazel_dep(name = "rules_shell", version = "0.6.1")
1920

2021
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
2122
python.toolchain(

‎MODULE.bazel.lock‎

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bazel/install.sh‎

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# ORFS developer install script
5+
# Builds and installs OpenROAD, Yosys, and yosys-slang to tools/install/
6+
# where flow/Makefile expects them.
7+
#
8+
# Uses stamp files for fast no-op re-runs (seconds when nothing changed).
9+
10+
WORKSPACE="${BUILD_WORKSPACE_DIRECTORY:-.}"
11+
INSTALL_DIR="${WORKSPACE}/tools/install"
12+
NUM_THREADS=$(nproc)
13+
14+
# --- Check system dependencies for yosys/slang builds ---
15+
check_deps() {
16+
local missing_cmds=()
17+
18+
for cmd in bison flex gawk g++ pkg-config tclsh git cmake; do
19+
if ! command -v "$cmd" &>/dev/null; then
20+
missing_cmds+=("$cmd")
21+
fi
22+
done
23+
24+
if [[ ${#missing_cmds[@]} -eq 0 ]]; then
25+
return
26+
fi
27+
28+
echo "ERROR: Missing commands: ${missing_cmds[*]}"
29+
echo ""
30+
31+
# Platform-specific install hint
32+
if [[ "$(uname -s)" == "Darwin" ]]; then
33+
echo " brew install bison flex gawk cmake pkg-config tcl-tk"
34+
elif command -v apt-get &>/dev/null; then
35+
echo " sudo apt-get install bison flex gawk g++ pkg-config tcl cmake git"
36+
elif command -v dnf &>/dev/null; then
37+
echo " sudo dnf install bison flex gawk gcc-c++ pkgconf tcl cmake git"
38+
elif command -v yum &>/dev/null; then
39+
echo " sudo yum install bison flex gawk gcc-c++ pkgconf tcl cmake git"
40+
elif command -v zypper &>/dev/null; then
41+
echo " sudo zypper install bison flex gawk gcc-c++ pkg-config tcl cmake git"
42+
fi
43+
exit 1
44+
}
45+
46+
check_deps
47+
48+
BUILD_OPENROAD=1
49+
50+
usage() {
51+
cat <<'EOF'
52+
Usage: bazelisk run //:install_for_bazel [-- OPTIONS]
53+
54+
Options:
55+
--help, -h Show this help
56+
--skip-openroad Skip OpenROAD build
57+
--threads N Compilation threads (default: nproc)
58+
EOF
59+
exit 0
60+
}
61+
62+
while [[ $# -gt 0 ]]; do
63+
case "$1" in
64+
--help|-h)
65+
usage
66+
;;
67+
--skip-openroad)
68+
BUILD_OPENROAD=0
69+
;;
70+
--threads)
71+
NUM_THREADS="$2"
72+
shift
73+
;;
74+
*)
75+
echo "Unknown option: $1"
76+
usage
77+
;;
78+
esac
79+
shift
80+
done
81+
82+
# --- Check submodules are initialized ---
83+
for sub in tools/OpenROAD tools/yosys tools/yosys-slang; do
84+
if [[ ! -d "${WORKSPACE}/${sub}" ]] || [[ -z "$(ls -A "${WORKSPACE}/${sub}" 2>/dev/null)" ]]; then
85+
echo "ERROR: ${sub} not initialized."
86+
echo "Run: git submodule update --init --recursive"
87+
exit 1
88+
fi
89+
done
90+
91+
# --- OpenROAD (delegates to its own //:install) ---
92+
if [[ $BUILD_OPENROAD -eq 1 ]]; then
93+
echo "=== Building OpenROAD with GUI support ==="
94+
(cd "${WORKSPACE}/tools/OpenROAD" && bazelisk run --//:platform=gui //:install)
95+
fi
96+
97+
# --- Yosys ---
98+
# Uses stamp file for fast no-op: if the yosys submodule commit hasn't
99+
# changed, skip the build entirely.
100+
YOSYS_INSTALL="${INSTALL_DIR}/yosys"
101+
YOSYS_STAMP="${YOSYS_INSTALL}/.yosys_commit"
102+
YOSYS_COMMIT="$(git -C "${WORKSPACE}/tools/yosys" rev-parse HEAD)"
103+
104+
if [[ -f "${YOSYS_STAMP}" ]] && [[ "$(cat "${YOSYS_STAMP}")" == "${YOSYS_COMMIT}" ]]; then
105+
echo "=== Yosys already up to date (${YOSYS_COMMIT:0:12}) ==="
106+
else
107+
echo "=== Building Yosys ==="
108+
(
109+
cd "${WORKSPACE}/tools/yosys"
110+
make -j "${NUM_THREADS}" PREFIX="${YOSYS_INSTALL}" ABC_ARCHFLAGS=-Wno-register
111+
make install PREFIX="${YOSYS_INSTALL}"
112+
)
113+
echo "${YOSYS_COMMIT}" > "${YOSYS_STAMP}"
114+
echo "Yosys installed to ${YOSYS_INSTALL}/bin/yosys"
115+
fi
116+
117+
# --- yosys-slang ---
118+
SLANG_STAMP="${YOSYS_INSTALL}/.slang_commit"
119+
SLANG_COMMIT="$(git -C "${WORKSPACE}/tools/yosys-slang" rev-parse HEAD)"
120+
121+
if [[ -f "${SLANG_STAMP}" ]] && [[ "$(cat "${SLANG_STAMP}")" == "${SLANG_COMMIT}" ]]; then
122+
echo "=== yosys-slang already up to date (${SLANG_COMMIT:0:12}) ==="
123+
else
124+
echo "=== Building yosys-slang ==="
125+
(
126+
cd "${WORKSPACE}/tools/yosys-slang"
127+
cmake -S . -B build \
128+
-DYOSYS_CONFIG="${YOSYS_INSTALL}/bin/yosys-config" \
129+
-DCMAKE_BUILD_TYPE=Release \
130+
-DYOSYS_SLANG_REVISION=unknown \
131+
-DSLANG_REVISION=unknown
132+
cmake --build build -j "${NUM_THREADS}"
133+
cmake --install build --prefix "${YOSYS_INSTALL}"
134+
)
135+
echo "${SLANG_COMMIT}" > "${SLANG_STAMP}"
136+
echo "yosys-slang installed to ${YOSYS_INSTALL}/share/yosys/plugins/"
137+
fi
138+
139+
echo ""
140+
echo "=== Done ==="
141+
echo "cd flow && make"

‎docs/user/BuildLocally.md‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,20 @@ cd OpenROAD-flow-scripts
1212
sudo ./setup.sh
1313
```
1414

15-
## Using Bazel to build OpenROAD and run the ORFS flow
15+
## Using Bazel to build OpenROAD and run the ORFS flow (unsupported)
1616

17-
Long story short: OpenROAD will eventually switch to using Bazel for downloading dependencies and building OpenROAD for all the reasons that the DependencyInstaller.sh and cmake are hard to support and brittle across platforms.
18-
19-
Currently the simplest way to build OpenROAD and run ORFS is to run one test, which will download all OpenROAD dependencies and build OpenROAD in the exec configuration:
17+
For ORFS/OpenROAD developers. Most of `./setup.sh` isn't needed when
18+
building OpenROAD with Bazel — this provides the bare minimum to build
19+
OpenROAD and test ORFS flows. No sudo required.
20+
Install [Bazelisk](https://bazel.build/install/bazelisk) first.
2021

2122
``` shell
22-
cd tools/OpenROAD
23-
bazelisk test src/drt/...
24-
cd ../../flow
25-
make OPENROAD_EXE=$(pwd)/../tools/OpenROAD/bazel-out/k8-opt-exec-ST-*/bin/openroad
23+
git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts
24+
cd OpenROAD-flow-scripts
25+
bazelisk run //:install_for_bazel
26+
cd flow && make
2627
```
2728

28-
Bazel could similarly be used to download and make available pre-built binaries for tools such as Yosys, eqy and KLayout.
29-
30-
Running some quick tests will cause the desired exec config of OpenROAD to be built. There's no explicit Bazel way to build an exec config of an executable and we want to to use an exec config that is the same binary as is used for a local OpenROAD modify + test Bazel cycle.
31-
3229
## Build
3330

3431
``` shell

‎etc/DependencyInstaller.sh‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ fi
1111

1212
# package versions
1313
klayoutVersion=0.30.3
14-
numThreads=$(nproc)
14+
if [[ "$OSTYPE" == "darwin"* ]]; then
15+
numThreads=$(sysctl -n hw.ncpu)
16+
else
17+
numThreads=$(nproc)
18+
fi
1519

1620
_versionCompare() {
1721
local a b IFS=. ; set -f

‎flow/designs/rapidus2hp/cva6/rules-base.json‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@
1212
"compare": "<="
1313
},
1414
"placeopt__design__instance__count__stdcell": {
15-
"value": 194724,
15+
"value": 164719,
1616
"compare": "<="
1717
},
1818
"detailedplace__design__violations": {
1919
"value": 0,
2020
"compare": "=="
2121
},
2222
"cts__design__instance__count__setup_buffer": {
23-
"value": 14604,
23+
"value": 14323,
2424
"compare": "<="
2525
},
2626
"cts__design__instance__count__hold_buffer": {
27-
"value": 14604,
27+
"value": 14323,
2828
"compare": "<="
2929
},
3030
"cts__timing__setup__ws": {
31-
"value": -0.0943,
31+
"value": -0.14,
3232
"compare": ">="
3333
},
3434
"cts__timing__setup__tns": {
35-
"value": -135.0,
35+
"value": -168.0,
3636
"compare": ">="
3737
},
3838
"cts__timing__hold__ws": {
@@ -44,11 +44,11 @@
4444
"compare": ">="
4545
},
4646
"globalroute__antenna_diodes_count": {
47-
"value": 143,
47+
"value": 138,
4848
"compare": "<="
4949
},
5050
"globalroute__timing__setup__ws": {
51-
"value": -0.292,
51+
"value": -0.194,
5252
"compare": ">="
5353
},
5454
"globalroute__timing__setup__tns": {
@@ -64,7 +64,7 @@
6464
"compare": ">="
6565
},
6666
"finish__timing__setup__ws": {
67-
"value": -0.292,
67+
"value": -0.194,
6868
"compare": ">="
6969
},
7070
"finish__timing__setup__tns": {

‎flow/scripts/report_metrics.tcl‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ proc report_metrics { stage when { include_erc true } { include_clock_skew true
224224
report_puts "\n=========================================================================="
225225
report_puts "$when slack div critical path delay"
226226
report_puts "--------------------------------------------------------------------------"
227-
report_puts "[format "%4f" [expr $path_slack / $path_delay * 100]]"
227+
if { $path_delay != 0.0 } {
228+
report_puts "[format "%4f" [expr $path_slack / $path_delay * 100]]"
229+
} else {
230+
report_puts "N/A (0 delay)"
231+
}
228232
}
229233

230234
report_puts "\n=========================================================================="

‎flow/util/genReport.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def gen_report(name, data):
170170
args.verbose - 2,
171171
)
172172

173-
if len(d["drcs"].keys()) > 0:
173+
if len(data["drcs"].keys()) > 0:
174174
if data["status"] == STATUS_GREEN:
175175
output += " Design has the violations under the allowed limit: "
176176
else:

‎flow/util/write_segment_rc.tcl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
proc fetch_segments_rc { net_to_segments_var } {
44
upvar 1 $net_to_segments_var net_to_segments
55

6-
foreach sta_net [get_nets *] {
6+
foreach sta_net [get_nets -hierarchical *] {
77
set db_net [sta::sta_to_db_net $sta_net]
88
set type [$db_net getSigType]
99

@@ -69,7 +69,7 @@ proc write_segment_rc_csv { filename net_to_segments_var } {
6969
puts $stream ""
7070

7171
# Then, write the parasitics data of each wire segment.
72-
foreach sta_net [get_nets *] {
72+
foreach sta_net [get_nets -hierarchical *] {
7373
set net_name [get_full_name $sta_net]
7474

7575
if { ![info exists net_to_segments($net_name)] } {

0 commit comments

Comments
 (0)