Skip to content

Style follow-up: localparams, named constants, dead code, typo renames, consistent nesting - #1959

Open
davidharrishmc wants to merge 19 commits into
openhwfoundation:mainfrom
davidharrishmc:dh/style-followup
Open

davidharrishmc wants to merge 19 commits into
openhwfoundation:mainfrom
davidharrishmc:dh/style-followup

Conversation

@davidharrishmc

@davidharrishmc davidharrishmc commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #1955 (which builds on #1952); merge those first so this PR shows only its own changes.

  • `define → localparam for local widths (FCTRLW, CTRLW, BMUCTRLW, plic C). Decode-table literals now carry explicit widths (14'b/24'b/21'b) since a parameter cannot size a literal. INSTR_CLASS_PRED stays a `define in bpred.sv; Use P.INSTR_CLASS_PRED in bpred #1967 replaces it with P.INSTR_CLASS_PRED. Shared config macros (`BP_*) stay.
  • Named constants instead of magic numbers, all value-identical: FP format codes use P.*_FMT; new package constants for page types, CMO bits, instruction classes, PMA regions, postprocessor selects, and rounding modes; existing UART_*/CLINT_* register names; RESULTSRC_*.
  • Remove dead logic: unused signals and declarations (branch predictors, FPU divider/postprocessor, uncore SDC leftovers, etc.), the unused zknde32 round port, the unreferenced mux6/mux7 modules, and the dead ZeM bits of the FPU's EMFpReg4 pipeline register (now P.NF+1 bits wide).
  • Fix typos in names (WordAdrrMux, SelecteDirty, HPTWAccesFaultReg, ADDR_WDITH, CacheBusHPWTStall, ziccslm_align, Div0eMReg, RestorMux, presresultmux, LeftShiftQm→RightShiftQm), updating the coverage-exclusion tag, and the placeholder macro name in rom1p1r_128x32 (generic64x128ROM → generic128x32ROM, matching the file).
  • Generate-block else branches that reused the if branch's label get their own (flushlogic→noflushlogic, bpred→nobpred, decomp→nodecomp, cboz→nocboz, tlb→notlb). These hierarchical paths change; nothing in the repo refers to them, but external wave or ILA scripts would need updating.
  • csrindextoaddr looks addresses up in a table instead of a one-hot case, and stops elaboration if TOTAL_CSRS exceeds the table.
  • Deduplicate where it is not intrusive: unpackinput's per-format exponent re-bias, flags' ShiftGtIntSz, fhazard's forwarding blocks, aes64ks1i, and rev8 via byteop.
  • Consistent 2-space nesting (FPU postprocessor, fcvt, fmaalign, AES S-boxes) and whitespace (import cvw::*; #(, port alignment).

🤖 Generated with Claude Code

davidharrishmc and others added 14 commits October 10, 2026 06:19
Fix spelling, grammar, and wrong or garbled comments; normalize
indentation and operator spacing; and add short comments explaining
hard-to-follow control-bit logic, especially in the FPU. Code tokens
are unchanged. Delete eight modules that are never instantiated.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…dh/sv-cosmetics

Resolve the src/cache/cache.sv conflict by taking openhwfoundation#1948's code (OFFSETLEN
and SETLEN as parameters, NextSet sized OFFSETLEN+SETLEN) and keeping this
branch's comment/whitespace cleanup.  The NextSet comment no longer says
"lower 12 bits", and the new localparams openhwfoundation#1948 added to ifu.sv and lsu.sv
get aligned comments.  After stripping comments and whitespace, every src/
file still matches main.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
Restore fdivsqrtuslc4, prioritythermometer, ram2p1r1wbe_128x64 and
ram2p1r1wbe_2048x64 as they are on main, and put the two RAMs back in
run_vcs's list of memories generated per FPGA target.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
Revert capitalization-only, punctuation-only, and no-gain rewording
edits, restore contributors' informal notes, and keep commented-out code
such as the rom1p1r bootloader initialization and the RAM preload
blocks. Spelling fixes, corrections to wrong comments, added explanatory
comments, and whitespace consistency stay.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Keep alternate designs, the ROM bootloader initialization, and
optimization notes; drop superseded one-liners, dead predictor flops,
and blocks that reference signals that no longer exist.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add a definition comment to the 1,430 ports that lacked one and make
comments for the same signal consistent across modules, keeping a
module-specific comment only where the name means something different.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Cosmetic and structural cleanup on top of the port-comment work, with no
intended change in behavior.

