Skip to content

Fix bytefield accessibility generation: detect attributed macros, filter XLEN bit-position labels#249

Merged
Bill Traynor (wmat) merged 1 commit into
riscv:mainfrom
Maanvi212006:fix/bytefield-a11y-generation
Jul 17, 2026
Merged

Fix bytefield accessibility generation: detect attributed macros, filter XLEN bit-position labels#249
Bill Traynor (wmat) merged 1 commit into
riscv:mainfrom
Maanvi212006:fix/bytefield-a11y-generation

Conversation

@Maanvi212006

@Maanvi212006 Maanvi212006 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Contributes to riscv/riscv-isa-manual#1129

Problem

Two bugs in tools/wavedrom_a11y.py surfaced while re-verifying auto-generated alt text on bytefield diagrams:

  1. detect_diagram_type used an exact match on [bytefield]. Once a file had already been processed and gained an alt="..." attribute (e.g. [bytefield, ,svg, alt="..."]), the literal [bytefield] no longer appeared in the file, so re-running the tool on an already-processed file caused it to fall through to diagram_type = 'unknown' and lose all bytefield-specific title/desc generation.

  2. The auto-generated field-name list included XLEN-relative bit-position labels (e.g. MXLEN-1, HSXLEN, VSXLEN-2) as if they were real field names, alongside genuine fields like Interrupt or Exception Code. These are bit-width markers analogous to plain numeric labels (which were already filtered), just written symbolically instead of as literal digits.

Fix

  • detect_diagram_type: match on the [bytefield prefix (consistent with how [wavedrom is already matched) instead of the exact string [bytefield], so the check is robust to attributes being appended.
  • build_accessibility_text: extend the field-label filter to also drop labels matching [A-Z]*XLEN[+-]?\d* (covers XLEN, MXLEN-1, SXLEN-1, HSXLEN, VSXLEN-2, etc.), while still preserving legitimate bracketed field names like BASE[MXLEN-1:2].

Testing

Verified via direct calls to extract_content / build_accessibility_text across representative files:

  • Re-processed files (sv39pte, pmpcfg, mvendorid) now correctly detect as bytefield and produce "{NAME} register field layout" titles with clean Fields: ... descriptions.
  • Swept all 92 bytefield .edn files for stray XLEN-pattern or empty descriptions; confirmed the only remaining XLEN occurrences are legitimate bracketed field names (BASE[MXLEN-1:2], BASE[SXLEN-1:2], BASE[VSXLEN-1:2]) that should be kept.

…bit-position labels

Signed-off-by: Maanvi212006 <maanvichetwani21@gmail.com>
@wmat

Copy link
Copy Markdown
Collaborator

Much appreciatd.

@wmat
Bill Traynor (wmat) merged commit 75101c8 into riscv:main Jul 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants