Skip to content

Commit

Permalink
[entropy_src] Keep applying fw_ov_rd_fifo_overflow
Browse files Browse the repository at this point in the history
Keep applying fw_ov_rd_fifo_overflow instead of pulsing. This commit is
a manual port of the following Opentitan commit:

b454878f2528b49318ff2b604cb8d59a6e59b0ea

Which is associated with
lowRISC/opentitan#21640.

Original commit description:

This commit applies the fw_ov_rd_fifo_overflow signal in case of an
overflow. It used to only send a pulse through the register but now
the signal is applied until the FIFO has been emptied once and is
receiving contiguous data again.
This commit also aligns the documentation for the FW_OV_RD_FIFO_OVERFLOW
register. The register is now not clearable by software. It instead
is cleared by hardware.

Signed-off-by: Miguel Osorio <[email protected]>
  • Loading branch information
moidx committed Apr 24, 2024
1 parent a50f6d2 commit 74ecc79
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d80fa2173c00ce84dc0c744ca9d1ee6a99eb54891d7eb6c172e6a38905699c12fd517b389bcff0698dfb7d352f7cda6c
4207d937698d49ca879659d561a60bcbfc427e004f3af67e1f8e31648eb770d625aa4916abba5503d5a8ef9788b159a1
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1712949801
1713993516
4 changes: 2 additions & 2 deletions src/entropy_src/data/entropy_src.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@
},
{ name: "FW_OV_RD_FIFO_OVERFLOW",
desc: "Firmware override Observe FIFO overflow status",
swaccess: "rw0c",
swaccess: "ro",
hwaccess: "hwo",
hwext: "false",
fields: [
Expand All @@ -1187,7 +1187,7 @@
in the Observe FIFO. The RNG data rate is slow enough that firmware should always
be able to keep up. This register meanwhile provides an additional check to confirm
that bytes read from the !!FW_OV_RD_DATA register represent contiguous RNG samples.
If an overflow event occurs, this bit must be cleared by software.
If an overflow event occurs, this bit is cleared by hardware as soon as the FIFO is emptied.
'''
}
]
Expand Down
6 changes: 3 additions & 3 deletions src/entropy_src/data/entropy_src.json
Original file line number Diff line number Diff line change
Expand Up @@ -1072,14 +1072,14 @@
{
"name": "FW_OV_RD_FIFO_OVERFLOW",
"desc": "Firmware override Observe FIFO overflow status",
"swaccess": "rw0c",
"swaccess": "ro",
"hwaccess": "hwo",
"hwext": "false",
"fields": [
{
"bits": "0",
"name": "FW_OV_RD_FIFO_OVERFLOW",
"desc": "This bit is set by hardware whenever RNG data is lost due to an overflow condition\nin the Observe FIFO. The RNG data rate is slow enough that firmware should always\nbe able to keep up. This register meanwhile provides an additional check to confirm\nthat bytes read from the !!FW_OV_RD_DATA register represent contiguous RNG samples.\nIf an overflow event occurs, this bit must be cleared by software."
"desc": "This bit is set by hardware whenever RNG data is lost due to an overflow condition\nin the Observe FIFO. The RNG data rate is slow enough that firmware should always\nbe able to keep up. This register meanwhile provides an additional check to confirm\nthat bytes read from the !!FW_OV_RD_DATA register represent contiguous RNG samples.\nIf an overflow event occurs, this bit is cleared by hardware as soon as the FIFO is emptied."
}
]
},
Expand Down Expand Up @@ -1366,4 +1366,4 @@
]
}
]
}
}
5 changes: 2 additions & 3 deletions src/entropy_src/data/entropy_src.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,8 @@ addrmap entropy_src {
in the Observe FIFO. The RNG data rate is slow enough that firmware should always
be able to keep up. This register meanwhile provides an additional check to confirm
that bytes read from the !!FW_OV_RD_DATA register represent contiguous RNG samples.
If an overflow event occurs, this bit must be cleared by software.";
sw = rw;
onwrite = woclr;
If an overflow event occurs, this bit is cleared by hardware as soon as the FIFO is emptied.";
sw = r;
} FW_OV_RD_FIFO_OVERFLOW[0:0];
} FW_OV_RD_FIFO_OVERFLOW @ 0xBC;
reg {
Expand Down
10 changes: 5 additions & 5 deletions src/entropy_src/rtl/entropy_src_core.sv
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Description: entropy_src core module
//

module entropy_src_core
import entropy_src_pkg::*;
module entropy_src_core
import entropy_src_pkg::*;
import lc_ctrl_state_pkg::*;
import lc_ctrl_reg_pkg::*;
import lc_ctrl_pkg::*;
Expand Down Expand Up @@ -2336,8 +2336,8 @@ module entropy_src_core
// contiguous as possible.
logic sfifo_observe_gate_d, sfifo_observe_gate_q;

assign sfifo_observe_gate_d = (sfifo_observe_push && sfifo_observe_full) ? 1'b0 :
!sfifo_observe_not_empty ? 1'b1 :
assign sfifo_observe_gate_d = (pfifo_postht_pop && sfifo_observe_full) ? 1'b0 :
!sfifo_observe_not_empty ? 1'b1 :
sfifo_observe_gate_q;

always_ff @(posedge clk_i or negedge rst_ni) begin
Expand All @@ -2348,7 +2348,7 @@ module entropy_src_core
end
end

assign hw2reg.fw_ov_rd_fifo_overflow.d = (pfifo_postht_pop && sfifo_observe_full);
assign hw2reg.fw_ov_rd_fifo_overflow.d = !sfifo_observe_gate_d;
assign hw2reg.fw_ov_rd_fifo_overflow.de = 1'b1;

assign observe_fifo_thresh_met = fw_ov_mode && (observe_fifo_thresh != '0) &&
Expand Down
10 changes: 4 additions & 6 deletions src/entropy_src/rtl/entropy_src_reg_top.sv
Original file line number Diff line number Diff line change
Expand Up @@ -2222,15 +2222,15 @@ module entropy_src_reg_top #(
// R[fw_ov_rd_fifo_overflow]: V(False)
caliptra_prim_subreg #(
.DW (1),
.SwAccess(caliptra_prim_subreg_pkg::SwAccessW0C),
.SwAccess(caliptra_prim_subreg_pkg::SwAccessRO),
.RESVAL (1'h0)
) u_fw_ov_rd_fifo_overflow (
.clk_i (clk_i),
.rst_ni (rst_ni),

// from register interface
.we (fw_ov_rd_fifo_overflow_we),
.wd (fw_ov_rd_fifo_overflow_wd),
.we (1'b0),
.wd ('0),

// from internal hardware
.de (hw2reg.fw_ov_rd_fifo_overflow.de),
Expand Down Expand Up @@ -3476,9 +3476,7 @@ module entropy_src_reg_top #(

assign fw_ov_sha3_start_wd = reg_wdata[3:0];
assign fw_ov_wr_fifo_full_re = addr_hit[46] & reg_re & !reg_error;
assign fw_ov_rd_fifo_overflow_we = addr_hit[47] & reg_we & !reg_error;

assign fw_ov_rd_fifo_overflow_wd = reg_wdata[0];
assign fw_ov_rd_data_re = addr_hit[48] & reg_re & !reg_error;
assign fw_ov_wr_data_we = addr_hit[49] & reg_we & !reg_error;

Expand Down Expand Up @@ -3573,7 +3571,7 @@ module entropy_src_reg_top #(
reg_we_check[44] = fw_ov_control_gated_we;
reg_we_check[45] = fw_ov_sha3_start_we;
reg_we_check[46] = 1'b0;
reg_we_check[47] = fw_ov_rd_fifo_overflow_we;
reg_we_check[47] = 1'b0;
reg_we_check[48] = 1'b0;
reg_we_check[49] = fw_ov_wr_data_we;
reg_we_check[50] = observe_fifo_thresh_gated_we;
Expand Down

0 comments on commit 74ecc79

Please sign in to comment.