- `define -> localparam: CTRLW, BMUCTRLW, FCTRLW, INSTR_CLASS_PRED and the
  PLIC context count become localparams, and control-word literals use
  sized 24'b/21'b/14'b constants.
- Named constants: P.*_FMT case labels in the FPU, RM_* rounding modes,
  POSTPROC_* postprocessor selects, RESULTSRC_* encodings, CMO_* cbo bit
  positions, ICLASS_* and REGION_* one-hot bit positions, KILOPAGE..
  PETAPAGE page types, compressed-opcode and SIZE_* masks, SINT_MASK.
  Package-level constants sit inside a lint_off UNUSEDPARAM block.
- Dead-code removal: unused signals, ports and flops (e.g. fdivsqrt un,
  NegQuotM, AZeroE, ZeM, zknde32 round, unused SDC/HPTW delays).
- Typo renames: SelecteDirty, HPTWAccesFaultReg, WordAdrrMux, RestorMux,
  presresultmux, ADDR_WDITH, ziccslm_align, SelectedWiteWordEn tag;
  LeftShiftQm -> RightShiftQm; else-branch generate blocks get no* names
  so they no longer duplicate the active branch's name.
- 2-space nesting and whitespace alignment.
- Dedup: unpackinput exponent re-bias, flags ShiftGtIntSz, fhazard
  forwarding, aes64ks1i result, rev8 via byteop.
- CLINT and UART register offsets use their named constants.
- sim/questa/coverage-exclusions-rv64gc.do tracks the renamed exclusion
  tag, and examples/exercises/7p12/buga.sh edits the CTRLW localparam.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Conflicts were main's logic changes in lines this branch re-indented or
re-commented; each keeps main's code with this branch's formatting:
- fdivsqrtfsm.sv, div.sv: FlushE & ~StallM (openhwfoundation#1925) and its comment; the
  fdivsqrtfsm DONE-state exclusion tag stays removed
- controller.sv: sfence.inval.ir refetch (openhwfoundation#1929)
- tlbcamline.sv: TLBWrite/WritePTE_G/WritePTE_NAPOT ports (openhwfoundation#1927)
- tlbcontrol.sv: ~UpperBitsUnequal in TLBMiss (openhwfoundation#1928), new BadNAPOT comment
- csrc.sv: time/timeh read only with Zicntr (openhwfoundation#1951)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
Comment the ports main added: hptw ENVCFG_PBMTE, and TLBWrite,
WritePTE_G and WritePTE_NAPOT in tlbcam and tlbcamline (one per line).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
Keep main's Match0Upper factoring (shared with Overlap) and its Zicntr
gating of time/timeh, with this branch's KILOPAGE constant and spacing;
use KILOPAGE in the new Overlap term too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: David Harris <David_Harris@hmc.edu>
@davidharrishmc

Copy link
Copy Markdown
Contributor Author

Review notes: every logic-text change is value-identical or removes dead logic, and today's main merge kept main's new code. The body needs a few corrections:

  • It says INSTR_CLASS_PRED became a localparam, but c38e316 put it back: `define INSTR_CLASS_PRED 1 is still at src/ifu/bpred/bpred.sv:30.
  • It says pipeline register widths are unchanged, but fpu.sv:358 narrows EMFpReg4 from P.FLEN to P.NF+1 (dropping the dead ZeM bits).
  • Not mentioned: deleting mux6/mux7 from src/generic/mux.sv; the rom1p1r_128x32.sv:36 macro name change from generic64x128ROM to generic128x32ROM (a correct placeholder fix); the generate-block renames that change hierarchy paths (noflushlogic, nobpred, nodecomp, nocboz, notlb, zicclsm_align), which nothing in the repo references but external wave/ILA scripts might; and the csrindextoaddr rewrite.
  • Nits: csrindextoaddr.sv sizes CSR_ADDR [36] while TOTAL_CSRS is a parameter, so a larger TOTAL_CSRS would index out of bounds (every instantiation uses 36). tlb.sv:116 still compares HitPageType == 3'b000 instead of KILOPAGE.
  • Merge strictly Clean up comments and whitespace in src/; delete unused modules #1952 → Comment every module port consistently #1955 → Style follow-up: localparams, named constants, dead code, typo renames, consistent nesting #1959 so each delta shows on its own (227 files cumulatively).

🤖 Generated with Claude Code

# Conflicts:
#	src/hazard/hazard.sv
#	src/privileged/csr.sv
#	src/privileged/privdec.sv
@davidharrishmc

Copy link
Copy Markdown
Contributor Author

Merge order: this is part of the cosmetic stack, merged strictly #1952 → #1955 → #1959 so each delta shows on its own. Merge the open bug-fix PRs first: #1949, #1958, #1967, #1969, #1972, #1982, #1986 and #1987. The stack conflicts textually with them, and re-applying formatting is easier than re-applying fixes.

🤖 Generated with Claude Code

davidharrishmc and others added 4 commits October 16, 2026 03:35
# Conflicts:
#	src/hazard/hazard.sv
#	src/mmu/hptw.sv
#	src/privileged/csr.sv
#	src/privileged/csrc.sv
#	src/privileged/privdec.sv
#	src/privileged/privileged.sv
#	src/privileged/trap.sv
LSUHREADY = HREADY & ~LSUDisable, and the arbiter sets LSUDisable while the
IFU holds the bus, so the port comment saying it is never gated was wrong.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	src/hazard/hazard.sv
#	src/lsu/lsu.sv
… address table

NAPOT4 compared HitPageType with a literal 3'b000 where the rest of the TLB uses
the page-type constants.  csrindextoaddr's address table has 36 entries while
TOTAL_CSRS is a parameter, so a larger TOTAL_CSRS would index past the table;
stop elaboration with an error instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidharrishmc

Copy link
Copy Markdown
Contributor Author

Updated per review:

🤖 Generated with Claude Code

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.

1 participant