Skip to content

Commit 1c53a3d

Browse files
gautschimivogelpi
authored andcommitted
[flash_ctrl,dv] byte/word scrambling addr fix
FlashAddrWidth is in flash words (not bytes). Passing a byte address to a function which expects word-addresses leads to a truncation of the three most significant address bits. As a result, when accessing the upper part of each flash bank the scrambling tweak was wrong which lead to a wrong data encryption and hence also to a wrong ICV calculation for the expected responses. Signed-off-by: Michael Gautschi <[email protected]> (cherry picked from commit d3aa4e9)
1 parent 0ec7367 commit 1c53a3d

File tree

6 files changed

+6
-10
lines changed

6 files changed

+6
-10
lines changed

hw/ip_templates/flash_ctrl/dv/env/flash_ctrl_env_pkg.sv

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ package flash_ctrl_env_pkg;
408408
bit [FlashDataWidth-1:0] masked_data;
409409
bit [FlashNumRoundsHalf-1:0][FlashDataWidth-1:0] scrambled_data;
410410

411-
// These parameters will be removed once it is included in mem_bkdr_util.sv
412-
int addr_lsb = 3;
413-
414-
word_addr = byte_addr >> addr_lsb;
411+
word_addr = byte_addr >> FlashDataByteWidth;
415412
mask = flash_galois_multiply(flash_addr_key, word_addr);
416413
masked_data = data ^ mask;
417414
crypto_dpi_prince_pkg::sv_dpi_prince_encrypt(.plaintext(masked_data), .key(flash_data_key),

hw/ip_templates/flash_ctrl/dv/env/flash_otf_item.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class flash_otf_item extends uvm_object;
139139
data = raw_fq[i][FlashDataWidth-1:0];
140140
if (ecc_en) begin
141141
data_with_icv = prim_secded_pkg::prim_secded_hamming_72_64_enc(raw_fq[i][63:0]);
142+
`uvm_info("icv", $sformatf("ICV:%4b", data_with_icv[67:64]), UVM_DEBUG)
142143
if (add_icv_err) begin
143144
`uvm_info("icv_debug", $sformatf("before:%4b after:%4b",
144145
data_with_icv[67:64], ~data_with_icv[67:64]), UVM_DEBUG)

hw/ip_templates/flash_ctrl/dv/flash_ctrl_base_sim_cfg.hjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
name: flash_ctrl_rw_evict_all_en
349349
uvm_test_seq: flash_ctrl_rw_evict_vseq
350350
run_opts: ["+scb_otf_en=1", "+ecc_mode=1", "+en_always_read=1",
351-
"+en_always_prog=1", "en_rnd_data=0"]
351+
"+en_always_prog=1", "+en_rnd_data=0"]
352352
reseed: 40
353353
}
354354
{

hw/top_earlgrey/ip_autogen/flash_ctrl/dv/env/flash_ctrl_env_pkg.sv

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ package flash_ctrl_env_pkg;
408408
bit [FlashDataWidth-1:0] masked_data;
409409
bit [FlashNumRoundsHalf-1:0][FlashDataWidth-1:0] scrambled_data;
410410

411-
// These parameters will be removed once it is included in mem_bkdr_util.sv
412-
int addr_lsb = 3;
413-
414-
word_addr = byte_addr >> addr_lsb;
411+
word_addr = byte_addr >> FlashDataByteWidth;
415412
mask = flash_galois_multiply(flash_addr_key, word_addr);
416413
masked_data = data ^ mask;
417414
crypto_dpi_prince_pkg::sv_dpi_prince_encrypt(.plaintext(masked_data), .key(flash_data_key),

hw/top_earlgrey/ip_autogen/flash_ctrl/dv/env/flash_otf_item.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class flash_otf_item extends uvm_object;
139139
data = raw_fq[i][FlashDataWidth-1:0];
140140
if (ecc_en) begin
141141
data_with_icv = prim_secded_pkg::prim_secded_hamming_72_64_enc(raw_fq[i][63:0]);
142+
`uvm_info("icv", $sformatf("ICV:%4b", data_with_icv[67:64]), UVM_DEBUG)
142143
if (add_icv_err) begin
143144
`uvm_info("icv_debug", $sformatf("before:%4b after:%4b",
144145
data_with_icv[67:64], ~data_with_icv[67:64]), UVM_DEBUG)

hw/top_earlgrey/ip_autogen/flash_ctrl/dv/flash_ctrl_base_sim_cfg.hjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@
348348
name: flash_ctrl_rw_evict_all_en
349349
uvm_test_seq: flash_ctrl_rw_evict_vseq
350350
run_opts: ["+scb_otf_en=1", "+ecc_mode=1", "+en_always_read=1",
351-
"+en_always_prog=1", "en_rnd_data=0"]
351+
"+en_always_prog=1", "+en_rnd_data=0"]
352352
reseed: 40
353353
}
354354
{

0 commit comments

Comments
 (0)