Skip to content

Commit 25111cb

Browse files
oharboeclaude
andcommitted
docs: update README with config.mk DSL and incremental caching
Document the value proposition: think in Make, test with Make, get Bazel caching and parallelism. Add sections on incremental caching (changing CORE_UTILIZATION skips synthesis), quick start, and the config.mk DSL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 963cabe commit 25111cb

1 file changed

Lines changed: 91 additions & 32 deletions

File tree

bazel/README.md

Lines changed: 91 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,119 @@
11
# OpenROAD-flow-scripts and Bazel integration
22

3-
`bazel-orfs` is a Bazel package containing the definitions and logic governing the build process of ORFS designs.
4-
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.
3+
Think in Make, test with Make, get Bazel performance, caching, and parallelism.
54

6-
## Run examples
5+
## How it works
76

8-
`flow/BUILD.bazel` contains definitions for various flows to serve as examples.
7+
`config.mk` is the canonical DSL for defining ORFS designs. The Bazel integration
8+
auto-generates `orfs_flow()` targets from these config.mk files using a Python parser,
9+
so you never need to maintain separate BUILD files for your designs.
910

10-
It is recommended to run the utility [Bazelisk](https://github.com/bazelbuild/bazelisk) to manage the version of `bazel` installed on the system.
11-
Details on installation can be found in the `bazel-orfs` [README](https://github.com/The-OpenROAD-Project/bazel-orfs?tab=readme-ov-file#requirements)
11+
```
12+
config.mk --> config_mk_parser.py --> orfs_flow() targets --> Bazel build
13+
```
14+
15+
The `bazel-orfs` package defines the rules that drive the ORFS Makefile-based flow
16+
through Bazel, giving you:
17+
18+
- **Caching**: unchanged stages are not re-run
19+
- **Parallelism**: independent designs and stages build concurrently
20+
- **Reproducibility**: hermetic builds with pinned tool versions
21+
- **Zero-docker mode**: everything runs from local sources, no Docker image required
22+
23+
## Quick start
1224

13-
The flow can be ran with the following call structure:
25+
Install [Bazelisk](https://github.com/bazelbuild/bazelisk), then:
1426

1527
```bash
16-
bazel build <target_name>_<stage_name>
28+
# Build GCD synthesis for ASAP7
29+
bazel build @orfs_designs//asap7/gcd:gcd_synth
30+
31+
# Build full RTL-to-GDSII flow
32+
bazel build //flow/designs/asap7/gcd:gcd_final
33+
34+
# Build for a different PDK
35+
bazel build //flow/designs/sky130hd/gcd:gcd_final
36+
```
37+
38+
## Adding a new design
39+
40+
Just create a `config.mk` file in `flow/designs/<platform>/<design>/`:
41+
42+
```makefile
43+
export PLATFORM = asap7
44+
export DESIGN_NAME = my_design
45+
export VERILOG_FILES = $(sort $(wildcard $(DESIGN_HOME)/src/$(DESIGN_NAME)/*.v))
46+
export SDC_FILE = $(DESIGN_HOME)/$(PLATFORM)/$(DESIGN_NAME)/constraint.sdc
47+
export CORE_UTILIZATION = 50
1748
```
1849

19-
For example, to run the stage `final`, along with all the dependent stages, call:
50+
Bazel targets auto-appear at `//flow/designs/<platform>/<design>:<design_name>_<stage>`.
51+
52+
## Incremental caching
53+
54+
Bazel only re-runs stages whose inputs changed. The variable metadata from
55+
`flow/scripts/variables.yaml` defines which ORFS variables affect which stages.
56+
57+
For example, if you modify only `CORE_UTILIZATION` in
58+
`flow/designs/asap7/gcd/config.mk`, then:
59+
2060
```bash
21-
bazel build gcd_final
61+
bazel build //flow/designs/asap7/gcd:gcd_place
2262
```
2363

24-
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)
64+
This re-runs from floorplan onward but **skips synthesis entirely** — because
65+
`variables.yaml` defines `CORE_UTILIZATION` as only affecting floorplan and
66+
later stages, not synthesis. The cached synthesis result is reused.
2567

26-
## Dependency version management
68+
## config.mk DSL
2769

28-
In the flow scipts, the `bazel-orfs` version is defined as
70+
The config.mk DSL is a restricted subset of Make. Supported features:
2971

30-
```starlark
31-
bazel_dep(name = "bazel-orfs")
32-
git_override(
33-
module_name = "bazel-orfs",
34-
commit = "<Hash of the default bazel-orfs commit>",
35-
remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
36-
)
72+
| Feature | Example |
73+
|---------|---------|
74+
| Variable assignment | `export VAR = value` |
75+
| Conditional default | `export VAR ?= value` |
76+
| Clear/immediate | `export VAR :=` |
77+
| Line continuations | `export FILES = a.v \`<br>` b.v` |
78+
| Path variables | `$(DESIGN_HOME)`, `$(PLATFORM)`, `$(DESIGN_NAME)`, `$(DESIGN_NICKNAME)` |
79+
| Glob patterns | `$(sort $(wildcard $(DESIGN_HOME)/src/$(DESIGN_NAME)/*.v))` |
80+
| Hierarchical blocks | `export BLOCKS = sub_macro1 sub_macro2` |
81+
82+
Run the linter to check your config.mk for unsupported features:
83+
84+
```bash
85+
python3 bazel/config_mk_parser.py --lint flow/designs/asap7/gcd/config.mk
3786
```
38-
However, as the referenced documentation shows, the git-based dependency can be overridden with a local repository.
39-
First, remove the `git_override` call entirely and replace it with a `local_path_override` call following this convention:
87+
88+
## Zero-docker mode
89+
90+
The default configuration uses no Docker image. All tools, scripts, PDKs, and
91+
flow infrastructure come from the local repository:
92+
93+
- **Scripts**: `//flow:makefile` and `//flow:makefile_yosys`
94+
- **PDKs**: `//flow:asap7`, `//flow:sky130hd`, etc.
95+
- **OpenROAD**: built from `tools/OpenROAD/` or system-installed
96+
97+
To switch to a Docker-based configuration, set the `image` attribute:
4098

4199
```starlark
42-
local_path_override(
43-
module_name = "bazel-orfs",
44-
path = "/replace/with/path/to/local/orfs/repository"
100+
orfs.default(
101+
image = "docker.io/openroad/orfs:tag",
102+
sha256 = "the-hash",
45103
)
46104
```
47105

48-
`bazel-orfs` sets a default version of the docker image used to create the Bazel environment.
49-
This selection can be overridden by a following snippet inserted below the `bazel-orfs` declaration and override.
106+
## Dependency version management
107+
108+
`bazel-orfs` is referenced in `MODULE.bazel`. To use a local checkout:
50109

51110
```starlark
52-
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
53-
orfs.default(
54-
image = "tag-name",
55-
sha256 = "the-hash",
111+
local_path_override(
112+
module_name = "bazel-orfs",
113+
path = "/path/to/local/bazel-orfs",
56114
)
57115
```
58116

59-
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).
117+
Details on usage and flow definitions are in the `bazel-orfs`
118+
[README](https://github.com/The-OpenROAD-Project/bazel-orfs?tab=readme-ov-file#usage).
60119

0 commit comments

Comments
 (0)