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
| Name | Type | Default | Description |
|---|---|---|---|
SRAM_ADDR_WIDTH | int unsigned | KM_SRAM_MEM_ADDR_WIDTH | SRAM word-address width; must be 13 to match scrambler_8192x32. |
SRAM_NUM_LOCK_REGIONS | int unsigned | km_intf_pkg::SramNumLockRegions | Number of write-lock regions, each SramLockRegionBytes long. |
Ports
| Name | Direction | Type | Description |
|---|---|---|---|
clk_i | input | logic | System clock. |
rst_ni | input | logic | Active-low asynchronous reset. |
mem_valid_i | input | logic | PicoRV32 native memory request valid (from CPU). |
mem_ready_o | output | logic | Memory ready: read data valid, write granted, or write to a locked region dropped. |
mem_addr_i | input | logic [31:0] | Byte address. |
mem_wdata_i | input | logic [31:0] | Write data. |
mem_wstrb_i | input | logic [3:0] | Write strobe (non-zero = write). |
mem_rstrb_i | input | logic [3:0] | Read strobe: byte lanes consumed by the CPU, which select the parity-checked lanes. |
mem_rdata_o | output | logic [31:0] | Read data. |
mem_la_read_i | input | logic | Look-ahead read signal (1 cycle before mem_valid). |
mem_la_addr_i | input | logic [31:0] | Look-ahead address. |
mem_la_rstrb_i | input | logic [3:0] | Look-ahead read strobe; selects the parity-checked lanes of a look-ahead fetch. |
sram_mem_req_o | output | km_sram_mem_req_t | SRAM memory request, exposed at the subsystem boundary. |
sram_mem_rsp_i | input | km_sram_mem_rsp_t | SRAM memory response. |
scrambler_key_i | input | logic [31:0] | Scrambler key from KMCSR. |
scrambler_en_i | input | logic | Scrambler enable from KMCSR; high scrambles the address and write data and descrambles read data. |
sram_lock_bits_i | input | logic [SRAM_NUM_LOCK_REGIONS-1:0] | SRAM write-lock from KMCSR: bit[i]=1 locks region i. |
parity_error_o | output | logic | Combinational; high while a valid read response fails parity on a strobed lane after descrambling. |
write_lock_violation_region_o | output | logic [SRAM_NUM_LOCK_REGIONS-1:0] | One-hot region of a write presented to a locked region; combinational. |