Skip to content

Commit a52764d

Browse files
Clear FIFO reset after reset execution
Internal-tag: [#74403]
1 parent 65a6517 commit a52764d

File tree

7 files changed

+37
-26
lines changed

7 files changed

+37
-26
lines changed

src/csr/I3CCSR.sv

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5564,12 +5564,15 @@ module I3CCSR (
55645564
automatic logic load_next_c;
55655565
next_c = field_storage.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.value;
55665566
load_next_c = '0;
5567-
if(decoded_reg_strb.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0 && decoded_req_is_wr) begin // SW write 1 clear
5568-
next_c = field_storage.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.value & ~(decoded_wr_data[15:8] & decoded_wr_biten[15:8]);
5567+
if(decoded_reg_strb.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0 && decoded_req_is_wr) begin // SW write
5568+
next_c = (field_storage.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.value & ~decoded_wr_biten[15:8]) | (decoded_wr_data[15:8] & decoded_wr_biten[15:8]);
55695569
load_next_c = '1;
55705570
end else if(hwif_in.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.we) begin // HW Write - we
55715571
next_c = hwif_in.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.next;
55725572
load_next_c = '1;
5573+
end else if(hwif_in.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.hwclr) begin // HW Clear
5574+
next_c = '0;
5575+
load_next_c = '1;
55735576
end
55745577
field_combo.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.next = next_c;
55755578
field_combo.I3C_EC.SecFwRecoveryIf.INDIRECT_FIFO_CTRL_0.RESET.load_next = load_next_c;

src/csr/I3CCSR_pkg.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ package I3CCSR_pkg;
497497
typedef struct packed{
498498
logic [7:0] next;
499499
logic we;
500+
logic hwclr;
500501
} I3CCSR__I3C_EC__SecFwRecoveryIf__INDIRECT_FIFO_CTRL_0__RESET__in_t;
501502

502503
typedef struct packed{

src/csr/I3CCSR_uvm.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ package I3CCSR_uvm;
24232423
this.CMS = new("CMS");
24242424
this.CMS.configure(this, 8, 0, "RW", 1, 'h0, 1, 1, 0);
24252425
this.RESET = new("RESET");
2426-
this.RESET.configure(this, 8, 8, "W1C", 1, 'h0, 1, 1, 0);
2426+
this.RESET.configure(this, 8, 8, "RW", 1, 'h0, 1, 1, 0);
24272427
if (has_coverage(UVM_CVR_REG_BITS)) begin
24282428
foreach(CMS_bit_cg[bt]) CMS_bit_cg[bt] = new();
24292429
foreach(RESET_bit_cg[bt]) RESET_bit_cg[bt] = new();

src/rdl/docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,10 +1772,10 @@ When set to 0, it holds execution of enqueued commands and runs current command
17721772
- Base Offset: 0x48
17731773
- Size: 0x4
17741774

1775-
|Bits|Identifier| Access |Reset| Name |
1776-
|----|----------|---------|-----|------------------------------------------|
1777-
| 7:0| CMS | rw | 0x0 |Indirect FIFO memory access configuration.|
1778-
|15:8| RESET |rw, woclr| 0x0 | Indirect memory configuration - reset |
1775+
|Bits|Identifier|Access|Reset| Name |
1776+
|----|----------|------|-----|------------------------------------------|
1777+
| 7:0| CMS | rw | 0x0 |Indirect FIFO memory access configuration.|
1778+
|15:8| RESET | rw | 0x0 | Indirect memory configuration - reset |
17791779

17801780
#### CMS field
17811781

src/rdl/secure_firmware_recovery_interface.rdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ regfile SecureFirmwareRecoveryInterfaceRegisters{
570570
sw = rw;
571571
hw = rw;
572572
we = true;
573-
onwrite = woclr;
573+
hwclr = true;
574574
reset = 8'h00;
575575
} RESET[15:8];
576576
} INDIRECT_FIFO_CTRL_0;

src/recovery/recovery_executor.sv

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,19 @@ module recovery_executor
630630
hwif_rec_o.INDIRECT_FIFO_CTRL_1.IMAGE_SIZE.next = tti_rx_rdata_i[31:0];
631631
end
632632

633+
logic fifo_reset_clear;
634+
assign hwif_rec_o.INDIRECT_FIFO_CTRL_0.RESET.hwclr = fifo_reset_clear;
635+
636+
always_ff @(posedge clk_i or negedge rst_ni) begin
637+
if (~rst_ni) begin
638+
fifo_reset_clear <= '0;
639+
end else if (hwif_rec_i.INDIRECT_FIFO_CTRL_0.RESET.value) begin
640+
fifo_reset_clear <= 1'b1;
641+
end else begin
642+
fifo_reset_clear <= '0;
643+
end
644+
end
645+
633646
// Force the value of FIFO_STATUS.FIFO_SIZE to IndirectFifoDepth.
634647
always_comb begin
635648
hwif_rec_o.INDIRECT_FIFO_STATUS_3.FIFO_SIZE.next = IndirectFifoDepth;

verification/cocotb/top/lib_i3c_top/test_recovery.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ async def test_write(dut):
348348
# Check
349349
protocol_status = (status >> 8) & 0xFF
350350
assert protocol_status == 0
351-
assert data0 == 0xBBAA # 2 MSBs are reserved
351+
assert data0 == 0xAA # 2 MSBs are reserved, 3rd MSB is W1C
352352
assert data1 == 0x44332211
353353

354354

@@ -833,7 +833,7 @@ async def test_virtual_read(dut):
833833
data, pec_ok = await recovery.command_read(VIRT_DYNAMIC_ADDR, cmd)
834834

835835
is_nack = data == None and pec_ok == None
836-
pec_ok = bool(pec_ok)
836+
pec_ok = bool(pec_ok)
837837

838838
if is_nack:
839839
dut._log.info("NACK")
@@ -962,9 +962,12 @@ async def test_payload_available(dut):
962962
# Initialize
963963
i3c_controller, i3c_target, tb, recovery = await initialize(dut, timeout=200)
964964

965-
fifo_size = dword2int(
966-
await tb.read_csr(tb.reg_map.I3C_EC.SECFWRECOVERYIF.INDIRECT_FIFO_STATUS_3.base_addr, 4)
967-
) * 4 # Multiply by 4 to get bytes from dwords
965+
fifo_size = (
966+
dword2int(
967+
await tb.read_csr(tb.reg_map.I3C_EC.SECFWRECOVERYIF.INDIRECT_FIFO_STATUS_3.base_addr, 4)
968+
)
969+
* 4
970+
) # Multiply by 4 to get bytes from dwords
968971

969972
# set regular device dynamic address
970973
await i3c_controller.i3c_ccc_write(
@@ -1100,16 +1103,14 @@ async def test_indirect_fifo_reset_access(dut):
11001103
VIRT_DYNAMIC_ADDR, I3cRecoveryInterface.Command.INDIRECT_FIFO_DATA, tx_data_before_reset
11011104
)
11021105

1103-
# Clear FIFO (pointers too)
1104-
await recovery.command_write(
1105-
VIRT_DYNAMIC_ADDR, I3cRecoveryInterface.Command.INDIRECT_FIFO_CTRL, [0x00, 0x01, 0x00, 0x00]
1106-
)
1106+
# Wait until data propagates to Indirect FIFO
1107+
await ClockCycles(tb.clk, tx_data_length)
11071108

1108-
# Clear FIFO reset
1109+
# Clear FIFO (pointers too)
11091110
await tb.write_csr_field(
11101111
tb.reg_map.I3C_EC.SECFWRECOVERYIF.INDIRECT_FIFO_CTRL_0.base_addr,
11111112
tb.reg_map.I3C_EC.SECFWRECOVERYIF.INDIRECT_FIFO_CTRL_0.RESET,
1112-
0xFF,
1113+
0x1,
11131114
)
11141115

11151116
# Write data to indirect FIFO through the recovery interface
@@ -1227,13 +1228,6 @@ async def bfm_agent():
12271228

12281229
assert (wrptr, rdptr) == (0, 0)
12291230

1230-
# Clear FIFO reset
1231-
await tb.write_csr_field(
1232-
tb.reg_map.I3C_EC.SECFWRECOVERYIF.INDIRECT_FIFO_CTRL_0.base_addr,
1233-
tb.reg_map.I3C_EC.SECFWRECOVERYIF.INDIRECT_FIFO_CTRL_0.RESET,
1234-
0xFF,
1235-
)
1236-
12371231
# Send firmware chunks
12381232
xfer_size = 4
12391233
for data_ptr in range(0, image_size, xfer_size * 4):

0 commit comments

Comments
 (0)