odb: add LEFDEF grammar railroad diagram documentation#9866
odb: add LEFDEF grammar railroad diagram documentation#9866sparsh-karna wants to merge 10 commits intoThe-OpenROAD-Project:masterfrom
Conversation
54ed0c5 to
aeac43c
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces auto-generated SVG railroad diagrams for LEF and DEF grammar rules in OpenROAD's ODB parser, along with Markdown documentation pages embedding these diagrams. The changes are documentation-only, with no modifications to production source code. The pull request includes a Python script for diagram generation, vendored Java tools, SVG diagrams for LEF and DEF grammars, Markdown documentation, and a CI workflow for automatic regeneration. No specific style guides were provided, so the review focuses on general code quality and best practices.
aeac43c to
20aaaf4
Compare
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Add SVG railroad diagrams generated directly from lef.y and def.y, a Python script to regenerate them, Markdown documentation that embeds the diagrams, and a GitHub Actions workflow that opens a PR whenever a grammar file changes. Files added: - src/odb/doc/generate_railroad_diagrams.py — converts .y → EBNF → individual SVG files using ebnf-convert and rr (downloaded from Maven Central on first use; not committed). - src/odb/doc/images/lef/ — 246 SVGs generated from lef.y - src/odb/doc/images/def/ — 276 SVGs generated from def.y - src/odb/doc/LEF_Grammar.md — documentation with embedded diagrams - src/odb/doc/DEF_Grammar.md — documentation with embedded diagrams - src/odb/doc/.gitignore — excludes tools/ and intermediate files - .github/workflows/github-actions-update-grammar-railroad-diagrams.yml — auto-regenerates and opens a PR on grammar changes Resolves The-OpenROAD-Project#2488 Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Place ebnf-convert.war (v0.73) and rr.war (v2.6) in src/odb/doc/tools/ so the script works offline without a Maven Central fetch. Update ensure_tools() to fail with actionable instructions rather than silently downloading, and remove tools/ from .gitignore now that the files are committed. Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
LEF_Grammar.md now covers 243 rules across 18 sections: File structure, Units, Layers, Vias, Via Rules, Spacing, Sites, Macros, Macro Pins, Non-default Rules, Properties, IRDrop, Noise & Correction Tables, Timing, Arrays (Floorplan), Antenna Rules, Dielectric & Minfeature, Primitives. DEF_Grammar.md now covers 274 rules across 28 sections: File structure, Design Attributes, Properties, Components, Nets, Net Routing, Net Subnets, Special Nets, Pins, Virtual Pins, Pin Properties, Blockages, Regions, Groups, Via Definitions, Non-default Rules, Fills, Slots, Styles, IO Timing, Scan Chains, Timing Disables, Partitions, Constraints, Assertions, Floorplan Constraints, Extension, Primitives. Each section has a linked TOC at the top of the page. Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Inject a CSS custom property and inline style into each generated SVG so the diagrams render with a solid warm-white background (#FFFCF0) instead of being transparent. This keeps them legible in both light and dark documentation themes. Also clean up generate_railroad_diagrams.py: remove dead Maven Central download code (WARs are now vendored), update the module docstring, and wire in the new fix_svg_background() helper that is called after each SVG is extracted from the rr output ZIP. Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
20aaaf4 to
e73ad78
Compare
|
@maliberty both CI failures are unrelated to the C++ changes. clang-tidy: the scan-code: flagging the routing code itself is clean. |
luarss
left a comment
There was a problem hiding this comment.
Very nice first cut. Just some feedback to make it more future-proof
.github/workflows/github-actions-update-grammar-railroad-diagrams.yml
Outdated
Show resolved
Hide resolved
.github/workflows/github-actions-update-grammar-railroad-diagrams.yml
Outdated
Show resolved
Hide resolved
src/odb/doc/tools/ebnf-convert.war
Outdated
There was a problem hiding this comment.
Why not download it in CI? I think this binary shouldn't be tracked in version control
There was a problem hiding this comment.
Looked into this, v0.73 of ebnf-convert (the version vendored here) was tagged on GitHub
but has no release assets attached, so there's no downloadable WAR for that version. Older
releases ship as zips not WARs, and the WAR format is required for the headless invocation
used in the script.
The rr.war (v2.6) is available on Maven Central and could be downloaded, but keeping one
tool vendored and one downloaded feels inconsistent.
The cleanest fix IMO is Git LFS, the WARs stay pinned to the exact tested versions, the
Scan Code failure goes away (LFS pointers are plain text), and there are no external
download dependencies at build time. Would that work?
Or what we can do is build the ebnf-convert from source in CI.
There was a problem hiding this comment.
Yes - you can build ebnf-convert from source then cache it using gh actions.
There was a problem hiding this comment.
got it, i will make the changes
There was a problem hiding this comment.
updated the ci to build on push, pls check and give feedback
- Use **/*.y glob in CI workflow trigger instead of hardcoded lef.y/def.y paths so any future grammar additions are covered automatically - Refactor argument parsing in generate_railroad_diagrams.py to use argparse instead of manual sys.argv handling Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
|
hey @luarss could you check the changes that i made |
| parser.add_argument("target", nargs="?") | ||
| args, _ = parser.parse_known_args() | ||
|
|
||
| if args.target not in {"lef", "def", "all"}: |
There was a problem hiding this comment.
Please use choices in add_argument for this.
There was a problem hiding this comment.
Done - the latest version uses choices=[*GRAMMARS.keys(), "all"] in add_argument.
|
|
||
| def main() -> None: | ||
| parser = argparse.ArgumentParser(add_help=False) | ||
| parser.add_argument("target", nargs="?") |
There was a problem hiding this comment.
some help message is always useful
There was a problem hiding this comment.
Done - added a description to ArgumentParser and a help string to the targets argument.
| def main() -> None: | ||
| parser = argparse.ArgumentParser(add_help=False) | ||
| parser.add_argument("target", nargs="?") | ||
| args, _ = parser.parse_known_args() |
There was a problem hiding this comment.
why this over parse_args()?
There was a problem hiding this comment.
Good catch - was using parse_known_args() as a workaround for a validation bug with the
default value. Fixed in the latest commit - now using parse_args() with proper choices
validation.
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
Signed-off-by: Sparsh Karna <sparsh2005karna@gmail.com>
|
hey @luarss, i have updated the ci for this could you check and give feedback |
Summary
Closes #2488.
Adds auto-generated SVG railroad diagrams for all LEF and DEF grammar rules
in OpenROAD's ODB parser, alongside Markdown documentation pages that embed
them. Railroad diagrams visually show every valid syntax path through the
LEF/DEF grammars, making them significantly easier to read than raw Bison
grammar files.
This is a documentation-only change. No production source code is modified.
What's Included
src/odb/doc/generate_railroad_diagrams.py: Python script thatconverts
lef.y/def.y(Bison grammars) → W3C EBNF → SVG railroaddiagrams via two vendored Java tools.
src/odb/doc/tools/ebnf-convert.war: VendoredGunther Rademacher's ebnf-convert
tool (Bison → EBNF conversion). Vendored directly to avoid requiring
contributors to build or download it separately.
src/odb/doc/tools/rr.war: VendoredRailroad Diagram Generator
rrlib(
de.bottlecaps.rr:rr-lib:2.6from Maven Central). Vendored for thesame reason.
src/odb/doc/images/lef/*.svg: 246 SVG railroad diagrams coveringevery LEF grammar rule.
src/odb/doc/images/def/*.svg: 276 SVG railroad diagrams coveringevery DEF grammar rule.
src/odb/doc/LEFGrammar.md: Markdown doc embedding all LEF diagrams,grouped by category.
src/odb/doc/DEFGrammar.md: Markdown doc embedding all DEF diagrams,grouped by category.
.github/workflows/github-actions-update-grammar-railroad-diagrams.yml:CI workflow that auto-regenerates diagrams and opens a PR whenever
lef.yordef.ychanges onmaster.docs/toc.yml: AddsLEFGrammarandDEFGrammarentries to theOpenROAD documentation navigation.
src/odb/doc/.gitignore: Ignores intermediate.ebnfand.zipartifacts produced during generation.
How to Regenerate Diagrams
Requires Java 11+ on PATH.
Example Diagram: