prim_ram_1p_scr_ext

Scramble a single-port SRAM front-end over prim_ram_1p_adv_ext tiles.

Refuse to grant req_i while key_valid_i is low. intg_error_i suppresses any real memory transaction on an upstream integrity fault.

Delay writes one cycle so reads and writes share the PRINCE keystream unit. Hold a pending write across a following read and detect address collisions; a colliding read returns the masked bytes of the pending write data. Read data returns one cycle after the grant. The inner RAM runs without ECC, so rerror_o can only report parity errors.

Keep cipher rounds low for latency. PRINCE's original 5 half-rounds are 2*5+1 effective rounds; NUM_PRINCE_ROUNDS_HALF of 3 is about 7 effective rounds and must be in [1..5].

NUM_DIFF_ROUNDS of 0 disables diffusion because non-linear data diffusion can interact adversely with end-to-end ECC. Enable it only with full knowledge of that interaction, for example with byte parity.

Parameters

Table 1. Parameters
NameTypeDefaultDescription
DEPTHint16*1024Logical depth; must be a power of 2 if NUM_ADDR_SCR_ROUNDS > 0.
INST_DEPTHintDEPTHPer-tile depth for RAM tiling.
WIDTHint32Data width; must be byte-aligned when byte parity is enabled.
DATA_BITS_PER_MASKint8Must be 8 when byte parity is enabled.
ENABLE_PARITYbit0Enables byte parity.
NUM_PRINCE_ROUNDS_HALFint3PRINCE half-rounds in [1..5]; kept low for latency. Original PRINCE uses 5 half-rounds (2*5+1 effective); 3 is about 7 effective rounds.
NUM_DIFF_ROUNDSint0Extra diffusion rounds; 0 disables diffusion. Default 0 because non-linear data diffusion can interact adversely with end-to-end ECC; enable only with full knowledge of that interaction (for example with byte parity).
DIFF_WIDTHintDATA_BITS_PER_MASKDiffusion block width; at least 4, and 8 with parity. Use 8 for intra-byte diffusion.
NUM_ADDR_SCR_ROUNDSint2Address scrambling rounds; 0 disables address scrambling.
REPLICATE_KEY_STREAMbit1'b01 replicates the same 64-bit keystream across a wider data port; 0 replicates the cipher with a wider nonce for a unique keystream across the full width.
AddrWidthintprim_util_pkg::vbits(DEPTH)Logical address width; derived.
NumParScrint(REPLICATE_KEY_STREAM) ? 1 : (WIDTH + 63) / 64Parallel PRINCE instances so the keystream covers WIDTH; PRINCE block size is 64 bits.
NumParKeystrint(REPLICATE_KEY_STREAM) ? (WIDTH + 63) / 64 : 1Parallel keystream replicas when REPLICATE_KEY_STREAM is set.
DataKeyWidthint128Scrambling key width from PRINCE; all parallel ciphers share the key with different IVs.
NonceWidthint64 * NumParScrNonce width; each 64-bit scrambling primitive needs a 64-bit IV.
NumRamInstintprim_util_pkg::ceil_div(DEPTH, INST_DEPTH)Number of tiled RAM instances.

Ports

Table 2. Ports
NameDirectionTypeDescription
clk_iinputMemory clock.
rst_niinputAsync reset, active-low.
key_valid_iinputScrambling key is live; requests are not granted while low.
key_iinput[DataKeyWidth-1:0]Scrambling key.
nonce_iinput[NonceWidth-1:0]Scrambling nonce; the top AddrWidth bits key address scrambling and the low bits form the keystream IVs.
req_iinputUnscrambled access request.
gnt_ooutputlogicRequest grant; req_i gated combinationally by key_valid_i.
write_iinputWrite when high, read when low.
addr_iinput[AddrWidth-1:0]Logical address before scramble.
wdata_iinput[WIDTH-1:0]Plaintext write data.
wmask_iinput[WIDTH-1:0]Write mask; must be byte-aligned for parity.
intg_error_iinputSuppresses any real memory transaction on an integrity fault and kills the matching read response.
rdata_ooutputlogic [WIDTH-1:0]Descrambled read data; 0 while rvalid_o is low.
rvalid_ooutputlogicRead response (rdata_o) is valid.
rerror_ooutputlogic [1:0]Bit1 flags a parity error; bit0, correctable, is always 0.
raddr_ooutputlogic [AddrWidth-1:0]Unscrambled address of the last granted read, for error reporting.
wr_collision_ooutputlogicRead hits a pending write address; valid with rvalid_o.
write_pending_ooutputlogicHigh while a write is granted or a delayed write is being committed to memory.
alert_ooutputlogicInvalid MuBi4 encoding on an internal control signal, including those of the inner RAM.
ram_req_ooutputram_req_t [NumRamInst-1:0]Per-tile external RAM requests from the inner prim_ram_1p_adv_ext.
ram_rsp_iinputram_rsp_t [NumRamInst-1:0]Per-tile external RAM responses.