--------------------------------------------------------------------------------
CPU Bus interface layer
--------------------------------------------------------------------------------
The CPU interface layer connects the selected SoC bus protocol to the shared
address decoder and routed child interfaces. It is not a register-file engine
or a universal fixed-latency strobe bridge.

Ports and signal references:
    BaseCpuif selects flat_interface_cls or sv_interface_cls using
    use_sv_interface. The Interface helpers emit both the upstream endpoint and
    every downstream endpoint, including rolled and unrolled array dimensions.
    Customize an existing SVInterface subclass for interface types, modports,
    and signal spelling rather than overriding a slave-only port declaration.

    DesignState.get_target_name(node) allocates the canonical identity used by
    ports, address-width constants, and references for every protocol. Unique
    local names stay short; colliding names use flattened hierarchy paths and
    suffixes as needed. Do not introduce adapter-local name allocation.

Shared decode signals:
    cpuif_req qualifies decode activity. cpuif_wr_en/cpuif_rd_en qualify the
    write/read address lanes cpuif_wr_addr/cpuif_rd_addr, expressed as byte
    addresses. The decoder produces direction-qualified child selections and
    a local-error selection. These signals are not necessarily one-cycle
    request pulses; acceptance and retention belong to the protocol adapter.

    cpuif_wr_data/cpuif_wr_byte_en carry the protocol's write payload and byte
    enables. Response wires include cpuif_wr_ack/cpuif_wr_err and
    cpuif_rd_ack/cpuif_rd_err/cpuif_rd_data. Their qualification follows the
    adapter's response phase, not a fixed latency from the live address.
    Separate internal address lanes do not expose a standalone option for
    different custom read/write address layouts.

Protocol state:
    APB3 and APB4:
        Share the cpuif.apb implementation. PWRITE qualifies the common
        address; the upstream manager holds the transfer through wait states.
        Optional transaction-aware buffering retains the SETUP payload and/or
        completed response. Ownership state retires the child exactly once,
        even while a registered response awaits upstream acceptance.

    AXI4-Lite:
        AW and W have independent one-entry holding registers. Paired writes
        and reads enter separate bounded order queues. Issue selection and
        response-head selection are distinct, so responses follow accepted
        request order in each direction. This is not full AXI4 with IDs/bursts.

    Single-manager AHB-Lite:
        One shared address/data pipeline serves reads and writes. Address
        decode uses live HADDR/HWRITE, but destination, direction, and validity
        advance only when HREADY is high. The response mux uses that retained
        data phase while the next address is visible. HWDATA remains the live
        data for the preceding accepted write, not data captured with its
        address. Local misses return not-ready/ERROR then ready/ERROR; mapped
        child errors and wait states pass through unchanged.

Clock/reset:
    clk_src accepts off, cpuif, and design. The exporter resolves omitted/None
    to off for APB with apb_buffer=none, preserving the 0.7.x clockless decoder
    ports (no clk/rst, standalone PCLK/PRESETn, or clock/reset forwarding).
    Buffered APB and AXI4-Lite resolve omitted/None to design.

    APB and AXI4-Lite select explicit clk/rst with --clk-src design or ingress
    protocol clock/reset with --clk-src cpuif. Flat cpuif-clocked variants
    expose ingress clock/reset inputs and child clock/reset outputs; SV
    interface members remain inputs and are connected externally to the same
    domain. APB buffering requires design, selected automatically if omitted;
    explicit off/cpuif with buffering is rejected. AXI4-Lite rejects off.

    AHB-Lite always uses ingress HCLK/HRESETn, without separate clk/rst ports
    or child clock/reset outputs. design/cpuif are accepted but ignored; off
    is rejected. Omit the option or select design/cpuif and wire ingress plus
    every child externally to that same domain.

Implementation:
    Protocol logic is rendered by Jinja templates. Use cpuif.signal(...) for
    endpoint references rather than spelling flat or SV names in templates.
    The current handshake and timing contract is documented in
    docs/cpuif/internal_protocol.rst and the individual protocol guides.
