From e7c2eca50ff496177b4f6526ee641548b44653a6 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 | 19 ++++- hw/ip/kmac/doc/interfaces.md | 18 ++--- hw/ip/kmac/dv/README.md | 4 +- hw/ip/kmac/dv/env/kmac_env.sv | 6 +- hw/ip/kmac/dv/env/kmac_env_cfg.sv | 4 +- hw/ip/kmac/dv/env/kmac_env_cov.sv | 2 +- hw/ip/kmac/dv/env/kmac_env_pkg.sv | 5 ++ hw/ip/kmac/dv/env/kmac_if.sv | 4 +- hw/ip/kmac/dv/env/kmac_scoreboard.sv | 10 +-- hw/ip/kmac/dv/env/kmac_virtual_sequencer.sv | 2 +- .../kmac_app_with_partial_data_vseq.sv | 2 +- hw/ip/kmac/dv/tb.sv | 11 +-- hw/ip/kmac/lint/kmac.waiver | 15 +++- hw/ip/kmac/rtl/kmac.sv | 8 ++- hw/ip/kmac/rtl/kmac_app.sv | 10 +-- hw/ip/kmac/rtl/kmac_pkg.sv | 60 ++++++---------- .../data/autogen/top_earlgrey.gen.hjson | 71 +++++++++++++++++-- hw/top_earlgrey/rtl/autogen/top_earlgrey.sv | 9 ++- 18 files changed, 178 insertions(+), 82 deletions(-) diff --git a/hw/ip/kmac/data/kmac.hjson b/hw/ip/kmac/data/kmac.hjson index 866062bf47868b..0f3452ca89bdef 100644 --- a/hw/ip/kmac/data/kmac.hjson +++ b/hw/ip/kmac/data/kmac.hjson @@ -123,6 +123,23 @@ local: "false" expose: "true" } + { name: "NumAppIntf" + type: "int" + default: "3" + desc: "Number of application interfaces" + local: "false" + expose: "true" + } + { name: "AppCfg" + desc: '''Application interface configuration. + Top-level connection to the application interface must follow this definition. + ''' + type: "kmac_pkg::app_config_t" + unpacked_dimensions: "[KmacNumAppIntf]" + default: "'{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl}" + local: "false" + expose: "true" + } { name: "NumWordsKey" type: "int" default: "16" @@ -196,7 +213,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..a78be55ab55683 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 | NumAppIntf | | +| 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/dv/README.md b/hw/ip/kmac/dv/README.md index 1afd85b3546f28..b5cf1362c6372d 100644 --- a/hw/ip/kmac/dv/README.md +++ b/hw/ip/kmac/dv/README.md @@ -123,8 +123,8 @@ The `kmac_scoreboard` is primarily used for end to end checking. It creates the following analysis ports to retrieve the data monitored by corresponding interface agents: * tl_a_chan_fifo: TL address channel * tl_d_chan_fifo: TL data channel -* kmac_app_req_fifo[kmac_pkg::NumAppIntf]: An array of analysis FIFOs to hold request transactions coming from the various application interfaces -* kmac_app_rsp_fifo[kmac_pkg::NumAppIntf]: An array of analysis FIFOs to hold response transactions coming from the various application interfaces +* kmac_app_req_fifo[NUM_APP_INTF]: An array of analysis FIFOs to hold request transactions coming from the various application interfaces +* kmac_app_rsp_fifo[NUM_APP_INTF]: An array of analysis FIFOs to hold response transactions coming from the various application interfaces * edn_fifo: FIFO used to hold transactions coming from the EDN interface The KMAC scoreboard implements a cycle-accurate model of the DUT that is used to thoroughly check the operation of the KMAC IP. diff --git a/hw/ip/kmac/dv/env/kmac_env.sv b/hw/ip/kmac/dv/env/kmac_env.sv index b218b86bd1a6f8..93c5c02c91d75e 100644 --- a/hw/ip/kmac/dv/env/kmac_env.sv +++ b/hw/ip/kmac/dv/env/kmac_env.sv @@ -12,13 +12,13 @@ class kmac_env extends cip_base_env #( `uvm_component_new - kmac_app_agent m_kmac_app_agent[kmac_pkg::NumAppIntf]; + kmac_app_agent m_kmac_app_agent[kmac_env_pkg::NUM_APP_INTF]; key_sideload_agent keymgr_sideload_agent; function void build_phase(uvm_phase phase); super.build_phase(phase); - for (int i = 0; i < kmac_pkg::NumAppIntf; i++) begin + for (int i = 0; i < kmac_env_pkg::NUM_APP_INTF; i++) begin string name = $sformatf("m_kmac_app_agent[%0d]", i); m_kmac_app_agent[i] = kmac_app_agent::type_id::create(name, this); uvm_config_db#(kmac_app_agent_cfg)::set(this, name, "cfg", cfg.m_kmac_app_agent_cfg[i]); @@ -39,7 +39,7 @@ class kmac_env extends cip_base_env #( function void connect_phase(uvm_phase phase); super.connect_phase(phase); - for (int i = 0; i < kmac_pkg::NumAppIntf; i++) begin + for (int i = 0; i < kmac_env_pkg::NUM_APP_INTF; i++) begin m_kmac_app_agent[i].monitor.analysis_port.connect(scoreboard.kmac_app_rsp_fifo[i].analysis_export); m_kmac_app_agent[i].m_data_push_agent.monitor.analysis_port.connect( scoreboard.kmac_app_req_fifo[i].analysis_export); diff --git a/hw/ip/kmac/dv/env/kmac_env_cfg.sv b/hw/ip/kmac/dv/env/kmac_env_cfg.sv index 04a61cd8122a36..38b92766f4ee25 100644 --- a/hw/ip/kmac/dv/env/kmac_env_cfg.sv +++ b/hw/ip/kmac/dv/env/kmac_env_cfg.sv @@ -7,7 +7,7 @@ class kmac_env_cfg extends cip_base_env_cfg #(.RAL_T(kmac_reg_block)); // ext interfaces kmac_vif kmac_vif; - rand kmac_app_agent_cfg m_kmac_app_agent_cfg[kmac_pkg::NumAppIntf]; + rand kmac_app_agent_cfg m_kmac_app_agent_cfg[kmac_env_pkg::NUM_APP_INTF]; rand key_sideload_agent_cfg keymgr_sideload_agent_cfg; // Masked KMAC is the default configuration @@ -50,7 +50,7 @@ class kmac_env_cfg extends cip_base_env_cfg #(.RAL_T(kmac_reg_block)); shadow_storage_err_status_fields[ral.cfg_regwen.en] = 0; shadow_storage_err_status_fields[ral.status.sha3_idle] = 0; - for (int i = 0; i < kmac_pkg::NumAppIntf; i++) begin + for (int i = 0; i < kmac_env_pkg::NUM_APP_INTF; i++) begin string name = $sformatf("m_kmac_app_agent_cfg[%0d]", i); m_kmac_app_agent_cfg[i] = kmac_app_agent_cfg::type_id::create(name); m_kmac_app_agent_cfg[i].if_mode = dv_utils_pkg::Host; diff --git a/hw/ip/kmac/dv/env/kmac_env_cov.sv b/hw/ip/kmac/dv/env/kmac_env_cov.sv index a846c3da6110de..69ac1736da605f 100644 --- a/hw/ip/kmac/dv/env/kmac_env_cov.sv +++ b/hw/ip/kmac/dv/env/kmac_env_cov.sv @@ -205,7 +205,7 @@ class kmac_env_cov extends cip_base_env_cov #(.CFG_T(kmac_env_cfg)); config_masked_cg config_masked_cg; config_unmasked_cg config_unmasked_cg; - app_cg_wrap app_cg_wrappers[kmac_pkg::NumAppIntf]; + app_cg_wrap app_cg_wrappers[kmac_env_pkg::NUM_APP_INTF]; covergroup msg_len_cg with function sample(int len); msg_len: coverpoint len { diff --git a/hw/ip/kmac/dv/env/kmac_env_pkg.sv b/hw/ip/kmac/dv/env/kmac_env_pkg.sv index 50ce63db18b264..ebb4787789f2ec 100644 --- a/hw/ip/kmac/dv/env/kmac_env_pkg.sv +++ b/hw/ip/kmac/dv/env/kmac_env_pkg.sv @@ -71,6 +71,11 @@ package kmac_env_pkg; parameter uint NUM_EDN = 1; + // Earlgrey has 3 application interfaces + parameter uint NUM_APP_INTF = 3; + parameter app_config_t APP_CFG[NUM_APP_INTF] = + '{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl}; + ///////////////////////////// // Timing Model Parameters // ///////////////////////////// diff --git a/hw/ip/kmac/dv/env/kmac_if.sv b/hw/ip/kmac/dv/env/kmac_if.sv index 710b085e160db0..026cb456bfa00c 100644 --- a/hw/ip/kmac/dv/env/kmac_if.sv +++ b/hw/ip/kmac/dv/env/kmac_if.sv @@ -9,8 +9,8 @@ interface kmac_if(input clk_i, input rst_ni); logic en_masking_o; lc_ctrl_pkg::lc_tx_t lc_escalate_en_i; prim_mubi_pkg::mubi4_t idle_o; - kmac_pkg::app_req_t [kmac_pkg::NumAppIntf-1:0] app_req; - kmac_pkg::app_rsp_t [kmac_pkg::NumAppIntf-1:0] app_rsp; + kmac_pkg::app_req_t [kmac_env_pkg::NUM_APP_INTF-1:0] app_req; + kmac_pkg::app_rsp_t [kmac_env_pkg::NUM_APP_INTF-1:0] app_rsp; function automatic void drive_lc_escalate(lc_ctrl_pkg::lc_tx_t val); lc_escalate_en_i = val; diff --git a/hw/ip/kmac/dv/env/kmac_scoreboard.sv b/hw/ip/kmac/dv/env/kmac_scoreboard.sv index 518cd6662bf55e..73231a9a7c1778 100644 --- a/hw/ip/kmac/dv/env/kmac_scoreboard.sv +++ b/hw/ip/kmac/dv/env/kmac_scoreboard.sv @@ -153,16 +153,16 @@ class kmac_scoreboard extends cip_base_scoreboard #( ({KMAC_FIFO_DEPTH{1'b1}} << KmacStatusFifoDepthLSB); // TLM fifos - uvm_tlm_analysis_fifo #(kmac_app_item) kmac_app_rsp_fifo[kmac_pkg::NumAppIntf]; + uvm_tlm_analysis_fifo #(kmac_app_item) kmac_app_rsp_fifo[NUM_APP_INTF]; uvm_tlm_analysis_fifo #(push_pull_agent_pkg::push_pull_item #( .HostDataWidth(kmac_app_agent_pkg::KMAC_REQ_DATA_WIDTH))) - kmac_app_req_fifo[kmac_pkg::NumAppIntf]; + kmac_app_req_fifo[NUM_APP_INTF]; `uvm_component_new function void build_phase(uvm_phase phase); super.build_phase(phase); - for (int i = 0; i < kmac_pkg::NumAppIntf; i++) begin + for (int i = 0; i < NUM_APP_INTF; i++) begin kmac_app_req_fifo[i] = new($sformatf("kmac_app_req_fifo[%0d]", i), this); kmac_app_rsp_fifo[i] = new($sformatf("kmac_app_rsp_fifo[%0d]", i), this); end @@ -1729,8 +1729,8 @@ class kmac_scoreboard extends cip_base_scoreboard #( byte fname_arr[]; byte custom_str_arr[]; - if (en_kmac_app && kmac_pkg::AppCfg[app_mode].PrefixMode) begin - prefix_bytes = {<< byte {kmac_pkg::AppCfg[app_mode].Prefix}}; + if (en_kmac_app && APP_CFG[app_mode].PrefixMode) begin + prefix_bytes = {<< byte {APP_CFG[app_mode].Prefix}}; end else begin prefix_bytes = {<< 32 {prefix}}; prefix_bytes = {<< byte {prefix_bytes}}; diff --git a/hw/ip/kmac/dv/env/kmac_virtual_sequencer.sv b/hw/ip/kmac/dv/env/kmac_virtual_sequencer.sv index 9fd88043e4d827..ad9a6abe1cb46b 100644 --- a/hw/ip/kmac/dv/env/kmac_virtual_sequencer.sv +++ b/hw/ip/kmac/dv/env/kmac_virtual_sequencer.sv @@ -10,7 +10,7 @@ class kmac_virtual_sequencer extends cip_base_virtual_sequencer #( `uvm_component_new - kmac_app_sequencer kmac_app_sequencer_h[kmac_pkg::NumAppIntf]; + kmac_app_sequencer kmac_app_sequencer_h[kmac_env_pkg::NUM_APP_INTF]; key_sideload_sequencer key_sideload_sequencer_h; endclass diff --git a/hw/ip/kmac/dv/env/seq_lib/kmac_app_with_partial_data_vseq.sv b/hw/ip/kmac/dv/env/seq_lib/kmac_app_with_partial_data_vseq.sv index d89a39db901b9b..da6f9499fa908b 100644 --- a/hw/ip/kmac/dv/env/seq_lib/kmac_app_with_partial_data_vseq.sv +++ b/hw/ip/kmac/dv/env/seq_lib/kmac_app_with_partial_data_vseq.sv @@ -11,7 +11,7 @@ class kmac_app_with_partial_data_vseq extends kmac_app_vseq; virtual task pre_start(); super.pre_start(); - for (int i = 0; i < kmac_pkg::NumAppIntf; i++) begin + for (int i = 0; i < kmac_env_pkg::NUM_APP_INTF; i++) begin cfg.m_kmac_app_agent_cfg[i].inject_zero_in_host_strb = 1; end cfg.do_cycle_accurate_check = 0; diff --git a/hw/ip/kmac/dv/tb.sv b/hw/ip/kmac/dv/tb.sv index 30a03dbedfff25..3c145ca18d9b2f 100644 --- a/hw/ip/kmac/dv/tb.sv +++ b/hw/ip/kmac/dv/tb.sv @@ -19,8 +19,8 @@ module tb; // keymgr/kmac sideload wires keymgr_pkg::hw_key_req_t kmac_sideload_key; // kmac_app interfaces - kmac_pkg::app_req_t [kmac_pkg::NumAppIntf-1:0] app_req; - kmac_pkg::app_rsp_t [kmac_pkg::NumAppIntf-1:0] app_rsp; + kmac_pkg::app_req_t [NUM_APP_INTF-1:0] app_req; + kmac_pkg::app_rsp_t [NUM_APP_INTF-1:0] app_rsp; // interfaces clk_rst_if clk_rst_if(.clk(clk), .rst_n(rst_n)); @@ -37,7 +37,7 @@ module tb; .sideload_key (kmac_sideload_key) ); - kmac_app_intf kmac_app_if[kmac_pkg::NumAppIntf](.clk(clk), .rst_n(rst_n)); + kmac_app_intf kmac_app_if[NUM_APP_INTF](.clk(clk), .rst_n(rst_n)); // edn_clk, edn_rst_n and edn_if is defined and driven in below macro `DV_EDN_IF_CONNECT @@ -48,7 +48,8 @@ module tb; kmac #( .EnMasking(`EN_MASKING), - .SwKeyMasked(`SW_KEY_MASKED) + .SwKeyMasked(`SW_KEY_MASKED), + .NumAppIntf(NUM_APP_INTF) ) dut ( .clk_i (clk ), .rst_ni (rst_n ), @@ -89,7 +90,7 @@ module tb; .entropy_i ({edn_if[0].ack, edn_if[0].d_data} ) ); - for (genvar i = 0; i < kmac_pkg::NumAppIntf; i++) begin : gen_kmac_app_intf + for (genvar i = 0; i < NUM_APP_INTF; i++) begin : gen_kmac_app_intf assign app_req[i] = kmac_app_if[i].kmac_data_req; assign kmac_app_if[i].kmac_data_rsp = app_rsp[i]; assign kmac_if.app_req[i] = app_req[i]; diff --git a/hw/ip/kmac/lint/kmac.waiver b/hw/ip/kmac/lint/kmac.waiver index 68d71d405ac254..4c65096b0058ca 100644 --- a/hw/ip/kmac/lint/kmac.waiver +++ b/hw/ip/kmac/lint/kmac.waiver @@ -9,7 +9,7 @@ waive -rules {HIER_NET_NOT_READ NOT_READ INPUT_NOT_READ} -location {kmac.sv} -re waive -rules {HIER_NET_NOT_READ NOT_READ INPUT_NOT_READ} -location {kmac.sv} \ -regexp {'tlram_addr' is not read} \ - -comment "MSG_FIFO ignores the exact memory address but use strobe for alignement" + -comment "MSG_FIFO ignores the exact memory address but use strobe for alignment" waive -rules {HIER_NET_NOT_READ NOT_READ INPUT_NOT_READ} \ -location {kmac_msgfifo.sv} -regexp {'packer_wmask.* is not read} \ @@ -29,3 +29,16 @@ waive -rules {INTEGER} -location {kmac_entropy.sv} \ waive -rules {CASE_SEL_EXPR} -location {kmac_app.sv} \ -comment "not a problem, just a suggested alternate implementation" + +waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \ + -regexp {'PrefixMode' is of two state type} \ + -comment "Enum bit is used as a generate selection. OK to be two state" +waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \ + -regexp {'app_mode_e' is of two state type} \ + -comment "Enum bit is used in ifs only. OK to be two state" +waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \ + -regexp {'Mode' is of two state type} \ + -comment "Enum bit is used in ifs only. OK to be two state" +waive -rules TWO_STATE_TYPE -location {kmac_pkg.sv} \ + -regexp {'app_config_t' is of type struct which contains two state type field} \ + -comment "Struct fields waived separately. OK to be two state" diff --git a/hw/ip/kmac/rtl/kmac.sv b/hw/ip/kmac/rtl/kmac.sv index 4cb66e85717d78..c9aa4e662a366c 100644 --- a/hw/ip/kmac/rtl/kmac.sv +++ b/hw/ip/kmac/rtl/kmac.sv @@ -28,7 +28,9 @@ 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 app_config_t AppCfg[NumAppIntf] = '{AppCfgKeyMgr, AppCfgLcCtrl, AppCfgRomCtrl}, parameter lfsr_perm_t RndCnstLfsrPerm = RndCnstLfsrPermDefault, parameter lfsr_seed_t RndCnstLfsrSeed = RndCnstLfsrSeedDefault, @@ -1042,7 +1044,9 @@ module kmac // Application interface Mux/Demux kmac_app #( .EnMasking(EnMasking), - .SecIdleAcceptSwMsg(SecIdleAcceptSwMsg) + .SecIdleAcceptSwMsg(SecIdleAcceptSwMsg), + .NumAppIntf(NumAppIntf), + .AppCfg(AppCfg) ) u_app_intf ( .clk_i, .rst_ni, diff --git a/hw/ip/kmac/rtl/kmac_app.sv b/hw/ip/kmac/rtl/kmac_app.sv index c2c784bf7c818c..8d00e87066fda9 100644 --- a/hw/ip/kmac/rtl/kmac_app.sv +++ b/hw/ip/kmac/rtl/kmac_app.sv @@ -10,9 +10,11 @@ module kmac_app import kmac_pkg::*; #( // App specific configs are defined in kmac_pkg - parameter bit EnMasking = 1'b0, - localparam int Share = (EnMasking) ? 2 : 1, // derived parameter - parameter bit SecIdleAcceptSwMsg = 1'b0 + parameter bit EnMasking = 1'b0, + localparam int Share = (EnMasking) ? 2 : 1, // derived parameter + parameter bit SecIdleAcceptSwMsg = 1'b0, + parameter int unsigned NumAppIntf = 3, + parameter app_config_t AppCfg[NumAppIntf] = '{AppCfgKeyMgr, AppCfgLcCtrl, AppCfgRomCtrl} ) ( input clk_i, input rst_ni, @@ -872,7 +874,7 @@ module kmac_app kmac_en_o <= AppCfg[arb_idx].Mode == AppKMAC ? 1'b 1 : 1'b 0; sha3_mode_o <= AppCfg[arb_idx].Mode == AppSHA3 ? sha3_pkg::Sha3 : sha3_pkg::CShake; - keccak_strength_o <= AppCfg[arb_idx].Strength ; + keccak_strength_o <= AppCfg[arb_idx].KeccakStrength ; end else if (st == StIdle) begin kmac_en_o <= reg_kmac_en_i; sha3_mode_o <= reg_sha3_mode_i; diff --git a/hw/ip/kmac/rtl/kmac_pkg.sv b/hw/ip/kmac/rtl/kmac_pkg.sv index b328b2ab053c5c..af930c299454e9 100644 --- a/hw/ip/kmac/rtl/kmac_pkg.sv +++ b/hw/ip/kmac/rtl/kmac_pkg.sv @@ -190,15 +190,6 @@ package kmac_pkg; // Application interface // /////////////////////////// - // Number of the application interface - // Currently KMAC has three interface. - // 0: KeyMgr - // 1: LC_CTRL - // 2: ROM_CTRL - // Make sure to change `width` of app inter-module signal definition - // if this value is changed. - parameter int unsigned NumAppIntf = 3; - // Application Algorithm // Each interface can choose algorithms among SHA3, cSHAKE, KMAC typedef enum bit [1:0] { @@ -228,7 +219,7 @@ package kmac_pkg; typedef struct packed { app_mode_e Mode; - sha3_pkg::keccak_strength_e Strength; + sha3_pkg::keccak_strength_e KeccakStrength; // PrefixMode determines the origin value of Prefix that is used in KMAC // and cSHAKE operations. @@ -241,33 +232,28 @@ package kmac_pkg; logic [NSPrefixW-1:0] Prefix; } app_config_t; - parameter app_config_t AppCfg [NumAppIntf] = '{ - // KeyMgr - '{ - Mode: AppKMAC, // KeyMgr uses KMAC operation - Strength: sha3_pkg::L256, - PrefixMode: 1'b 1, // Use prefix parameter - // {fname: encoded_string("KMAC"), custom_str: encoded_string("")} - Prefix: NSPrefixW'({EncodedStringEmpty, EncodedStringKMAC}) - }, - - // LC_CTRL - '{ - Mode: AppCShake, - Strength: sha3_pkg::L128, - PrefixMode: 1'b 1, // Use prefix parameter - // {fname: encode_string(""), custom_str: encode_string("LC_CTRL")} - Prefix: NSPrefixW'({EncodedStringLcCtrl, EncodedStringEmpty}) - }, - - // ROM_CTRL - '{ - Mode: AppCShake, - Strength: sha3_pkg::L256, - PrefixMode: 1'b 1, // Use prefix parameter - // {fname: encode_string(""), custom_str: encode_string("ROM_CTRL")} - Prefix: NSPrefixW'({EncodedStringRomCtrl, EncodedStringEmpty}) - } + parameter app_config_t AppCfgKeyMgr = '{ + Mode: AppKMAC, // KeyMgr uses KMAC operation + KeccakStrength: sha3_pkg::L256, + PrefixMode: 1'b 1, // Use prefix parameter + // {fname: encoded_string("KMAC"), custom_str: encoded_string("")} + Prefix: NSPrefixW'({EncodedStringEmpty, EncodedStringKMAC}) + }; + + parameter app_config_t AppCfgLcCtrl= '{ + Mode: AppCShake, + KeccakStrength: sha3_pkg::L128, + PrefixMode: 1'b 1, // Use prefix parameter + // {fname: encode_string(""), custom_str: encode_string("LC_CTRL")} + Prefix: NSPrefixW'({EncodedStringLcCtrl, EncodedStringEmpty}) + }; + + parameter app_config_t AppCfgRomCtrl = '{ + Mode: AppCShake, + KeccakStrength: sha3_pkg::L256, + PrefixMode: 1'b 1, // Use prefix parameter + // {fname: encode_string(""), custom_str: encode_string("ROM_CTRL")} + Prefix: NSPrefixW'({EncodedStringRomCtrl, EncodedStringEmpty}) }; // Exporting the app internal mux selection enum into the package. So that DV diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson index c9a2f3033b2b49..f4a9621fca97e6 100644 --- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson +++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson @@ -6530,6 +6530,29 @@ expose: "true" name_top: SecKmacIdleAcceptSwMsg } + { + name: NumAppIntf + desc: Number of application interfaces + type: int + default: 3 + local: "false" + expose: "true" + name_top: KmacNumAppIntf + } + { + name: AppCfg + desc: + ''' + Application interface configuration. + Top-level connection to the application interface must follow this definition. + ''' + type: kmac_pkg::app_config_t + unpacked_dimensions: "[KmacNumAppIntf]" + default: "'{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl}" + local: "false" + expose: "true" + name_top: KmacAppCfg + } { name: RndCnstLfsrSeed desc: Compile-time random data for PRNG default seed @@ -6591,7 +6614,17 @@ package: kmac_pkg type: req_rsp act: rsp - width: 3 + width: + { + name: NumAppIntf + desc: Number of application interfaces + param_type: int + unpacked_dimensions: null + default: 3 + local: false + expose: true + name_top: KmacNumAppIntf + } inst_name: kmac default: "" end_idx: -1 @@ -20343,7 +20376,17 @@ package: kmac_pkg type: req_rsp act: rsp - width: 3 + width: + { + name: NumAppIntf + desc: Number of application interfaces + param_type: int + unpacked_dimensions: null + default: 3 + local: false + expose: true + name_top: KmacNumAppIntf + } inst_name: kmac default: "" end_idx: -1 @@ -23449,7 +23492,17 @@ package: kmac_pkg struct: app_req signame: kmac_app_req - width: 3 + width: + { + name: NumAppIntf + desc: Number of application interfaces + param_type: int + unpacked_dimensions: null + default: 3 + local: false + expose: true + name_top: KmacNumAppIntf + } type: req_rsp end_idx: -1 act: rsp @@ -23460,7 +23513,17 @@ package: kmac_pkg struct: app_rsp signame: kmac_app_rsp - width: 3 + width: + { + name: NumAppIntf + desc: Number of application interfaces + param_type: int + unpacked_dimensions: null + default: 3 + local: false + 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 a4fa3db4c2a101..9e7564cff1119a 100644 --- a/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv +++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey.sv @@ -83,6 +83,9 @@ module top_earlgrey #( parameter bit KmacSwKeyMasked = 0, parameter int SecKmacCmdDelay = 0, parameter bit SecKmacIdleAcceptSwMsg = 0, + parameter int KmacNumAppIntf = 3, + parameter kmac_pkg::app_config_t KmacAppCfg[KmacNumAppIntf] = + '{kmac_pkg::AppCfgKeyMgr, kmac_pkg::AppCfgLcCtrl, kmac_pkg::AppCfgRomCtrl}, // parameters for otbn parameter bit OtbnStub = 0, parameter otbn_pkg::regfile_e OtbnRegFile = otbn_pkg::RegFileFF, @@ -601,8 +604,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; @@ -2318,6 +2321,8 @@ module top_earlgrey #( .SwKeyMasked(KmacSwKeyMasked), .SecCmdDelay(SecKmacCmdDelay), .SecIdleAcceptSwMsg(SecKmacIdleAcceptSwMsg), + .NumAppIntf(KmacNumAppIntf), + .AppCfg(KmacAppCfg), .RndCnstLfsrSeed(RndCnstKmacLfsrSeed), .RndCnstLfsrPerm(RndCnstKmacLfsrPerm), .RndCnstBufferLfsrSeed(RndCnstKmacBufferLfsrSeed),