Skip to content

Commit

Permalink
User/dev/michnorris/reg file x check (#400)
Browse files Browse the repository at this point in the history
* adding assertion for x check on all hwif in structs in rdl reg files

* updating script to find reset name and include it in assertion

* fixing script to use hard reset or powergood for assertion if it's found

* fixing script to look for pwrgood instead of power

* updating script again, error_reset_b is another name used for pwrgood/hard reset

---------

Co-authored-by: Michael Norris <[email protected]>
  • Loading branch information
Nitsirks and Michael Norris authored Feb 20, 2024
1 parent 9536d99 commit feed73c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/datavault/rtl/dv_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,7 @@ module dv_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.hard_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/doe/rtl/doe_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1408,4 +1408,7 @@ module doe_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.cptra_pwrgood)

endmodule
3 changes: 3 additions & 0 deletions src/ecc/rtl/ecc_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1813,4 +1813,7 @@ module ecc_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.hard_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/hmac/rtl/hmac_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -2053,4 +2053,7 @@ module hmac_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.error_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/keyvault/rtl/kv_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,7 @@ module kv_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.hard_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/pcrvault/rtl/pv_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,7 @@ module pv_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.hard_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/sha256/rtl/sha256_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1425,4 +1425,7 @@ module sha256_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.error_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/sha512/rtl/sha512_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -2024,4 +2024,7 @@ module sha512_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.error_reset_b)

endmodule
3 changes: 3 additions & 0 deletions src/soc_ifc/rtl/mbox_csr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,7 @@ module mbox_csr (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.cptra_rst_b)

endmodule
3 changes: 3 additions & 0 deletions src/soc_ifc/rtl/sha512_acc_csr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1615,4 +1615,7 @@ module sha512_acc_csr (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.cptra_pwrgood)

endmodule
3 changes: 3 additions & 0 deletions src/soc_ifc/rtl/soc_ifc_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -5683,4 +5683,7 @@ module soc_ifc_reg (
assign cpuif_rd_ack = readback_done;
assign cpuif_rd_data = readback_data;
assign cpuif_rd_err = readback_err;

`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, hwif_in.cptra_pwrgood)

endmodule
15 changes: 15 additions & 0 deletions tools/scripts/rdl_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def scrub_line_by_line(fname):
mod_cnt = 0
mod_lines = ""

found_hard_reset = None

# Line by line manipulation
# Look for unpacked arrays (could be struct arrays or signal arrays)
# Look for unpacked struct types
Expand All @@ -35,6 +37,14 @@ def scrub_line_by_line(fname):
has_reg_strb = re.search(r'\bdecoded_reg_strb\b', line)
has_unpacked = re.search(r'\[\d+\]', line)
has_struct = re.search(r'\bstruct\b\s*(?:unpacked)?', line)
is_endmodule = re.search(r'\bendmodule\b', line)
has_reset = re.search(r'\bnegedge\b', line)
if (has_reset is not None and found_hard_reset is None):
substring = re.search(r"negedge (\w+.\w+)", line)
reset_name = substring.group(1)
# Find the hard reset if it exists
# hard_reset_b, error_reset_b and cptra_pwrgood are used interchangeably
found_hard_reset = re.search(r'hard_reset|pwrgood|error_reset',reset_name)
# Skip lines with logic assignments or references to signals; we
# only want to scrub signal definitions for unpacked arrays
if (has_assign is not None or has_reg_strb is not None):
Expand All @@ -55,6 +65,11 @@ def scrub_line_by_line(fname):
has_unpacked = re.search(r'\[\d+\]', line)
mod_lines+=line
mod_cnt+=1
elif (is_endmodule is not None):
mod_lines+="\n"
mod_lines+="`CALIPTRA_ASSERT_KNOWN(ERR_HWIF_IN, hwif_in, clk, " + reset_name + ")\n"
mod_lines+="\n"
mod_lines+=line
else:
mod_lines+=line
#print(f"modified {mod_cnt} lines with unpacked arrays in {fname}")
Expand Down

0 comments on commit feed73c

Please sign in to comment.