Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hw/dv/tools/dvsim/sim.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ do_build: gen_sv_flist
post_build: do_build
@echo "[make]: post_build"
ifneq (${post_build_cmds},)
cd ${build_dir} && ${post_build_cmds}
cd ${build_dir} && ${post_build_cmds} ${post_build_opts}
endif

build_result: post_build
Expand Down Expand Up @@ -183,7 +183,11 @@ endif

simulate: sw_build
@echo "[make]: simulate"
ifeq (${SIMULATOR}, z01x)
cd ${run_dir} && ${run_cmd} ${fi_sim_run_opts}
else
cd ${run_dir} && ${run_cmd} ${run_opts}
endif

post_run: simulate
@echo "[make]: post_run"
Expand Down
401 changes: 401 additions & 0 deletions hw/dv/tools/dvsim/z01x.hjson

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions hw/dv/tools/fi_sim.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

if {[info exists ::env(FI_CAMPAIGN)]} {
set fi_campaign "$::env(FI_CAMPAIGN)"
} else {
puts "ERROR: FI_CAMPAIGN environment variable not set!"
quit
}

if {[info exists ::env(FI_TC)]} {
set fi_tc_name "$::env(FI_TC)"
} else {
puts "ERROR: FI_TC environment variable not set!"
quit
}

create_testcases -name $fi_tc_name -exec "$::env(SIMV)" -args "$::env(run_opts) +ntb_random_seed=$::env(seed) +UVM_TEST_SEQ=$::env(uvm_test_seq) -assert disable_assert" -fsim_args " -fsim=limit+hyperactive+0 -fsim=fault+monitor+drop"

# Currently hard coded to 2.
set_config -global_max_jobs 2

fsim

report -campaign $fi_campaign -report $::env(run_dir)/fsim_result.rpt -overwrite -showfaultid

puts "TEST PASSED CHECKS"

fdb_disconnect
quit
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@
name: xcelium_crypto_dpi_prince_build_opts
build_opts: ["-I{build_dir}/fusesoc-work/src/{crypto_prince_ref_src_dir}"]
}

{
name: z01x_crypto_dpi_prince_build_opts
build_opts: ["-CFLAGS -I{build_dir}/fusesoc-work/src/{crypto_prince_ref_src_dir}"]
}
]
}
7 changes: 7 additions & 0 deletions hw/ip_templates/flash_ctrl/dv/fi/block.sff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

FaultGenerate {
NA [0,1] {PORT "tb.dut.u_eflash.gen_flash_cores[0].**"}
}
84 changes: 84 additions & 0 deletions hw/ip_templates/flash_ctrl/dv/fi/strobe.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

module strobe;

// Enable TL-UL integrity checker strobing points.
`define FI_SIM_Z01X

initial begin
@(posedge tb.dut.rst_ni)
// Start FI injection job. For permanent faults, faults are injected
// at this point. For transient faults, the cycle counter starts from
// here.
$fs_inject;
end

integer cmp;

// Compare outputs of the golden and faulty machine. If we detect a mismatch,
// set the fault status to "observed, not detected" (ON). If the faulty machine
// produced an invalid value (X/Z), set to "potentially observed, not detected"
// (PN).
always@(negedge tb.dut.clk_i) begin
cmp = $fs_compare(tb.dut.mem_tl_o, tb.dut.prim_tl_o, tb.dut.core_tl_o);
if (1 == cmp) begin
// Mismatch beetween the golden and faulty machine.
$fs_set_status("ON", "tb.dut.mem_tl_o, tb.dut.prim_tl_o, tb.dut.core_tl_o");
end else if (2 == cmp) begin
// Faulty machine has a X/Z at the output.
$fs_set_status("PN", "tb.dut.mem_tl_o, tb.dut.prim_tl_o, tb.dut.core_tl_o");
end
end

// In the previous always block, we have classified the fault as ON or PN. Now
// check, if one of the countermeasures has detected the fault. Then, set the
// fault status to "observed detected" (OD) or "potentially observed, detected"
// (PD). If one of the alert signal is invalid (X/Z), set to "observed, potentially
// detected" (OP), "potentially observed, potentially detected" (PP), or "not
// detected, potentially observed" (NP).
string status;
always@(negedge tb.dut.clk_i) begin
#2;
cmp = $fs_compare(tb.dut.alert_srcs, tb.dut.mem_tl_intg_err, tb.dut.prim_tl_intg_err,
tb.dut.core_tl_intg_err, tb.dut.flash_host_rderr);
status = $fs_get_status();
if (1 == cmp) begin
if (status == "ON") begin
// Mismatch between golden and faulty machine and the alert was triggered.
$fs_drop_status("OD", {"tb.dut.alert_srcs, tb.dut.mem_tl_intg_err,",
"tb.dut.prim_tl_intg_err, tb.dut.core_tl_intg_err,",
"tb.dut.flash_host_rderr"});
end else if (status == "PN") begin
// Potential mismatch between golden and faulty machine and the alert was triggered.
$fs_drop_status("PD", {"tb.dut.alert_srcs, tb.dut.mem_tl_intg_err,",
"tb.dut.prim_tl_intg_err, tb.dut.core_tl_intg_err,",
"tb.dut.flash_host_rderr"});
end else begin
// No mismatch between golden and faulty machine but the alert was triggered.
$fs_set_status("ND", {"tb.dut.alert_srcs, tb.dut.mem_tl_intg_err,",
"tb.dut.prim_tl_intg_err, tb.dut.core_tl_intg_err,",
"tb.dut.flash_host_rderr"});
end
end else if (2 == cmp) begin
if (status == "ON") begin
// Mismatch between golden and faulty machine and the alert was potentially triggered.
$fs_drop_status("OP", {"tb.dut.alert_srcs, tb.dut.mem_tl_intg_err,",
"tb.dut.prim_tl_intg_err, tb.dut.core_tl_intg_err,",
"tb.dut.flash_host_rderr"});
end else if (status == "PN") begin
// Potential mismatch between golden and faulty machine and the alert was potentially
// triggered.
$fs_drop_status("PP", {"tb.dut.alert_srcs, tb.dut.mem_tl_intg_err,",
"tb.dut.prim_tl_intg_err, tb.dut.core_tl_intg_err,",
"tb.dut.flash_host_rderr"});
end else begin
// No mismatch between golden and faulty machine but the alert was potentially triggered.
$fs_set_status("NP", {"tb.dut.alert_srcs, tb.dut.mem_tl_intg_err,",
"tb.dut.prim_tl_intg_err, tb.dut.core_tl_intg_err,",
"tb.dut.flash_host_rderr"});
end
end
end
endmodule
Loading
Loading