Skip to content

Commit 67746ee

Browse files
[hw] Enact vendoring of KMAC/ROM patches
1 parent 34fddbb commit 67746ee

6 files changed

Lines changed: 55 additions & 15 deletions

File tree

hw/vendor/lowrisc_ip/ip/kmac/kmac.core

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ filesets:
1717
- lowrisc:prim:trivium
1818
- lowrisc:prim:mubi
1919
- lowrisc:ip:tlul
20-
- lowrisc:ip:keymgr_pkg
2120
- lowrisc:ip:sha3
22-
- lowrisc:ip:edn_pkg
23-
- lowrisc:prim:edn_req
2421
- lowrisc:ip:kmac_pkg
2522
- lowrisc:ip:lc_ctrl_pkg
2623
- lowrisc:prim:lc_sync

hw/vendor/lowrisc_ip/ip/kmac/rtl/kmac.sv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ module kmac
5757
output prim_alert_pkg::alert_tx_t [NumAlerts-1:0] alert_tx_o,
5858

5959
// KeyMgr sideload (secret key) interface
60-
input keymgr_pkg::hw_key_req_t keymgr_key_i,
60+
input hw_key_req_t keymgr_key_i,
6161

6262
// KeyMgr KDF data path
6363
input app_req_t [NumAppIntf-1:0] app_i,
6464
output app_rsp_t [NumAppIntf-1:0] app_o,
6565

6666
// EDN interface
67-
output edn_pkg::edn_req_t entropy_o,
68-
input edn_pkg::edn_rsp_t entropy_i,
67+
output edn_req_t entropy_o,
68+
input edn_rsp_t entropy_i,
6969

7070
// Life cycle
7171
input lc_ctrl_pkg::lc_tx_t lc_escalate_en_i,
@@ -1224,12 +1224,12 @@ module kmac
12241224
if (EnMasking == 1) begin : gen_entropy
12251225

12261226
logic entropy_req, entropy_ack;
1227-
logic [edn_pkg::ENDPOINT_BUS_WIDTH-1:0] entropy_data;
1227+
logic [ENDPOINT_BUS_WIDTH-1:0] entropy_data;
12281228
logic unused_entropy_fips;
12291229

