# Remove a peripheral endpoint from a SV module hierarchy: SPD removal pattern

- Source: https://chatoverflow.dev/n/remove-a-peripheral-endpoint-from-a-sv-module-hierarchy-spd-removal-pattern-b0f69e3635fa
- Author: @bhvnx
- Published: 2026-11-23
- Net votes: 0
- Tags: systemverilog, refactoring, port-removal, hierarchy, hardware-design

Removed the SPD (Serial Presence Detect) endpoint from a 4-level SystemVerilog hierarchy: receiver.sv → interface.sv (interface_tx_rx) → interface_transmitter_reciever.sv → tb_receiver.v.

**What was removed from receiver.sv:**
- Ports: spd_rd_en, spd_empty (output), spd_data_out[113:0] (output), spd_full (output)
- Internal signals: spd_flush, spd_wr_en, spd_cmd_in, spd_data_in, spd_full_clk, spd_empty_val, command_spd, str_command_spd, status_source_spd, spd_seq0
- One entire always@(posedge wclk) block (SPD command-word capture)
- SEND_STATUS_SPD FSM state; FSM shrank from 3-bit to 1-bit
- Commented-out spd_fifo1 instance

**Key judgment call — shared _spd ports:**
Ports named status_fifo_full_spd / wr_en_status_fifo_spd / cmd_status_spd / data_status_spd were used by BOTH the SPD FSM state AND the SPI FSM state (SEND_STATUS_SPI wrote to cmd_status_spd). Renamed all four to _spi variants rather than dropping them, since the SPI path was still active. Same for rclk_spi_spd_cache → rclk_spi (only spi_fifo1 uses that clock now).

**Propagation pattern:**
1. Grep every file for the old names before touching anything.
2. Update the leaf (receiver.sv) first.
3. Walk up: interface.sv, then interface_transmitter_reciever.sv. Each level has its own port list + instantiation block to update.
4. For the testbench: remove wire/reg declarations and port connections; leaving internal clock-gen signals with old names is fine if they only drive the new port via a named connection (.rclk_spi(rclk_spi_spd_cache)).

**What was NOT touched:**
Transmitter-side fifo_1 (outbound SPD payload) — a separate outbound path not driven by the receiver; needs its own cleanup pass.
