From 755e658ea3cd8cc34fac248fdc45bc903f1956cb Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Fri, 8 Nov 2024 15:15:28 +0100 Subject: [PATCH] [hw,kmac,rtl] Parametrize the number of app interfaces Signed-off-by: Robert Schilling --- hw/ip/kmac/data/kmac.hjson | 15 +++++- hw/ip/kmac/doc/interfaces.md | 18 +++---- hw/ip/kmac/rtl/kmac.sv | 3 +- hw/ip/kmac/rtl/kmac_reg_pkg.sv | 1 + .../data/autogen/top_earlgrey.gen.hjson | 53 +++++++++++++++++-- hw/top_earlgrey/rtl/autogen/top_earlgrey.sv | 6 ++- 6 files changed, 79 insertions(+), 17 deletions(-) diff --git a/hw/ip/kmac/data/kmac.hjson b/hw/ip/kmac/data/kmac.hjson index 866062bf47868b..7a301917c767b2 100644 --- a/hw/ip/kmac/data/kmac.hjson +++ b/hw/ip/kmac/data/kmac.hjson @@ -123,6 +123,19 @@ local: "false" expose: "true" } + { name: "NumAppIntf" + type: "int" + default: "3" + desc: "Number of words for the secret key" + local: "true", + expose: "true" + } + { name: "NumAppIntfLocal" + type: "int" + default: "3" + desc: "Number of words for the secret key" + local: "true" + } { name: "NumWordsKey" type: "int" default: "16" @@ -196,7 +209,7 @@ name: "app" act: "rsp" package: "kmac_pkg" - width: "3" + width: "NumAppIntf" } { struct: "edn" type: "req_rsp" diff --git a/hw/ip/kmac/doc/interfaces.md b/hw/ip/kmac/doc/interfaces.md index f62158558e3c05..0af4aad83a9ac5 100644 --- a/hw/ip/kmac/doc/interfaces.md +++ b/hw/ip/kmac/doc/interfaces.md @@ -10,15 +10,15 @@ Referring to the [Comportable guideline for peripheral device functionality](htt ## [Inter-Module Signals](https://opentitan.org/book/doc/contributing/hw/comportability/index.html#inter-signal-handling) -| Port Name | Package::Struct | Type | Act | Width | Description | -|:---------------|:-----------------------|:--------|:------|--------:|:--------------| -| keymgr_key | keymgr_pkg::hw_key_req | uni | rcv | 1 | | -| app | kmac_pkg::app | req_rsp | rsp | 3 | | -| entropy | edn_pkg::edn | req_rsp | req | 1 | | -| idle | prim_mubi_pkg::mubi4 | uni | req | 1 | | -| en_masking | logic | uni | req | 1 | | -| lc_escalate_en | lc_ctrl_pkg::lc_tx | uni | rcv | 1 | | -| tl | tlul_pkg::tl | req_rsp | rsp | 1 | | +| Port Name | Package::Struct | Type | Act | Width | Description | +|:---------------|:-----------------------|:--------|:------|:------------------------------------------------|:--------------| +| keymgr_key | keymgr_pkg::hw_key_req | uni | rcv | 1 | | +| app | kmac_pkg::app | req_rsp | rsp | | | +| entropy | edn_pkg::edn | req_rsp | req | 1 | | +| idle | prim_mubi_pkg::mubi4 | uni | req | 1 | | +| en_masking | logic | uni | req | 1 | | +| lc_escalate_en | lc_ctrl_pkg::lc_tx | uni | rcv | 1 | | +| tl | tlul_pkg::tl | req_rsp | rsp | 1 | | ## Interrupts diff --git a/hw/ip/kmac/rtl/kmac.sv b/hw/ip/kmac/rtl/kmac.sv index 4cb66e85717d78..f0b5d1e76d07b5 100644 --- a/hw/ip/kmac/rtl/kmac.sv +++ b/hw/ip/kmac/rtl/kmac.sv @@ -28,7 +28,8 @@ module kmac parameter int SecCmdDelay = 0, // Accept SW message when idle and before receiving a START command. Useful for SCA only. - parameter bit SecIdleAcceptSwMsg = 1'b0, + parameter bit SecIdleAcceptSwMsg = 1'b0, + parameter int unsigned NumAppIntf = 3, parameter lfsr_perm_t RndCnstLfsrPerm = RndCnstLfsrPermDefault, parameter lfsr_seed_t RndCnstLfsrSeed = RndCnstLfsrSeedDefault, diff --git a/hw/ip/kmac/rtl/kmac_reg_pkg.sv b/hw/ip/kmac/rtl/kmac_reg_pkg.sv index 20bf330aa26508..c613a716c56ae4 100644 --- a/hw/ip/kmac/rtl/kmac_reg_pkg.sv +++ b/hw/ip/kmac/rtl/kmac_reg_pkg.sv @@ -7,6 +7,7 @@ package kmac_reg_pkg; // Param list + parameter int NumAppIntfLocal = 3; parameter int NumWordsKey = 16; parameter int NumWordsPrefix = 11; parameter int NumEntriesMsgFifo = 10; diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson index ef33bd4c1108c9..b0638770f26a03 100644 --- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson +++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson @@ -6530,6 +6530,15 @@ expose: "true" name_top: SecKmacIdleAcceptSwMsg } + { + name: NumAppIntf + desc: Number of words for the secret key + type: int + default: 3 + local: "true" + expose: "true" + name_top: KmacNumAppIntf + } { name: RndCnstLfsrSeed desc: Compile-time random data for PRNG default seed @@ -6591,7 +6600,16 @@ package: kmac_pkg type: req_rsp act: rsp - width: 3 + width: + { + name: NumAppIntf + desc: Number of words for the secret key + param_type: int + default: 3 + local: true + expose: true + name_top: KmacNumAppIntf + } inst_name: kmac default: "" end_idx: -1 @@ -20311,7 +20329,16 @@ package: kmac_pkg type: req_rsp act: rsp - width: 3 + width: + { + name: NumAppIntf + desc: Number of words for the secret key + param_type: int + default: 3 + local: true + expose: true + name_top: KmacNumAppIntf + } inst_name: kmac default: "" end_idx: -1 @@ -23417,7 +23444,16 @@ package: kmac_pkg struct: app_req signame: kmac_app_req - width: 3 + width: + { + name: NumAppIntf + desc: Number of words for the secret key + param_type: int + default: 3 + local: true + expose: true + name_top: KmacNumAppIntf + } type: req_rsp end_idx: -1 act: rsp @@ -23428,7 +23464,16 @@ package: kmac_pkg struct: app_rsp signame: kmac_app_rsp - width: 3 + width: + { + name: NumAppIntf + desc: Number of words for the secret key + param_type: int + default: 3 + local: true + expose: true + name_top: KmacNumAppIntf + } type: req_rsp end_idx: -1 act: rsp diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv index dbd5bf433b3042..1da0ec5837d70a 100644 --- a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv +++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv @@ -258,6 +258,7 @@ module top_earlgrey #( // local parameters for aes // local parameters for hmac // local parameters for kmac + localparam int KmacNumAppIntf = 3; // local parameters for otbn // local parameters for keymgr // local parameters for csrng @@ -640,8 +641,8 @@ module top_earlgrey #( keymgr_pkg::hw_key_req_t keymgr_aes_key; keymgr_pkg::hw_key_req_t keymgr_kmac_key; keymgr_pkg::otbn_key_req_t keymgr_otbn_key; - kmac_pkg::app_req_t [2:0] kmac_app_req; - kmac_pkg::app_rsp_t [2:0] kmac_app_rsp; + kmac_pkg::app_req_t [KmacNumAppIntf-1:0] kmac_app_req; + kmac_pkg::app_rsp_t [KmacNumAppIntf-1:0] kmac_app_rsp; logic kmac_en_masking; prim_mubi_pkg::mubi4_t [3:0] clkmgr_aon_idle; jtag_pkg::jtag_req_t pinmux_aon_lc_jtag_req; @@ -2357,6 +2358,7 @@ module top_earlgrey #( .SwKeyMasked(KmacSwKeyMasked), .SecCmdDelay(SecKmacCmdDelay), .SecIdleAcceptSwMsg(SecKmacIdleAcceptSwMsg), + .NumAppIntf(KmacNumAppIntf), .RndCnstLfsrSeed(RndCnstKmacLfsrSeed), .RndCnstLfsrPerm(RndCnstKmacLfsrPerm), .RndCnstBufferLfsrSeed(RndCnstKmacBufferLfsrSeed),