Skip to content

Commit d4e2131

Browse files
[fuse_ctrl, test] Remove hardcoded addresses from tb services
Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org>
1 parent 98ebd38 commit d4e2131

File tree

3 files changed

+68
-48
lines changed

3 files changed

+68
-48
lines changed

src/integration/test_suites/caliptra_ss_fuse_ctrl_interrupts/caliptra_ss_fuse_ctrl_interrupts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void main (void) {
5757
* 1: An ordinary, successful DAI operation must result in an `otp_operation_done` interrupt.
5858
*/
5959

60-
dai_wr(CPTRA_CORE_MANUF_DEBUG_UNLOCK_TOKEN, 0x1, 0, 32, 0);
60+
dai_wr(CPTRA_SS_MANUF_DEBUG_UNLOCK_TOKEN, 0x1, 0, 32, 0);
6161

6262
uint32_t alert_state = lsu_read_32(SOC_OTP_CTRL_INTERRUPT_STATE);
6363
if (((alert_state >> OTP_CTRL_INTERRUPT_STATE_OTP_OPERATION_DONE_LOW) & 0x1 != 0x1) ||

src/integration/test_suites/caliptra_ss_fuse_ctrl_test_unlocked0_prov/caliptra_ss_fuse_ctrl_test_unlocked0_prov.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ void test_unlocked0_provision() {
6666
VPRINTF(LOW, "ERROR: incorrect value: exp: %08X act: %08X\n", read_value, sentinel);
6767
}
6868

69-
if (!partitions[i].is_secret) {
69+
if (partitions[i].sw_digest) {
7070
dai_wr(partitions[i].digest_address, sentinel, 0, 64, 0);
71-
} else {
71+
} else if (partitions[i].hw_digest) {
7272
calculate_digest(partitions[i].address);
7373
}
7474
}
@@ -83,9 +83,11 @@ void test_unlocked0_provision() {
8383
grant_mcu_for_fc_writes();
8484
}
8585

86-
dai_wr(rnd_fuse_addresses[i], sentinel, 0, partitions[i].granularity, OTP_CTRL_STATUS_DAI_ERROR_MASK);
86+
if (partitions[i].sw_digest || partitions[i].hw_digest) {
87+
dai_wr(rnd_fuse_addresses[i], sentinel, 0, partitions[i].granularity, OTP_CTRL_STATUS_DAI_ERROR_MASK);
88+
}
8789

88-
if (!partitions[i].is_secret) {
90+
if (partitions[i].sw_digest) {
8991
dai_rd(rnd_fuse_addresses[i], &read_value, &zero, partitions[i].granularity, 0);
9092
if ((read_value & 0xFF) != sentinel) {
9193
VPRINTF(LOW, "ERROR: incorrect value: exp: %08X act: %08X\n", read_value, sentinel);

src/integration/testbench/fc_lcc_tb_services.sv

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module fc_lcc_tb_services (
2727
`include "caliptra_ss_tb_cmd_list.svh"
2828
`include "caliptra_ss_includes.svh"
2929

30+
import otp_ctrl_reg_pkg::*;
31+
3032
logic disable_lcc_sva;
3133

3234
logic ecc_fault_en = 1'b0;
@@ -114,7 +116,7 @@ module fc_lcc_tb_services (
114116
end
115117
CMD_FC_LCC_FAULT_DIGEST: begin
116118
$display("fc_lcc_tb_services: fault the transition tokens partition digest");
117-
force `CPTRA_SS_TB_TOP_NAME.u_otp.u_prim_ram_1p_adv.u_mem.mem[696] = '0;
119+
force `CPTRA_SS_TB_TOP_NAME.u_otp.u_prim_ram_1p_adv.u_mem.mem[SecretLcTransitionPartitionDigestOffset/2] = '0;
118120
end
119121
CMD_FC_LCC_FAULT_BUS_ECC: begin
120122
$display("fc_lcc_tb_services: fault one bit in axi write request");
@@ -243,51 +245,67 @@ module fc_lcc_tb_services (
243245
// Uncorrectable error: Flip all bits of a word in a locked partition
244246
//-------------------------------------------------------------------------
245247

246-
// reg fault_active_q;
247-
// reg [15:0] faulted_word_q [0:6];
248+
reg fault_active_q;
249+
reg [15:0] faulted_word_q [0:6];
248250

249-
// localparam int partition_offsets [0:6] = '{'h024, 'h048, 'h050, 'h058, 'h060, 'h160C, 'h1880};
250-
// localparam int partition_digests [0:6] = '{'h044, 'h04C, 'h054, 'h05C, 'h064, 'h1664, 'h1980};
251+
localparam int partition_offsets [0:6] = '{
252+
SecretManufPartitionOffset/2,
253+
SecretProdPartition0Offset/2,
254+
SecretProdPartition1Offset/2,
255+
SecretProdPartition2Offset/2,
256+
SecretProdPartition3Offset/2,
257+
SecretLcTransitionPartitionOffset/2,
258+
VendorSecretProdPartitionOffset/2
259+
};
260+
localparam int partition_digests [0:6] = '{
261+
SecretManufPartitionDigestOffset/2,
262+
SecretProdPartition0DigestOffset/2,
263+
SecretProdPartition1DigestOffset/2,
264+
SecretProdPartition2DigestOffset/2,
265+
SecretProdPartition3DigestOffset/2,
266+
SecretLcTransitionPartitionDigestOffset/2,
267+
VendorSecretProdPartitionDigestOffset/2
268+
};
251269

252-
// always_ff @(posedge clk or negedge cptra_rst_b) begin
253-
// if (!cptra_rst_b) begin
254-
// fault_active_q <= 1'b0;
255-
// end else begin
256-
// if (tb_service_cmd_valid && (tb_service_cmd == CMD_FC_LCC_CORRECTABLE_FAULT || tb_service_cmd == CMD_FC_LCC_UNCORRECTABLE_FAULT) && !fault_active_q) begin
257-
// fault_active_q <= 1'b1;
258-
// end
259-
// end
260-
// end
270+
always_ff @(posedge clk or negedge cptra_rst_b) begin
271+
if (!cptra_rst_b) begin
272+
fault_active_q <= 1'b0;
273+
end else begin
274+
if (tb_service_cmd_valid && (tb_service_cmd == CMD_FC_LCC_CORRECTABLE_FAULT || tb_service_cmd == CMD_FC_LCC_UNCORRECTABLE_FAULT) && !fault_active_q) begin
275+
fault_active_q <= 1'b1;
276+
end
277+
end
278+
end
261279

262-
// generate
263-
// for (genvar i = 0; i < 7; i++) begin
264-
// always_ff @(posedge clk or negedge cptra_rst_b) begin
265-
// if (!cptra_rst_b) begin
266-
// faulted_word_q[i] <= '0;
267-
// end else begin
268-
// if (tb_service_cmd_valid && !fault_active_q) begin
269-
// // Only inject faults into partitions that are locked.
270-
// if (tb_service_cmd == CMD_FC_LCC_CORRECTABLE_FAULT) begin
271-
// faulted_word_q[i] <= { `FC_MEM[partition_offsets[i]][15:1], `FC_MEM[partition_offsets[i]][0] ^ |`FC_MEM[partition_digests[i]] };
272-
// end else if (tb_service_cmd == CMD_FC_LCC_UNCORRECTABLE_FAULT) begin
273-
// faulted_word_q[i] <= `FC_MEM[partition_offsets[i]][15:0] ^ {16{|`FC_MEM[partition_digests[i]]}};
274-
// end
275-
// end
276-
// end
277-
// end
278-
// end
279-
// endgenerate
280+
generate
281+
for (genvar i = 0; i < 7; i++) begin
282+
always_ff @(posedge clk or negedge cptra_rst_b) begin
283+
if (!cptra_rst_b) begin
284+
faulted_word_q[i] <= '0;
285+
end else begin
286+
if (tb_service_cmd_valid && !fault_active_q) begin
287+
// Only inject faults into partitions that are locked.
288+
if (tb_service_cmd == CMD_FC_LCC_CORRECTABLE_FAULT) begin
289+
faulted_word_q[i] <= { `FC_MEM[partition_offsets[i]][15:1], `FC_MEM[partition_offsets[i]][0] ^ |`FC_MEM[partition_digests[i]] };
290+
end else if (tb_service_cmd == CMD_FC_LCC_UNCORRECTABLE_FAULT) begin
291+
faulted_word_q[i] <= `FC_MEM[partition_offsets[i]][15:0] ^ {16{|`FC_MEM[partition_digests[i]]}};
292+
end
293+
end
294+
end
295+
end
296+
end
297+
endgenerate
280298

281-
// generate
282-
// for (genvar i = 0; i < 7; i++) begin
283-
// always_comb begin
284-
// if (fault_active_q) begin
285-
// force `FC_MEM[partition_offsets[i]][15:0] = faulted_word_q[i];
286-
// end else begin
287-
// release `FC_MEM[partition_offsets[i]][15:0];
288-
// end
289-
// end
290-
// end
291-
// endgenerate
299+
generate
300+
for (genvar i = 0; i < 7; i++) begin
301+
always_comb begin
302+
if (fault_active_q) begin
303+
force `FC_MEM[partition_offsets[i]][15:0] = faulted_word_q[i];
304+
end else begin
305+
release `FC_MEM[partition_offsets[i]][15:0];
306+
end
307+
end
308+
end
309+
endgenerate
292310

293311
endmodule

0 commit comments

Comments
 (0)