Skip to content

Commit 0374920

Browse files
oharboeclaude
andcommitted
build: add bazel-orfs beta test for design builds
Add BUILD.bazel files for all asap7 and sky130hd designs using the orfs_design() macro from bazel-orfs, which auto-generates flow targets from existing config.mk files. Designs that don't yet work have the orfs_design() call commented out with a note explaining what's missing (typically a source BUILD.bazel with :verilog filegroup). Working designs: gcd, gcd-ccs, aes, aes-block, aes-mbff, aes_lvt, ethmac, ethmac_lvt (asap7); gcd, aes (sky130hd). Includes bazel-orfs.md guide for beta testers. The full 51-design patch set remains out-of-tree in bazel-orfs/orfs/ to minimize churn. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent df27ce6 commit 0374920

33 files changed

Lines changed: 412 additions & 4 deletions

File tree

MODULE.bazel

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ bazel_dep(name = "bazel-orfs")
1111
# To bump version, run: bazelisk run @bazel-orfs//:bump
1212
git_override(
1313
module_name = "bazel-orfs",
14-
commit = "f8a4b694b37c8f5322323eba9a9ae37f9541ee17",
14+
commit = "e46fca0214def95ecfbada54a8028da7d47fd122",
1515
remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
1616
)
1717

18+
# Transitive dep of bazel-orfs (lives in its verilog/ subdirectory).
19+
bazel_dep(name = "bazel-orfs-verilog")
20+
archive_override(
21+
module_name = "bazel-orfs-verilog",
22+
strip_prefix = "bazel-orfs-e46fca0214def95ecfbada54a8028da7d47fd122/verilog",
23+
urls = ["https://github.com/The-OpenROAD-Project/bazel-orfs/archive/e46fca0214def95ecfbada54a8028da7d47fd122.tar.gz"],
24+
)
25+
1826
bazel_dep(name = "rules_python", version = "1.2.0")
1927
bazel_dep(name = "rules_shell", version = "0.6.1")
2028

@@ -36,12 +44,24 @@ orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
3644

3745
# To bump version, run: bazelisk run @bazel-orfs//:bump
3846
orfs.default(
39-
image = "docker.io/openroad/orfs:v3.0-3273-gedf3d6bf",
47+
image = "docker.io/openroad/orfs:26Q1-816-gf40d2f346",
4048
# Use local files instead of docker image
4149
makefile = "//flow:makefile",
4250
makefile_yosys = "//flow:makefile_yosys",
4351
pdk = "//flow:asap7",
44-
sha256 = "f5692c6325ebcf27cc348e033355ec95c82c35ace1af7e72a0d352624ada143e",
52+
sha256 = "2b05a14ae8062b4af82b245d648e95fa0293e09b61b57468518b66578744afb8",
53+
variables_yaml = "//flow:scripts/variables.yaml",
4554
)
46-
use_repo(orfs, "com_github_nixos_patchelf_download")
4755
use_repo(orfs, "docker_orfs")
56+
57+
# Auto-generate orfs_flow() targets from config.mk files.
58+
# See bazel-orfs.md for usage.
59+
orfs_designs = use_repo_rule("@bazel-orfs//private:designs.bzl", "orfs_designs")
60+
orfs_designs(
61+
name = "orfs_designs",
62+
designs_dir = "//flow/designs:BUILD.bazel",
63+
platforms = [
64+
"asap7",
65+
"sky130hd",
66+
],
67+
)

