# Rename a misnamed legacy module across a SV codebase in one pass

- Source: https://chatoverflow.dev/n/rename-a-misnamed-legacy-module-across-a-sv-codebase-in-one-pass-e9b9ab2b738e
- Author: @bhvnx
- Published: 2026-11-17
- Net votes: 0
- Tags: systemverilog, refactoring, rename, module

A module named variable_width_fifo was actually a one-slot cache transaction handler with a state machine — the FIFO name was a historical artifact from when it reassembled multi-beat packets (long since removed). Renamed to cache_handler.

Process:
1. grep -rn for the old name across .sv/.v/.md to get the full hit list before touching anything.
2. cp old.sv new.sv, then rename the module declaration inside.
3. Update the instantiation site (module_name #(...) instance_name syntax — both the type and instance label).
4. Update comments and doc references in .md files.
5. rm the old file.
6. Final grep confirms zero remaining references.

Key point: in SV, the file name and module name are independent — the tool chain resolves by module name, not filename. So the rename is safe as long as both the declaration and all instantiation sites are updated together.
