Skip to content

Commit a1a215e

Browse files
committed
[flash_ctrl/fi] Add VC-Z01X FI analysis support to flash_ctrl
This commit adds the FI sim configuration files needed to run VC-Z01X on the flash controller. Signed-off-by: Pascal Nasahl <[email protected]>
1 parent c0f4e84 commit a1a215e

19 files changed

+2063
-0
lines changed

hw/ip/prim/dv/prim_prince/crypto_dpi_prince/crypto_dpi_prince_sim_opts.hjson

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@
1818
name: xcelium_crypto_dpi_prince_build_opts
1919
build_opts: ["-I{build_dir}/fusesoc-work/src/{crypto_prince_ref_src_dir}"]
2020
}
21+
22+
{
23+
name: z01x_crypto_dpi_prince_build_opts
24+
build_opts: ["-CFLAGS -I{build_dir}/fusesoc-work/src/{crypto_prince_ref_src_dir}"]
25+
}
2126
]
2227
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright lowRISC contributors (OpenTitan project).
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
FaultGenerate {
6+
NA [0,1] {PORT "tb.dut.u_eflash.gen_flash_cores[0].**"}
7+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright lowRISC contributors (OpenTitan project).
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
module strobe;
6+
7+
// Enable TL-UL integrity checker strobing points.
8+
`define FI_SIM_Z01X
9+
10+
initial begin
11+
@(posedge tb.dut.rst_ni)
12+
// Start FI injection job. For permanent faults, faults are injected
13+
// at this point. For transient faults, the cycle counter starts from
14+
// here.
15+
$fs_inject;
16+
end
17+
18+
integer cmp;
19+
20+
// Compare outputs of the golden and faulty machine. If we detect a mismatch,
21+
// set the fault status to "observed, not detected" (ON). If the faulty machine
22+
// produced an invalid value (X/Z), set to "potentially observed, not detected"
23+
// (PN).
24+
always@(negedge tb.dut.clk_i) begin
25+
cmp = $fs_compare(tb.dut.mem_tl_o, tb.dut.prim_tl_o, tb.dut.core_tl_o);
26+
if (1 == cmp) begin
27+
// Mismatch beetween the golden and faulty machine.
28+
$fs_set_status("ON", "tb.dut.mem_tl_o, tb.dut.prim_tl_o, tb.dut.core_tl_o");
29+
end else if (2 == cmp) begin
30+
// Faulty machine has a X/Z at the output.
31+
$fs_set_status("PN", "tb.dut.mem_tl_o, tb.dut.prim_tl_o, tb.dut.core_tl_o");
32+
end
33+
end
34+
35+
// In the previous always block, we have classified the fault as ON or PN. Now
36+
// check, if one of the countermeasures has detected the fault. Then, set the
37+
// fault status to "observed detected" (OD) or "potentially observed, detected"
38+
// (PD). If one of the alert signal is invalid (X/Z), set to "observed, potentially
39+
// detected" (OP), "potentially observed, potentially detected" (PP), or "not
40+
// detected, potentially observed" (NP).
41+
string status;
42+
always@(negedge tb.dut.clk_i) begin
43+
#2;
44+
cmp = $fs_compare(tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,
45+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr);
46+
status = $fs_get_status();
47+
if (1 == cmp) begin
48+
if (status == "ON") begin
49+
// Mismatch between golden and faulty machine and the alert was triggered.
50+
$fs_drop_status("OD", "tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,\
51+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr");
52+
end else if (status == "PN") begin
53+
// Potential mismatch between golden and faulty machine and the alert was triggered.
54+
$fs_drop_status("PD", "tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,\
55+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr");
56+
end else begin
57+
// No mismatch between golden and faulty machine but the alert was triggered.
58+
$fs_set_status("ND", "tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,\
59+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr");
60+
end
61+
end else if (2 == cmp) begin
62+
if (status == "ON") begin
63+
// Mismatch between golden and faulty machine and the alert was potentially triggered.
64+
$fs_drop_status("OP", "tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,\
65+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr");
66+
end else if (status == "PN") begin
67+
// Potential mismatch between golden and faulty machine and the alert was potentially
68+
// triggered.
69+
$fs_drop_status("PP", "tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,\
70+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr");
71+
end else begin
72+
// No mismatch between golden and faulty machine but the alert was potentially triggered.
73+
$fs_set_status("NP", "tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,\
74+
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr");
75+
end
76+
end
77+
end
78+
endmodule

0 commit comments

Comments
 (0)