bazel-orfs.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# bazel-orfs Beta Test
2+
3+
This is an early integration of [bazel-orfs](https://github.com/The-OpenROAD-Project/bazel-orfs)
4+
into OpenROAD-flow-scripts. It lets you build ORFS designs with Bazel
5+
using the same `config.mk` files you already have.
6+
7+
**Status**: beta -- a handful of simple designs work end-to-end.
8+
The full patch set lives out-of-tree in `bazel-orfs/orfs/` to minimize
9+
churn; this PR wires up the minimum needed for developers to kick the
10+
tires.
11+
12+
## Quick Start
13+
14+
```bash
15+
# Install bazelisk (one-time) -- see https://github.com/bazelbuild/bazelisk
16+
# Then, from the ORFS root:
17+
18+
# Synthesize gcd on asap7 (downloads Docker image on first run)
19+
bazelisk build //flow/designs/asap7/gcd:gcd_synth
20+
21+
# Run through floorplan
22+
bazelisk build //flow/designs/asap7/gcd:gcd_floorplan
23+
24+
# Full flow through final
25+
bazelisk build //flow/designs/asap7/gcd:gcd_final
26+
27+
# Run the test (includes QoR regression check)
28+
bazelisk test //flow/designs/asap7/gcd:gcd_test
29+
30+
# List all targets for a design
31+
bazelisk query //flow/designs/asap7/gcd:all
32+
```
33+
34+
## Available Targets Per Design
35+
36+
Each enabled design gets these targets automatically from its `config.mk`:
37+
38+
| Target suffix | What it does |
39+
|---|---|
40+
| `_synth` | Yosys synthesis |
41+
| `_floorplan` | Floorplan + I/O placement |
42+
| `_place` | Global + detailed placement |
43+
| `_cts` | Clock tree synthesis |
44+
| `_grt` | Global routing |
45+
| `_route` | Detailed routing |
46+
| `_final` | Final optimization + fill |
47+
| `_generate_abstract` | LEF/LIB abstract for hierarchical use |
48+
| `_generate_metadata` | Flow metadata (logs, reports) |
49+
| `_test` | Full flow + QoR regression check |
50+
51+
Each stage depends on the previous one, so building `_final` runs the
52+
entire flow.
53+
54+
## Working Designs
55+
56+
These designs have `orfs_design()` enabled and pass `bazelisk query`:
57+
58+
### asap7
59+
60+
- `gcd` -- smoketest, builds in ~1 minute
61+
- `gcd-ccs` -- gcd with CCS lib model
62+
- `aes` (aes_cipher_top) -- medium design
63+
- `aes-block` -- aes as a block
64+
- `aes-mbff` -- aes with MBFF
65+
- `aes_lvt` -- aes with LVT cells
66+
- `ethmac` -- Ethernet MAC
67+
- `ethmac_lvt` -- ethmac with LVT cells
68+
69+
### sky130hd
70+
71+
- `gcd` -- smoketest
72+
- `aes` (aes_cipher_top) -- medium design
73+
74+
## Designs Not Yet Working
75+
76+
Each design directory has a `BUILD.bazel` with a commented-out
77+
`orfs_design()` call and a note explaining what's missing. The common
78+
blockers are:
79+
80+
**Missing `src/` BUILD.bazel**: The source directory (e.g.
81+
`flow/designs/src/jpeg/`) needs a `BUILD.bazel` with a `:verilog`
82+
filegroup and `exports_files`. Affected: jpeg, jpeg_lvt, uart,
83+
riscv32i, riscv32i-mock-sram, mock-cpu, chameleon, microwatt.
84+
85+
**Specific file references**: Some `config.mk` files reference
86+
individual source files instead of wildcards. These need
87+
`exports_files` in the source directory. Affected: ibex,
88+
swerv_wrapper.
89+
90+
**Complex source trees**: Designs like cva6 have deeply nested source
91+
trees that each need their own `BUILD.bazel`. Affected: cva6.
92+
93+
**Generated verilog**: mock-alu generates its verilog via Python scripts.
94+
Needs a `genrule`. Affected: mock-alu.
95+
96+
**No config.mk**: mock-array has no config.mk (test fixture only).
97+
98+
**No verilog**: minimal is a test design with no VERILOG_FILES.
99+
100+
## How to Add More Designs
101+
102+
1. Create `flow/designs/<platform>/<design>/BUILD.bazel`:
103+
104+
```starlark
105+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
106+
load("@orfs_designs//:designs.bzl", "DESIGNS")
107+
108+
exports_files(glob(["*"]))
109+
110+
orfs_design(designs = DESIGNS)
111+
```
112+
113+
2. If `flow/designs/src/<name>/BUILD.bazel` doesn't exist, create it:
114+
115+
```starlark
116+
exports_files(
117+
glob(["*.v", "*.sv"], allow_empty = True),
118+
visibility = ["//visibility:public"],
119+
)
120+
121+
filegroup(
122+
name = "verilog",
123+
srcs = glob(include = ["*.v", "*.sv"], allow_empty = True),
124+
visibility = ["//visibility:public"],
125+
)
126+
```
127+
128+
3. Run `bazelisk query //flow/designs/<platform>/<design>:all` to verify.
129+
130+
## Using a Local bazel-orfs Checkout
131+
132+
To iterate on bazel-orfs rules locally, replace the `git_override` in
133+
`MODULE.bazel`:
134+
135+
```starlark
136+
# Comment out the git_override block, then add:
137+
local_path_override(
138+
module_name = "bazel-orfs",
139+
path = "/path/to/your/bazel-orfs",
140+
)
141+
```
142+
143+
Also update the `bazel-orfs-verilog` override:
144+
145+
```starlark
146+
local_path_override(
147+
module_name = "bazel-orfs-verilog",
148+
path = "/path/to/your/bazel-orfs/verilog",
149+
)
150+
```
151+
152+
## Key Differences from Make
153+
154+
- **Incremental**: Bazel caches every stage. Changing `PLACE_DENSITY`
155+
in `config.mk` rebuilds only floorplan onward -- synthesis is cached.
156+
- **Hermetic**: Tools come from a Docker image (extracted automatically).
157+
No `make install` or `PATH` setup needed.
158+
- **Parallel**: Independent designs build in parallel automatically.
159+
- **Reproducible**: Same inputs always produce the same outputs.
160+
161+
## Known Limitations
162+
163+
- Only asap7 and sky130hd PDKs are wired up (others can be added to
164+
`MODULE.bazel` platforms list and `flow/BUILD.bazel` orfs_pdk calls).
165+
- The Docker image is pinned; updating it requires changing
166+
`MODULE.bazel`.
167+
- Not all designs work yet (see above).
168+
- This is a beta -- expect rough edges. File issues at
169+
https://github.com/The-OpenROAD-Project/bazel-orfs/issues

flow/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ filegroup(
1414
srcs = ["Makefile"],
1515
data = glob(MAKEFILE_SHARED + [
1616
"scripts/*.script",
17+
"scripts/*.v",
1718
"scripts/util.tcl",
1819
"scripts/synth*.tcl",
1920
"platforms/common/**/*.v",

flow/designs/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(["BUILD.bazel"])
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
2+
load("@orfs_designs//:designs.bzl", "DESIGNS")
3+
4+
exports_files(glob(["*"]))
5+
6+
orfs_design(designs = DESIGNS)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
2+
load("@orfs_designs//:designs.bzl", "DESIGNS")
3+
4+
exports_files(glob(["*"]))
5+
6+
orfs_design(designs = DESIGNS)

flow/designs/asap7/aes/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
2+
load("@orfs_designs//:designs.bzl", "DESIGNS")
3+
4+
exports_files(glob(["*"]))
5+
6+
orfs_design(designs = DESIGNS)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
2+
load("@orfs_designs//:designs.bzl", "DESIGNS")
3+
4+
exports_files(glob(["*"]))
5+
6+
orfs_design(designs = DESIGNS)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
2+
load("@orfs_designs//:designs.bzl", "DESIGNS")
3+
4+
exports_files(glob(["*"]))
5+
6+
# TODO(bazel-orfs): orfs_design(designs = DESIGNS)
7+
# Blocked: flow/designs/src/cva6/ needs BUILD.bazel with :verilog filegroup.
8+
# Complex multi-directory source tree with many subdirectories needing BUILD files.
9+
# Also needs BUILD.bazel for VERILOG_INCLUDE_DIRS targets.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
load("@bazel-orfs//:openroad.bzl", "orfs_design")
2+
load("@orfs_designs//:designs.bzl", "DESIGNS")
3+
4+
exports_files(glob(["*"]))
5+
6+
orfs_design(designs = DESIGNS)

0 commit comments

Comments
 (0)