Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 109 additions & 12 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,79 @@ bazel_dep(name = "rules_shell", version = "0.6.1")
# our MODULE.bazel doesn't need to be patched at non-root consumption
# time.

bazel_dep(name = "toolchains_llvm", version = "1.5.0", dev_dependency = True)
# Hermetic zero-sysroot LLVM toolchain (hermetic-llvm, BCR module "llvm"):
# statically linked LLVM binaries and a cc_toolchain with no host compiler,
# linker, headers or libraries involved. Mirrors tools/OpenROAD (which marks
# it dev_dependency and documents that root modules bring their own C++
# toolchain).
bazel_dep(name = "llvm", version = "0.8.11", dev_dependency = True)
bazel_dep(name = "openroad", dev_dependency = True)
local_path_override(
module_name = "openroad",
path = "tools/OpenROAD",
)

# single_version_override is only honored in the root module, so the
# fixes tools/OpenROAD carries for its own root builds must be mirrored
# here. The patch files are copied into //patches/openroad-deps because
# override patches must live in the main repository (see the comments in
# tools/OpenROAD/MODULE.bazel for each):
# - abc: flush prompt/handle EOF without readline (yosys coprocess hang)
# - bison: gnulib wrapper-header precedence under hermetic-llvm
# - boost.icl: interval_set subtraction bug (boostorg/icl#54)
# - gawk: libc-header shadowing fix release
# - tcl_lang: tclZipfs crypt.h include under zero-sysroot toolchain
single_version_override(
module_name = "abc",
patch_strip = 1,
patches = [
"//patches/openroad-deps:0001-mainUtils-flush-prompt-and-handle-eof-without-readline.patch",
],
)

single_version_override(
module_name = "bison",
patch_strip = 1,
patches = [
"//patches/openroad-deps:0001-gnulib-wrapper-headers-use-I-not-isystem.patch",
],
version = "3.8.2.bcr.7",
)

single_version_override(
module_name = "boost.icl",
patch_strip = 1,
patches = [
"//patches/openroad-deps:0001-refactor-interval-lookup-operations-icl-54.patch",
],
)

single_version_override(
module_name = "gawk",
version = "5.3.2.bcr.7",
)

# m4 and sed: same gnulib libc-header shadowing class as gawk/bison
# under hermetic-llvm (BCR #7642); these releases carry the fixes
# (sed via BCR #7915).
single_version_override(
module_name = "m4",
version = "1.4.21.bcr.4",
)

single_version_override(
module_name = "sed",
version = "4.9.bcr.5",
)

single_version_override(
module_name = "tcl_lang",
patch_strip = 1,
patches = [
"//patches/openroad-deps:0001-tclZipfs-include-vendored-minizip-crypt.h-by-path.patch",
],
)

