|
| 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