[entropy_src, top] Connect entropy_src efuse_sw_rd_en
- Allocate otp bits for entropy_src software read enable
- Update dev image to allow software read
Signed-off-by: Timothy Chen <timothytim@google.com>
diff --git a/hw/ip/entropy_src/data/entropy_src.hjson b/hw/ip/entropy_src/data/entropy_src.hjson
index 32d096d..67e5334 100644
--- a/hw/ip/entropy_src/data/entropy_src.hjson
+++ b/hw/ip/entropy_src/data/entropy_src.hjson
@@ -39,12 +39,11 @@
act: "req",
package: "entropy_src_pkg",
}
- { struct: "logic"
- type: "uni"
- name: "efuse_es_sw_reg_en"
- act: "rcv"
- width: 1
- package: ""
+ { struct: "otp_hw_cfg",
+ type: "uni",
+ name: "otp_hw_cfg",
+ act: "rcv",
+ package: "otp_ctrl_part_pkg",
}
{ struct: "logic"
type: "uni"
diff --git a/hw/ip/entropy_src/dv/tb/tb.sv b/hw/ip/entropy_src/dv/tb/tb.sv
index 8b36263..1f5e73b 100644
--- a/hw/ip/entropy_src/dv/tb/tb.sv
+++ b/hw/ip/entropy_src/dv/tb/tb.sv
@@ -17,6 +17,7 @@
wire devmode, efuse_es_sw_reg_en;
wire [NUM_MAX_INTERRUPTS-1:0] interrupts;
wire intr_entropy_valid, intr_health_test_failed, intr_fatal_err;
+ otp_ctrl_part_pkg::otp_hw_cfg_data_t otp_hw_cfg;
// interfaces
clk_rst_if clk_rst_if(.clk(clk), .rst_n(rst_n));
@@ -29,6 +30,12 @@
push_pull_if#(.HostDataWidth(entropy_src_pkg::FIPS_CSRNG_BUS_WIDTH))
csrng_if(.clk(clk), .rst_n(rst_n));
+ // TODO: Hack to enable otp values
+ always_comb begin
+ otp_hw_cfg = otp_ctrl_part_pkg::OTP_HW_CFG_DATA_DEFAULT;
+ otp_hw_cfg.en_entropy_src_fw_read = efuse_es_sw_reg_en ? 8'hA5 : '0;
+ end
+
`DV_ALERT_IF_CONNECT
// dut
@@ -39,7 +46,7 @@
.tl_i (tl_if.h2d ),
.tl_o (tl_if.d2h ),
- .efuse_es_sw_reg_en_i (efuse_es_sw_reg_en),
+ .otp_hw_cfg_i (otp_hw_cfg ),
.entropy_src_hw_if_o ({csrng_if.ack,
csrng_if.d_data[entropy_src_pkg::CSRNG_BUS_WIDTH-1:0],
diff --git a/hw/ip/entropy_src/entropy_src.core b/hw/ip/entropy_src/entropy_src.core
index cba18da..c0659d9 100644
--- a/hw/ip/entropy_src/entropy_src.core
+++ b/hw/ip/entropy_src/entropy_src.core
@@ -13,6 +13,7 @@
- lowrisc:prim:lfsr
- lowrisc:ip:tlul
- lowrisc:ip:sha3
+ - lowrisc:ip:otp_ctrl_pkg
- lowrisc:ip:entropy_src_pkg
files:
- rtl/entropy_src_reg_pkg.sv
diff --git a/hw/ip/entropy_src/rtl/entropy_src.sv b/hw/ip/entropy_src/rtl/entropy_src.sv
index 60764de..6e770a4 100644
--- a/hw/ip/entropy_src/rtl/entropy_src.sv
+++ b/hw/ip/entropy_src/rtl/entropy_src.sv
@@ -21,8 +21,8 @@
input tlul_pkg::tl_h2d_t tl_i,
output tlul_pkg::tl_d2h_t tl_o,
- // Efuse Interface
- input logic efuse_es_sw_reg_en_i,
+ // OTP Interface
+ input otp_ctrl_part_pkg::otp_hw_cfg_t otp_hw_cfg_i,
// RNG Interface
output logic rng_fips_o,
@@ -72,6 +72,11 @@
.devmode_i(1'b1)
);
+ logic efuse_es_sw_reg_en;
+ otp_ctrl_part_pkg::otp_hw_cfg_t unused_hw_cfg;
+ assign unused_hw_cfg = otp_hw_cfg_i;
+ assign efuse_es_sw_reg_en = (otp_hw_cfg_i.data.en_entropy_src_fw_read == 8'hA5);
+
entropy_src_core #(
.EsFifoDepth(EsFifoDepth)
) u_entropy_src_core (
@@ -80,7 +85,7 @@
.reg2hw,
.hw2reg,
- .efuse_es_sw_reg_en_i,
+ .efuse_es_sw_reg_en_i(efuse_es_sw_reg_en),
.rng_fips_o,
.entropy_src_hw_if_o,
diff --git a/hw/ip/otp_ctrl/data/otp_ctrl.hjson b/hw/ip/otp_ctrl/data/otp_ctrl.hjson
index 9223dc65..1244b89 100644
--- a/hw/ip/otp_ctrl/data/otp_ctrl.hjson
+++ b/hw/ip/otp_ctrl/data/otp_ctrl.hjson
@@ -227,6 +227,18 @@
default: "1",
local: "true"
},
+ { name: "EnEntropySrcFwReadOffset",
+ desc: "Offset of EN_ENTROPY_SRC_FW_READ",
+ type: "int",
+ default: "1569",
+ local: "true"
+ },
+ { name: "EnEntropySrcFwReadSize",
+ desc: "Size of EN_ENTROPY_SRC_FW_READ",
+ type: "int",
+ default: "1",
+ local: "true"
+ },
{ name: "HwCfgDigestOffset",
desc: "Offset of HW_CFG_DIGEST",
type: "int",
diff --git a/hw/ip/otp_ctrl/data/otp_ctrl_img_dev.hjson b/hw/ip/otp_ctrl/data/otp_ctrl_img_dev.hjson
index 034ca94..040762e 100644
--- a/hw/ip/otp_ctrl/data/otp_ctrl_img_dev.hjson
+++ b/hw/ip/otp_ctrl/data/otp_ctrl_img_dev.hjson
@@ -48,7 +48,11 @@
{
name: "DEVICE_ID",
value: "<random>",
- }
+ },
+ {
+ name: "EN_ENTROPY_SRC_FW_READ",
+ value: "0xA5",
+ },
],
}
{
diff --git a/hw/ip/otp_ctrl/data/otp_ctrl_mmap.hjson b/hw/ip/otp_ctrl/data/otp_ctrl_mmap.hjson
index a7a2de1..6eb2b9a 100644
--- a/hw/ip/otp_ctrl/data/otp_ctrl_mmap.hjson
+++ b/hw/ip/otp_ctrl/data/otp_ctrl_mmap.hjson
@@ -147,6 +147,10 @@
name: "EN_SRAM_IFETCH",
size: "1",
},
+ {
+ name: "EN_ENTROPY_SRC_FW_READ",
+ size: "1",
+ },
],
desc: '''Hardware configuration bits used to hardwire
specific hardware functionality. E.g., raw entropy
diff --git a/hw/ip/otp_ctrl/doc/otp_ctrl_mmap.md b/hw/ip/otp_ctrl/doc/otp_ctrl_mmap.md
index e943a9a..7ab2dac 100644
--- a/hw/ip/otp_ctrl/doc/otp_ctrl_mmap.md
+++ b/hw/ip/otp_ctrl/doc/otp_ctrl_mmap.md
@@ -11,6 +11,7 @@
| | | | 64bit | [OWNER_SW_CFG_DIGEST](#Reg_owner_sw_cfg_digest_0) | 0x5F8 | 8 |
| 2 | HW_CFG | 240 | 32bit | DEVICE_ID | 0x600 | 32 |
| | | | 32bit | EN_SRAM_IFETCH | 0x620 | 1 |
+| | | | 32bit | EN_ENTROPY_SRC_FW_READ | 0x621 | 1 |
| | | | 64bit | [HW_CFG_DIGEST](#Reg_hw_cfg_digest_0) | 0x6E8 | 8 |
| 3 | SECRET0 | 40 | 64bit | TEST_UNLOCK_TOKEN | 0x6F0 | 16 |
| | | | 64bit | TEST_EXIT_TOKEN | 0x700 | 16 |
diff --git a/hw/ip/otp_ctrl/rtl/otp_ctrl.sv b/hw/ip/otp_ctrl/rtl/otp_ctrl.sv
index cf30f8f..27da794 100644
--- a/hw/ip/otp_ctrl/rtl/otp_ctrl.sv
+++ b/hw/ip/otp_ctrl/rtl/otp_ctrl.sv
@@ -197,8 +197,7 @@
.intg_error_o( ),
.rdata_i ( tlul_rdata ),
.rvalid_i ( tlul_rvalid ),
- .rerror_i ( tlul_rerror ),
- .req_type_o ( )
+ .rerror_i ( tlul_rerror )
);
logic [NumPart-1:0] tlul_part_sel_oh;
diff --git a/hw/ip/otp_ctrl/rtl/otp_ctrl_part_pkg.sv b/hw/ip/otp_ctrl/rtl/otp_ctrl_part_pkg.sv
index 3fa247f..b07af10 100644
--- a/hw/ip/otp_ctrl/rtl/otp_ctrl_part_pkg.sv
+++ b/hw/ip/otp_ctrl/rtl/otp_ctrl_part_pkg.sv
@@ -217,7 +217,8 @@
// Breakout types for easier access of individual items.
typedef struct packed {
logic [63:0] hw_cfg_digest;
- logic [1591:0] unallocated;
+ logic [1583:0] unallocated;
+ logic [7:0] en_entropy_src_fw_read;
logic [7:0] en_sram_ifetch;
logic [255:0] device_id;
} otp_hw_cfg_data_t;
@@ -225,7 +226,8 @@
// default value used for intermodule
parameter otp_hw_cfg_data_t OTP_HW_CFG_DATA_DEFAULT = '{
hw_cfg_digest: 64'hABFF25A58087D34A,
- unallocated: 1592'h0,
+ unallocated: 1584'h0,
+ en_entropy_src_fw_read: 8'h0,
en_sram_ifetch: 8'h0,
device_id: 256'h37E5AE39A58FACEE41389646B3968A3B128F4AF0AFFC1AAC77ADEFF42376E09D
};
@@ -267,7 +269,8 @@
}),
1920'({
64'hABFF25A58087D34A,
- 1592'h0, // unallocated space
+ 1584'h0, // unallocated space
+ 8'h0,
8'h0,
256'h37E5AE39A58FACEE41389646B3968A3B128F4AF0AFFC1AAC77ADEFF42376E09D
}),
diff --git a/hw/ip/otp_ctrl/rtl/otp_ctrl_reg_pkg.sv b/hw/ip/otp_ctrl/rtl/otp_ctrl_reg_pkg.sv
index 8a2fad7..b47a466 100644
--- a/hw/ip/otp_ctrl/rtl/otp_ctrl_reg_pkg.sv
+++ b/hw/ip/otp_ctrl/rtl/otp_ctrl_reg_pkg.sv
@@ -33,6 +33,8 @@
parameter int DeviceIdSize = 32;
parameter int EnSramIfetchOffset = 1568;
parameter int EnSramIfetchSize = 1;
+ parameter int EnEntropySrcFwReadOffset = 1569;
+ parameter int EnEntropySrcFwReadSize = 1;
parameter int HwCfgDigestOffset = 1768;
parameter int HwCfgDigestSize = 8;
parameter int Secret0Offset = 1776;
diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
index 8fcda92..5197417 100644
--- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
+++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
@@ -4430,12 +4430,15 @@
index: -1
}
{
- name: efuse_es_sw_reg_en
- struct: logic
+ name: otp_hw_cfg
+ struct: otp_hw_cfg
+ package: otp_ctrl_part_pkg
type: uni
act: rcv
width: 1
inst_name: entropy_src
+ default: ""
+ top_signame: otp_ctrl_otp_hw_cfg
index: -1
}
{
@@ -5617,6 +5620,7 @@
]
otp_ctrl.otp_hw_cfg:
[
+ entropy_src.otp_hw_cfg
lc_ctrl.otp_hw_cfg
keymgr.otp_hw_cfg
sram_ctrl_main.otp_hw_cfg
@@ -13202,12 +13206,15 @@
index: -1
}
{
- name: efuse_es_sw_reg_en
- struct: logic
+ name: otp_hw_cfg
+ struct: otp_hw_cfg
+ package: otp_ctrl_part_pkg
type: uni
act: rcv
width: 1
inst_name: entropy_src
+ default: ""
+ top_signame: otp_ctrl_otp_hw_cfg
index: -1
}
{
diff --git a/hw/top_earlgrey/data/top_earlgrey.hjson b/hw/top_earlgrey/data/top_earlgrey.hjson
index 47322d4..62151f5 100644
--- a/hw/top_earlgrey/data/top_earlgrey.hjson
+++ b/hw/top_earlgrey/data/top_earlgrey.hjson
@@ -897,7 +897,8 @@
'lc_ctrl.lc_otp_token' : ['otp_ctrl.lc_otp_token'],
// HW_CFG broadcast
- 'otp_ctrl.otp_hw_cfg' : ['lc_ctrl.otp_hw_cfg', 'keymgr.otp_hw_cfg',
+ 'otp_ctrl.otp_hw_cfg' : ['entropy_src.otp_hw_cfg',
+ 'lc_ctrl.otp_hw_cfg', 'keymgr.otp_hw_cfg',
'sram_ctrl_main.otp_hw_cfg', 'sram_ctrl_ret_aon.otp_hw_cfg'],
// Diversification constant coming from life cycle
diff --git a/hw/top_earlgrey/dv/chip_sim_cfg.hjson b/hw/top_earlgrey/dv/chip_sim_cfg.hjson
index 3119b43..2a834cc 100644
--- a/hw/top_earlgrey/dv/chip_sim_cfg.hjson
+++ b/hw/top_earlgrey/dv/chip_sim_cfg.hjson
@@ -181,6 +181,12 @@
en_run_modes: ["sw_test_mode"]
}
{
+ name: chip_dif_entropy_smoketest
+ uvm_test_seq: chip_sw_base_vseq
+ sw_images: ["sw/device/tests/dif_entropy_smoketest:1"]
+ en_run_modes: ["sw_test_mode"]
+ }
+ {
name: chip_dif_gpio_smoketest
uvm_test_seq: chip_sw_gpio_smoke_vseq
sw_images: ["sw/device/tests/dif_gpio_smoketest:1"]
diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
index b91ffb7..43f1307 100644
--- a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
+++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
@@ -2064,7 +2064,7 @@
.entropy_src_rng_i(es_rng_rsp_i),
.entropy_src_xht_o(),
.entropy_src_xht_i(entropy_src_pkg::ENTROPY_SRC_XHT_RSP_DEFAULT),
- .efuse_es_sw_reg_en_i('0),
+ .otp_hw_cfg_i(otp_ctrl_otp_hw_cfg),
.rng_fips_o(es_rng_fips_o),
.tl_i(entropy_src_tl_req),
.tl_o(entropy_src_tl_rsp),