|
| 1 | +# KLayout as an Optional Dependency |
| 2 | + |
| 3 | +KLayout is only required for GDS/OAS stream generation, DRC, and LVS |
| 4 | +verification. All other ORFS functionality — synthesis, floorplanning, |
| 5 | +placement, CTS, routing, timing reports, and abstract generation — works |
| 6 | +without KLayout installed. |
| 7 | + |
| 8 | +## Makefile Targets |
| 9 | + |
| 10 | +| Target | Requires KLayout | Description | |
| 11 | +|---|---|---| |
| 12 | +| `make finish` | No | Complete flow through timing reports | |
| 13 | +| `make gds` | Yes | Generate GDS/OAS from finished design | |
| 14 | +| `make do-finish` / `make do-final` | No | Same as `finish`, for bazel-orfs | |
| 15 | +| `make do-gds` | Yes | Same as `gds`, for bazel-orfs | |
| 16 | +| `make drc` | Yes | Run DRC checks (requires GDS) | |
| 17 | +| `make lvs` | Yes | Run LVS checks (requires GDS) | |
| 18 | +| `make gallery` | Yes | Generate layout screenshots | |
| 19 | +| `make klayout_<file>` | Yes | Open result in KLayout viewer | |
| 20 | +| `make generate_abstract` | No | Generate LEF/LIB abstracts | |
| 21 | + |
| 22 | +A `check-klayout` guard produces a clear error message when KLayout is |
| 23 | +missing and a KLayout-dependent target is invoked: |
| 24 | + |
| 25 | +``` |
| 26 | +Error: KLayout not found. Install KLayout or set KLAYOUT_CMD. |
| 27 | +Hint: 'make finish' works without KLayout. Only GDS/DRC/LVS need it. |
| 28 | +``` |
| 29 | + |
| 30 | +## Use Cases |
| 31 | + |
| 32 | +| Use Case | Needs KLayout? | |
| 33 | +|---|---| |
| 34 | +| Education / learning digital design | No | |
| 35 | +| Architectural exploration (PPA analysis) | No | |
| 36 | +| CI testing of ORFS / OpenROAD | No | |
| 37 | +| Local ORFS and OpenROAD development | No | |
| 38 | +| bazel-orfs default `orfs_flow()` | No | |
| 39 | +| GDS generation for tapeout | Yes | |
| 40 | +| DRC / LVS verification | Yes | |
| 41 | +| Layout visualization in KLayout GUI | Yes | |
| 42 | + |
| 43 | +## bazel-orfs Integration |
| 44 | + |
| 45 | +bazel-orfs uses the `do-` prefixed targets which bypass Make's dependency |
| 46 | +management. The relevant targets follow the standard pattern: |
| 47 | + |
| 48 | +- `do-finish` / `do-final` — runs the finish stage without GDS |
| 49 | +- `do-gds` — runs GDS generation (requires KLayout) |
| 50 | + |
| 51 | +An `orfs_gds()` Bazel rule can call `do-gds` independently from |
| 52 | +`orfs_flow()`, making KLayout an optional toolchain dependency configured |
| 53 | +in `MODULE.bazel`. |
| 54 | + |
| 55 | +## KLayout Tech File Generation |
| 56 | + |
| 57 | +The `do-klayout` and `do-klayout_wrap` targets generate `.lyt` technology |
| 58 | +files by substituting LEF and map file paths into platform templates. |
| 59 | +This is implemented in `util/generate_klayout_tech.py` using stdlib XML |
| 60 | +processing — no KLayout dependency required. |
| 61 | + |
| 62 | +## Testing Without KLayout |
| 63 | + |
| 64 | +Unit tests for all KLayout-related Python scripts use `unittest.mock` to |
| 65 | +mock the `pya` API: |
| 66 | + |
| 67 | +``` |
| 68 | +cd flow/test |
| 69 | +python -m unittest test_generate_klayout_tech test_def2stream test_convertDrc |
| 70 | +``` |
| 71 | + |
| 72 | +These tests cover: |
| 73 | +- `.lyt` tech file generation (`test_generate_klayout_tech.py`) |
| 74 | +- DEF-to-GDS merging logic (`test_def2stream.py`) |
| 75 | +- DRC report conversion (`test_convertDrc.py`) |
| 76 | + |
| 77 | +## Future: OpenROAD `write_gds` and KLayout Coexistence |
| 78 | + |
| 79 | +OpenROAD has an unfinished `write_gds` command. When it is eventually |
| 80 | +completed, it would eliminate the KLayout dependency for GDS generation |
| 81 | +in many cases. However, KLayout support will live alongside `write_gds` |
| 82 | +until there is confidence that `write_gds` is robust and fully covers |
| 83 | +all current use cases. |
| 84 | + |
| 85 | +Even then, non-public or future PDKs may have requirements that benefit |
| 86 | +from KLayout's mature GDS handling. Whether KLayout support stays in |
| 87 | +ORFS indefinitely remains to be seen. Once `write_gds` works robustly |
| 88 | +for all of today's use cases, extending it to cover future ones may |
| 89 | +turn out to be straightforward. |
0 commit comments