bazel_dep(name = "qt-bazel", dev_dependency = True)
git_override(
module_name = "qt-bazel",
Expand All @@ -36,7 +102,7 @@ git_override(
bazel_dep(name = "bazel-orfs", dev_dependency = True)
bazel_dep(name = "bazel-orfs-verilog", dev_dependency = True)

BAZEL_ORFS_COMMIT = "3a5ddd7eb48c363717e65903ae4573d528327fd3"
BAZEL_ORFS_COMMIT = "970ff81f19dc602b44bb017f97dcdbc70f58fd89"

BAZEL_ORFS_REMOTE = "https://github.com/The-OpenROAD-Project/bazel-orfs.git"

Expand All @@ -51,7 +117,8 @@ git_override(
commit = BAZEL_ORFS_COMMIT,
patch_strip = 1,
patches = [
"//patches/bazel-orfs:0001-render_gds-monkey-patch-PDK_CONFIGS-not-gdsii_use_custom_config.patch",
"//patches/bazel-orfs:0002-add-orfs_openroad_synth-rule-and-macro.patch",
"//patches/bazel-orfs:0003-add-orfs_canon_verilog-rule.patch",
],
remote = BAZEL_ORFS_REMOTE,
)
Expand All @@ -63,6 +130,32 @@ git_override(
strip_prefix = "verilog",
)

# LEC (logic equivalence checking) rules wrapping kepler-formal. The
# expansion patch (build-time lec_check + instant status test + stage
# netlist extraction) is carried here until upstreamed to bazel-orfs.
bazel_dep(name = "bazel-orfs-lec", dev_dependency = True)
git_override(
module_name = "bazel-orfs-lec",
commit = BAZEL_ORFS_COMMIT,
patch_strip = 1,
patches = [
"//patches/bazel-orfs:lec-0001-build-time-lec-check-and-netlist-extraction.patch",
],
remote = BAZEL_ORFS_REMOTE,
strip_prefix = "lec",
)

# kepler-formal is not on BCR yet (see its docs/bcr-roadmap.md). The lec
# module's own kepler-formal override points at a CI mock and is a no-op
# when it is not the root module, so the real, hermetically built (llvm
# zero-sysroot toolchain) kepler-formal is pinned here.
bazel_dep(name = "kepler-formal", dev_dependency = True)
git_override(
module_name = "kepler-formal",
commit = "6af0212097e737a2d843eedd524023f49bd77945",
remote = "https://github.com/keplertech/kepler-formal.git",
)

# yosys-slang is not on BCR. Pin to a commit on povik/yosys-slang master
# that has the upstream Bazel build (povik/yosys-slang#310) and the
# slang.so visibility fix (povik/yosys-slang#311). Submodules pull in
Expand All @@ -77,20 +170,24 @@ git_override(

# --- Extensions ---

llvm = use_extension(
"@toolchains_llvm//toolchain/extensions:llvm.bzl",
"llvm",
register_toolchains(
"@llvm//toolchain:all",
dev_dependency = True,
)
llvm.toolchain(
llvm_version = "20.1.8",
)
use_repo(llvm, "llvm_toolchain")

register_toolchains(
"@llvm_toolchain//:all",
# sv-lang (via tools/OpenROAD) pulls in rules_pycross, whose toolchain
# extension fails on Python 3.8 (transitively registered via or-tools ->
# pybind11_abseil, dropped from rules_python 2.0.0's MINOR_MAPPING).
# pycross.configure_environments is root-honored only, so the workaround
# must be mirrored here from tools/OpenROAD/MODULE.bazel.
bazel_dep(name = "rules_pycross", version = "0.8.1", dev_dependency = True)

pycross = use_extension(
"@rules_pycross//pycross/extensions:pycross.bzl",
"pycross",
dev_dependency = True,
)
pycross.configure_environments(python_versions = ["3.13"])

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
Expand Down
40 changes: 40 additions & 0 deletions flow/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel-orfs//:openroad.bzl", "orfs_pdk")
load("//flow/designs:design.bzl", "lec_check_targets", "lec_test_targets")

# Expose every individual file under platforms/ as a public source-file
# target, so designs in other packages can refer to e.g.
Expand Down Expand Up @@ -173,3 +174,42 @@ filegroup(
"sky130hd",
"sky130hs",
]]

# Single-corner (typical) liberty sets per platform for kepler-formal
# LEC: kepler-formal needs cell definitions, not timing corners, and
# feeding it the same cells at several corners would double-define
# them. Design-specific macro libs come in via ADDITIONAL_LIBS (see
# lec_liberty in flow/designs/design.bzl).
[filegroup(
name = pdk + "_lec_libs",
srcs = glob(patterns),
visibility = ["//visibility:public"],
) for pdk, patterns in {
"asap7": ["platforms/asap7/lib/NLDM/*_TT_*.lib*"],
"gf180": ["platforms/gf180/lib/*__tt_025C_5v00.lib.gz"],
"ihp-sg13g2": ["platforms/ihp-sg13g2/lib/*_typ_*.lib"],
"nangate45": ["platforms/nangate45/lib/*.lib"],
"sky130hd": ["platforms/sky130hd/lib/*.lib"],
"sky130hs": ["platforms/sky130hs/lib/*tt_025C_1v80.lib"],
}.items()]

# LEC (kepler-formal) aggregates over every design and stage; all
# constituents are tagged `manual` so wildcards skip them. Build the
# checks first (this is where the SAT solving happens; throttle with
# --jobs=N), then run the instant verdict tests:
#
# bazelisk build //flow:lec_check --jobs=4
# bazelisk test //flow:lec_test
filegroup(
name = "lec_check",
srcs = lec_check_targets(),
tags = ["manual"],
visibility = ["//visibility:public"],
)

test_suite(
name = "lec_test",
tags = ["manual"],
tests = lec_test_targets(),
visibility = ["//visibility:public"],
)
12 changes: 12 additions & 0 deletions flow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ clean_synth:
rm -f $(SYNTH_STATS)
rm -f $(SDC_FILE_CLOCK_PERIOD)

# Run Synthesis using OpenROAD's integrated synthesizer (sv_elaborate +
# synthesize, OpenROAD #10473). Drives `synth_syn.tcl`, which reads
# LEF/Liberty/SDC straight from the ORFS env vars and writes 1_synth.odb
# + 1_synth.sdc directly -- bypassing the Yosys + synth_odb chain. Used
# by the bazel-orfs `orfs_openroad_synth_rule` for the `_syn` flow
# variant. Independent of the Yosys recipes above; either path can run.
.PHONY: do-syn-synth
do-syn-synth:
@mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR)
$(RUN_CMD) --log $(abspath $(LOG_DIR)/1_synth.log) --tee -- \
$(OPENROAD_CMD) $(SCRIPTS_DIR)/synth_syn.tcl

# ==============================================================================
# _____ _ ___ ___ ____ ____ _ _ _ _
# | ___| | / _ \ / _ \| _ \| _ \| | / \ | \ | |
Expand Down
27 changes: 27 additions & 0 deletions flow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,30 @@ the generated targets get `tags = ["manual"]`.
Each OpenROAD invocation takes `-threads <nproc>`. A wildcard
`bazelisk test` runs designs in parallel and overcommits the host. Cap
with `--jobs=N`.

## Logic equivalence checking (LEC)

Every design gets per-stage
[kepler-formal](https://github.com/keplertech/kepler-formal)
equivalence checks, all tagged `manual`:

| Target | Checks |
|---|---|
| `<n>_lec_synth` | Canonicalized RTL (`<n>_canon_v`, written from the yosys canonicalize checkpoint) vs the yosys synthesis netlist — SEC, using kepler-formal's pre-synthesis `.v` support. A failure implicates synthesis, not canonicalization. |
| `<n>_lec_<stage>` | Adjacent-pair gate-level LEC along the flow: synth↔floorplan, floorplan↔place, place↔cts, cts↔route, route↔final, on netlists written from each stage's `.odb` (physical-only cells removed). |
| `<n>_syn_lec_synth` | Flat designs only: the OpenROAD built-in synth (`_syn` variant) netlist vs the same canonicalized RTL. |

Each check runs kepler-formal at **build** time (`lec_check`; the
verdict and log are cached build artifacts) and pairs with an instant
`<target>_test` that only asserts the recorded verdict, so `bazelisk
test` sweeps never time out on SAT runtimes. Build first — SAT solving
is memory-hungry, so cap parallelism per the section above — then run
the tests:

```bash
bazelisk build //flow:lec_check --jobs=4 # or individual <n>_lec_* targets
bazelisk test //flow:lec_test
```

Hierarchical designs (`OPENROAD_HIERARCHICAL=1`) are read with `-hier`
and produce hierarchical netlists.
Loading