Skip to content

Commit

Permalink
[hw,kmac,rtl] Parametrize the number of app interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Schilling <[email protected]>
  • Loading branch information
Razer6 committed Nov 8, 2024
1 parent 6ac4a95 commit 87e5060
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 36 deletions.
9 changes: 8 additions & 1 deletion hw/ip/kmac/data/kmac.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@
local: "false"
expose: "true"
}
{ name: "NumAppIntf"
type: "int"
default: "3"
desc: "Number of words for the secret key"
local: "true",
expose: "true"
}
{ name: "NumWordsKey"
type: "int"
default: "16"
Expand Down Expand Up @@ -196,7 +203,7 @@
name: "app"
act: "rsp"
package: "kmac_pkg"
width: "3"
width: "NumAppIntf"
}
{ struct: "edn"
type: "req_rsp"
Expand Down
18 changes: 9 additions & 9 deletions hw/ip/kmac/doc/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <reggen.params.Parameter object at 0x105ce36f0> | |
| 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

Expand Down
4 changes: 2 additions & 2 deletions hw/ip/kmac/dv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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[kmac_reg_pkg::NumAppIntf]: An array of analysis FIFOs to hold request transactions coming from the various application interfaces
* kmac_app_rsp_fifo[kmac_reg_pkg::NumAppIntf]: 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.
Expand Down
6 changes: 3 additions & 3 deletions hw/ip/kmac/dv/env/kmac_env.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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_reg_pkg::NumAppIntf];
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_reg_pkg::NumAppIntf; 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]);
Expand All @@ -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_reg_pkg::NumAppIntf; 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);
Expand Down
4 changes: 2 additions & 2 deletions hw/ip/kmac/dv/env/kmac_env_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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_reg_pkg::NumAppIntf];
rand key_sideload_agent_cfg keymgr_sideload_agent_cfg;

// Masked KMAC is the default configuration
Expand Down Expand Up @@ -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_reg_pkg::NumAppIntf; 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;
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/kmac/dv/env/kmac_env_cov.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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_reg_pkg::NumAppIntf];

covergroup msg_len_cg with function sample(int len);
msg_len: coverpoint len {
Expand Down
1 change: 1 addition & 0 deletions hw/ip/kmac/dv/env/kmac_env_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kmac_env_pkg;
import kmac_app_agent_pkg::*;
import kmac_ral_pkg::*;
import kmac_pkg::*;
import kmac_reg_pkg::*;
import keymgr_pkg::*;
import key_sideload_agent_pkg::*;
import sec_cm_pkg::*;
Expand Down
4 changes: 2 additions & 2 deletions hw/ip/kmac/dv/env/kmac_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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_reg_pkg::NumAppIntf-1:0] app_req;
kmac_pkg::app_rsp_t [kmac_reg_pkg::NumAppIntf-1:0] app_rsp;

function automatic void drive_lc_escalate(lc_ctrl_pkg::lc_tx_t val);
lc_escalate_en_i = val;
Expand Down
6 changes: 3 additions & 3 deletions hw/ip/kmac/dv/env/kmac_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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[kmac_reg_pkg::NumAppIntf];
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[kmac_reg_pkg::NumAppIntf];

`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 < kmac_reg_pkg::NumAppIntf; 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
Expand Down
2 changes: 1 addition & 1 deletion hw/ip/kmac/dv/env/kmac_virtual_sequencer.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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_reg_pkg::NumAppIntf];
key_sideload_sequencer key_sideload_sequencer_h;

endclass
Original file line number Diff line number Diff line change
Expand Up @@ -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_reg_pkg::NumAppIntf; i++) begin
cfg.m_kmac_app_agent_cfg[i].inject_zero_in_host_strb = 1;
end
cfg.do_cycle_accurate_check = 0;
Expand Down
8 changes: 4 additions & 4 deletions hw/ip/kmac/dv/tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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 [kmac_reg_pkg::NumAppIntf-1:0] app_req;
kmac_pkg::app_rsp_t [kmac_reg_pkg::NumAppIntf-1:0] app_rsp;

// interfaces
clk_rst_if clk_rst_if(.clk(clk), .rst_n(rst_n));
Expand All @@ -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[kmac_reg_pkg::NumAppIntf](.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
Expand Down Expand Up @@ -89,7 +89,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 < kmac_reg_pkg::NumAppIntf; 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];
Expand Down
1 change: 1 addition & 0 deletions hw/ip/kmac/kmac_pkg.core
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ filesets:
- lowrisc:constants:top_pkg
- lowrisc:ip:sha3
files:
- rtl/kmac_reg_pkg.sv
- rtl/kmac_pkg.sv
file_type: systemVerilogSource

Expand Down
3 changes: 2 additions & 1 deletion hw/ip/kmac/rtl/kmac.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions hw/ip/kmac/rtl/kmac_reg_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package kmac_reg_pkg;

// Param list
parameter int NumAppIntf = 3;
parameter int NumWordsKey = 16;
parameter int NumWordsPrefix = 11;
parameter int NumEntriesMsgFifo = 10;
Expand Down
53 changes: 49 additions & 4 deletions hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2357,6 +2358,7 @@ module top_earlgrey #(
.SwKeyMasked(KmacSwKeyMasked),
.SecCmdDelay(SecKmacCmdDelay),
.SecIdleAcceptSwMsg(SecKmacIdleAcceptSwMsg),
.NumAppIntf(KmacNumAppIntf),
.RndCnstLfsrSeed(RndCnstKmacLfsrSeed),
.RndCnstLfsrPerm(RndCnstKmacLfsrPerm),
.RndCnstBufferLfsrSeed(RndCnstKmacBufferLfsrSeed),
Expand Down

0 comments on commit 87e5060

Please sign in to comment.