km_sram_interface

Adapt the PicoRV32 native memory interface to the SRAM with scrambling, parity and write-lock support.

Bridges the PicoRV32 native memory interface to the standard SRAM memory interface (km_sram_mem_req_t / km_sram_mem_rsp_t).

Features:

  • Optional address/data scrambling via scrambler_8192x32, controlled by scrambler_key_i / scrambler_en_i from KMCSR.
  • Odd-parity generation on the write path and checking on the read path; parity is computed before scrambling.
  • Per-region write-lock (SramLockRegionBytes per region, so SRAM_NUM_LOCK_REGIONS is SramSizeBytes / SramLockRegionBytes): writes to a locked region are silently dropped but still acknowledged, and write_lock_violation_region_o reports to KMCSR which region had an attempted write while locked.
  • Requests are held off for two cycles after reset release.
  • PicoRV32 look-ahead prefetch support for pipelined SRAM.

The SRAM must return rvalid at least one cycle after accepting a read: the response is descrambled and parity-checked with the address and strobes captured at the accept.

Parameters

Table 1. Parameters
NameTypeDefaultDescription
SRAM_ADDR_WIDTHint unsignedKM_SRAM_MEM_ADDR_WIDTHSRAM word-address width; must be 13 to match scrambler_8192x32.
SRAM_NUM_LOCK_REGIONSint unsignedkm_intf_pkg::SramNumLockRegionsNumber of write-lock regions, each SramLockRegionBytes long.

Ports

Table 2. Ports
NameDirectionTypeDescription
clk_iinputlogicSystem clock.
rst_niinputlogicActive-low asynchronous reset.
mem_valid_iinputlogicPicoRV32 native memory request valid (from CPU).
mem_ready_ooutputlogicMemory ready: read data valid, write granted, or write to a locked region dropped.
mem_addr_iinputlogic [31:0]Byte address.
mem_wdata_iinputlogic [31:0]Write data.
mem_wstrb_iinputlogic [3:0]Write strobe (non-zero = write).
mem_rstrb_iinputlogic [3:0]Read strobe: byte lanes consumed by the CPU, which select the parity-checked lanes.
mem_rdata_ooutputlogic [31:0]Read data.
mem_la_read_iinputlogicLook-ahead read signal (1 cycle before mem_valid).
mem_la_addr_iinputlogic [31:0]Look-ahead address.
mem_la_rstrb_iinputlogic [3:0]Look-ahead read strobe; selects the parity-checked lanes of a look-ahead fetch.
sram_mem_req_ooutputkm_sram_mem_req_tSRAM memory request, exposed at the subsystem boundary.
sram_mem_rsp_iinputkm_sram_mem_rsp_tSRAM memory response.
scrambler_key_iinputlogic [31:0]Scrambler key from KMCSR.
scrambler_en_iinputlogicScrambler enable from KMCSR; high scrambles the address and write data and descrambles read data.
sram_lock_bits_iinputlogic [SRAM_NUM_LOCK_REGIONS-1:0]SRAM write-lock from KMCSR: bit[i]=1 locks region i.
parity_error_ooutputlogicCombinational; high while a valid read response fails parity on a strobed lane after descrambling.
write_lock_violation_region_ooutputlogic [SRAM_NUM_LOCK_REGIONS-1:0]One-hot region of a write presented to a locked region; combinational.