|
| 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 |
0 commit comments