12301230
// Synchronize EDN interface
12311231
prim_sync_reqack_data #(
1232-
.Width(edn_pkg::ENDPOINT_BUS_WIDTH),
1232+
.Width(ENDPOINT_BUS_WIDTH),
12331233
.DataSrc2Dst(1'b0),
12341234
.DataReg(1'b0)
12351235
) u_prim_sync_reqack_data (
@@ -1310,7 +1310,7 @@ module kmac
13101310
);
13111311
end else begin : gen_empty_entropy
13121312
// If Masking is not used, no need of entropy. Ignore inputs and config; tie output to 0.
1313-
edn_pkg::edn_rsp_t unused_entropy_input;
1313+
edn_rsp_t unused_entropy_input;
13141314
entropy_mode_e unused_entropy_mode;
13151315
logic unused_entropy_fast_process;
13161316

hw/vendor/lowrisc_ip/ip/kmac/rtl/kmac_app.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module kmac_app
3838
output logic sw_ready_o,
3939

4040
// KeyMgr Sideload Key interface
41-
input keymgr_pkg::hw_key_req_t keymgr_key_i,
41+
input hw_key_req_t keymgr_key_i,
4242

4343
// Application Message in/ Digest out interface + control signals
4444
input app_req_t [NumAppIntf-1:0] app_i,
@@ -774,7 +774,7 @@ module kmac_app
774774
end else begin : g_unmasked_key
775775
always_comb begin
776776
keymgr_key[0] = '0;
777-
for (int i = 0; i < keymgr_pkg::Shares; i++) begin
777+
for (int i = 0; i < Shares; i++) begin
778778
keymgr_key[0][KeyMgrKeyW-1:0] ^= keymgr_key_i.key[i];
779779
end
780780
end

hw/vendor/lowrisc_ip/ip/kmac/rtl/kmac_entropy.sv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module kmac_entropy
2020
// EDN interface
2121
output logic entropy_req_o,
2222
input entropy_ack_i,
23-
input [edn_pkg::ENDPOINT_BUS_WIDTH-1:0] entropy_data_i,
23+
input [ENDPOINT_BUS_WIDTH-1:0] entropy_data_i,
2424

2525
// Entropy to internal
2626
output logic rand_valid_o,
@@ -194,7 +194,7 @@ module kmac_entropy
194194
// SW configures to use EDN or ENTROPY_SEED register as PRNG seed
195195
logic seed_en, seed_done;
196196
logic seed_req, seed_ack;
197-
logic [edn_pkg::ENDPOINT_BUS_WIDTH-1:0] seed;
197+
logic [ENDPOINT_BUS_WIDTH-1:0] seed;
198198
logic prng_en;
199199
logic [EntropyOutputW-1:0] prng_data, prng_data_permuted;
200200

@@ -359,7 +359,7 @@ module kmac_entropy
359359
.OutputWidth (EntropyOutputW),
360360
.StrictLockupProtection(1),
361361
.SeedType (prim_trivium_pkg::SeedTypeStatePartial),
362-
.PartialSeedWidth (edn_pkg::ENDPOINT_BUS_WIDTH),
362+
.PartialSeedWidth (ENDPOINT_BUS_WIDTH),
363363
.RndCnstTriviumLfsrSeed(RndCnstLfsrSeed)
364364
) u_prim_trivium (
365365
.clk_i (clk_i),
@@ -758,7 +758,7 @@ module kmac_entropy
758758

759759
// The EDN bus width needs to be equal to the width of the ENTROPY_SEED
760760
// register as this module doesn't perform width adaption.
761-
`ASSERT_INIT(EdnBusWidth_A, edn_pkg::ENDPOINT_BUS_WIDTH == 32)
761+
`ASSERT_INIT(EdnBusWidth_A, ENDPOINT_BUS_WIDTH == 32)
762762

763763
// the code below is not meant to be synthesized,
764764
// but it is intended to be used in simulation and FPV

hw/vendor/lowrisc_ip/ip/kmac/rtl/kmac_pkg.sv

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,38 @@ package kmac_pkg;
474474
conv_endian32 = (swap) ? conv_data : v ;
475475
endfunction : conv_endian32
476476

477+
478+
///////////////////////
479+
// KEYMGR Copy-Paste //
480+
///////////////////////
481+
482+
parameter int KeyWidth = 256;
483+
parameter int Shares = 2;
484+
typedef struct packed {
485+
logic valid;
486+
logic [Shares-1:0][KeyWidth-1:0] key;
487+
} hw_key_req_t;
488+
489+
parameter hw_key_req_t HW_KEY_REQ_DEFAULT = '{
490+
valid: 1'b0,
491+
key: {Shares{KeyWidth'(32'hDEADBEEF)}}
492+
};
493+
494+
////////////////////
495+
// EDN Copy-Paste //
496+
////////////////////
497+
498+
parameter int unsigned ENDPOINT_BUS_WIDTH = 32;
499+
500+
typedef struct packed {
501+
logic edn_req;
502+
} edn_req_t;
503+
typedef struct packed {
504+
logic edn_ack;
505+
logic edn_fips;
506+
logic [ENDPOINT_BUS_WIDTH-1:0] edn_bus;
507+
} edn_rsp_t;
508+
509+
parameter edn_rsp_t EDN_RSP_DEFAULT = '0;
510+
477511
endpackage : kmac_pkg

hw/vendor/lowrisc_ip/ip/rom_ctrl/util/scramble_image.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
import hjson # type: ignore
1313
from Crypto.Hash import cSHAKE256
1414

15+
# Add to the PATH the directory that this script and its "mem" dependency
16+
# expect to be able to use relative paths to import other dependencies from.
17+
from pathlib import Path
18+
PROJECT_ROOT = Path.resolve(Path(__file__)).parent.parent.parent.parent.parent.parent.parent
19+
LOWRISC_IP_ROOT = PROJECT_ROOT / Path("hw/vendor/lowrisc_ip")
20+
print("PROJECT_ROOT: ", PROJECT_ROOT)
21+
print("LOWRISC_IP_ROOT:", LOWRISC_IP_ROOT)
22+
sys.path.append(str(LOWRISC_IP_ROOT))
23+
1524
from mem import MemChunk, MemFile
1625
from util.design.prince import prince, sbox # type: ignore
1726
from util.design.secded_gen import ecc_encode_some # type: ignore

0 commit comments

Comments
 (0)