Knock OTBN memory range from 4MiB to 256KiB This should make it a bit easier to fit all the peripherals together in the memory map. There's still a 64KiB address space for each memory (they're currently 4KiB in size), so we can grow by a factor of 16 without running out of addresses. If we're slapping down more SRAM than that, our address map will be the least of our worries! Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otbn/data/otbn.hjson b/hw/ip/otbn/data/otbn.hjson index c6a6062..a80fe01 100644 --- a/hw/ip/otbn/data/otbn.hjson +++ b/hw/ip/otbn/data/otbn.hjson
@@ -147,9 +147,9 @@ } // register : start_addr - // Give IMEM and DMEM 1 MB address space, each, to allow for easy expansion + // Give IMEM and DMEM 16 KiB address space, each, to allow for easy expansion // of the actual IMEM and DMEM sizes without changing the address map. - { skipto: "0x100000" } + { skipto: "0x4000" } { window: { name: "IMEM" @@ -167,7 +167,7 @@ } } - { skipto: "0x200000" } + { skipto: "0x8000" } { window: { name: "DMEM"
diff --git a/hw/ip/otbn/dv/memutil/otbn_memutil.cc b/hw/ip/otbn/dv/memutil/otbn_memutil.cc index 8e05ca7..b354fda 100644 --- a/hw/ip/otbn/dv/memutil/otbn_memutil.cc +++ b/hw/ip/otbn/dv/memutil/otbn_memutil.cc
@@ -11,14 +11,14 @@ #include <stdexcept> OtbnMemUtil::OtbnMemUtil(const std::string &top_scope) { - MemAreaLoc imem_loc = {.base = 0x100000, .size = 4096}; + MemAreaLoc imem_loc = {.base = 0x4000, .size = 4096}; std::string imem_scope = top_scope + ".u_imem.u_mem.gen_generic.u_impl_generic"; if (!RegisterMemoryArea("imem", imem_scope, 32, &imem_loc)) { throw std::runtime_error("Failed to register IMEM OTBN memory area."); } - MemAreaLoc dmem_loc = {.base = 0x200000, .size = 4096}; + MemAreaLoc dmem_loc = {.base = 0x8000, .size = 4096}; std::string dmem_scope = top_scope + ".u_dmem.u_mem.gen_generic.u_impl_generic"; if (!RegisterMemoryArea("dmem", dmem_scope, 256, &dmem_loc)) {
diff --git a/hw/ip/otbn/dv/verilator/otbn_top_sim_waivers.vlt b/hw/ip/otbn/dv/verilator/otbn_top_sim_waivers.vlt index b131d75..49bca62 100644 --- a/hw/ip/otbn/dv/verilator/otbn_top_sim_waivers.vlt +++ b/hw/ip/otbn/dv/verilator/otbn_top_sim_waivers.vlt
@@ -4,7 +4,7 @@ `verilator_config -lint_off -rule WIDTH -file "*/otbn_top_sim.sv" -match "*'OTBN_IMEM_SIZE' generates 22 bits*" -lint_off -rule WIDTH -file "*/otbn_top_sim.sv" -match "*'OTBN_DMEM_SIZE' generates 22 bits*" +lint_off -rule WIDTH -file "*/otbn_top_sim.sv" -match "*'OTBN_IMEM_SIZE' generates * bits*" +lint_off -rule WIDTH -file "*/otbn_top_sim.sv" -match "*'OTBN_DMEM_SIZE' generates * bits*" lint_off -rule WIDTH -file "*/otbn_top_sim.sv" -match "*'ImemStartAddr' generates 32 bits*" lint_off -rule WIDTH -file "*/otbn_top_sim.sv" -match "*'stack_wr_ptr_q' generates 4 bits*"
diff --git a/hw/ip/otbn/rtl/otbn_reg_pkg.sv b/hw/ip/otbn/rtl/otbn_reg_pkg.sv index 2e8c9df..d4ea4f9 100644 --- a/hw/ip/otbn/rtl/otbn_reg_pkg.sv +++ b/hw/ip/otbn/rtl/otbn_reg_pkg.sv
@@ -120,20 +120,20 @@ } otbn_hw2reg_t; // Register Address - parameter logic [21:0] OTBN_INTR_STATE_OFFSET = 22'h 0; - parameter logic [21:0] OTBN_INTR_ENABLE_OFFSET = 22'h 4; - parameter logic [21:0] OTBN_INTR_TEST_OFFSET = 22'h 8; - parameter logic [21:0] OTBN_ALERT_TEST_OFFSET = 22'h c; - parameter logic [21:0] OTBN_CMD_OFFSET = 22'h 10; - parameter logic [21:0] OTBN_STATUS_OFFSET = 22'h 14; - parameter logic [21:0] OTBN_ERR_CODE_OFFSET = 22'h 18; - parameter logic [21:0] OTBN_START_ADDR_OFFSET = 22'h 1c; + parameter logic [15:0] OTBN_INTR_STATE_OFFSET = 16'h 0; + parameter logic [15:0] OTBN_INTR_ENABLE_OFFSET = 16'h 4; + parameter logic [15:0] OTBN_INTR_TEST_OFFSET = 16'h 8; + parameter logic [15:0] OTBN_ALERT_TEST_OFFSET = 16'h c; + parameter logic [15:0] OTBN_CMD_OFFSET = 16'h 10; + parameter logic [15:0] OTBN_STATUS_OFFSET = 16'h 14; + parameter logic [15:0] OTBN_ERR_CODE_OFFSET = 16'h 18; + parameter logic [15:0] OTBN_START_ADDR_OFFSET = 16'h 1c; // Window parameter - parameter logic [21:0] OTBN_IMEM_OFFSET = 22'h 100000; - parameter logic [21:0] OTBN_IMEM_SIZE = 22'h 1000; - parameter logic [21:0] OTBN_DMEM_OFFSET = 22'h 200000; - parameter logic [21:0] OTBN_DMEM_SIZE = 22'h 1000; + parameter logic [15:0] OTBN_IMEM_OFFSET = 16'h 4000; + parameter logic [15:0] OTBN_IMEM_SIZE = 16'h 1000; + parameter logic [15:0] OTBN_DMEM_OFFSET = 16'h 8000; + parameter logic [15:0] OTBN_DMEM_SIZE = 16'h 1000; // Register Index typedef enum int {
diff --git a/hw/ip/otbn/rtl/otbn_reg_top.sv b/hw/ip/otbn/rtl/otbn_reg_top.sv index 9a2b40f..d9928fe 100644 --- a/hw/ip/otbn/rtl/otbn_reg_top.sv +++ b/hw/ip/otbn/rtl/otbn_reg_top.sv
@@ -28,7 +28,7 @@ import otbn_reg_pkg::* ; - localparam int AW = 22; + localparam int AW = 16; localparam int DW = 32; localparam int DBW = DW/8; // Byte Width @@ -88,10 +88,10 @@ reg_steer = 2; // Default set to register // TODO: Can below codes be unique case () inside ? - if (tl_i.a_address[AW-1:0] >= 1048576 && tl_i.a_address[AW-1:0] < 1052672) begin + if (tl_i.a_address[AW-1:0] >= 16384 && tl_i.a_address[AW-1:0] < 20480) begin reg_steer = 0; end - if (tl_i.a_address[AW-1:0] >= 2097152 && tl_i.a_address[AW-1:0] < 2101248) begin + if (tl_i.a_address[AW-1:0] >= 32768 && tl_i.a_address[AW-1:0] < 36864) begin reg_steer = 1; end end
diff --git a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson index 3981cd6..91c3fcd 100644 --- a/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson +++ b/hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
@@ -3372,7 +3372,7 @@ clk_i: clkmgr_clocks.clk_main_otbn } domain: "0" - size: 0x400000 + size: 0x10000 bus_device: tlul bus_host: none available_input_list: [] @@ -4302,7 +4302,7 @@ [ { base_addr: 0x50000000 - size_byte: 0x400000 + size_byte: 0x10000 } ] xbar: false
diff --git a/hw/top_earlgrey/dv/autogen/xbar_env_pkg__params.sv b/hw/top_earlgrey/dv/autogen/xbar_env_pkg__params.sv index df04a3d..7744543 100644 --- a/hw/top_earlgrey/dv/autogen/xbar_env_pkg__params.sv +++ b/hw/top_earlgrey/dv/autogen/xbar_env_pkg__params.sv
@@ -47,7 +47,7 @@ '{32'h40140000, 32'h40140fff} }}, '{"otbn", '{ - '{32'h50000000, 32'h503fffff} + '{32'h50000000, 32'h5000ffff} }}, '{"keymgr", '{ '{32'h401a0000, 32'h401a0fff}
diff --git a/hw/top_earlgrey/ip/xbar_main/data/autogen/xbar_main.gen.hjson b/hw/top_earlgrey/ip/xbar_main/data/autogen/xbar_main.gen.hjson index b3e9f8b..6a382f6 100644 --- a/hw/top_earlgrey/ip/xbar_main/data/autogen/xbar_main.gen.hjson +++ b/hw/top_earlgrey/ip/xbar_main/data/autogen/xbar_main.gen.hjson
@@ -392,7 +392,7 @@ [ { base_addr: 0x50000000 - size_byte: 0x400000 + size_byte: 0x10000 } ] xbar: false
diff --git a/hw/top_earlgrey/ip/xbar_main/dv/autogen/xbar_env_pkg__params.sv b/hw/top_earlgrey/ip/xbar_main/dv/autogen/xbar_env_pkg__params.sv index 811963b..0406f01 100644 --- a/hw/top_earlgrey/ip/xbar_main/dv/autogen/xbar_env_pkg__params.sv +++ b/hw/top_earlgrey/ip/xbar_main/dv/autogen/xbar_env_pkg__params.sv
@@ -56,7 +56,7 @@ '{32'h40140000, 32'h40140fff} }}, '{"otbn", '{ - '{32'h50000000, 32'h503fffff} + '{32'h50000000, 32'h5000ffff} }}, '{"keymgr", '{ '{32'h401a0000, 32'h401a0fff}
diff --git a/hw/top_earlgrey/ip/xbar_main/rtl/autogen/tl_main_pkg.sv b/hw/top_earlgrey/ip/xbar_main/rtl/autogen/tl_main_pkg.sv index 2ab6b8c..cc20554 100644 --- a/hw/top_earlgrey/ip/xbar_main/rtl/autogen/tl_main_pkg.sv +++ b/hw/top_earlgrey/ip/xbar_main/rtl/autogen/tl_main_pkg.sv
@@ -53,7 +53,7 @@ localparam logic [31:0] ADDR_MASK_PADCTRL = 32'h 00000fff; localparam logic [31:0] ADDR_MASK_ALERT_HANDLER = 32'h 00000fff; localparam logic [31:0] ADDR_MASK_NMI_GEN = 32'h 00000fff; - localparam logic [31:0] ADDR_MASK_OTBN = 32'h 003fffff; + localparam logic [31:0] ADDR_MASK_OTBN = 32'h 0000ffff; localparam logic [31:0] ADDR_MASK_KEYMGR = 32'h 00000fff; localparam int N_HOST = 3;
diff --git a/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv b/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv index 5aedd7d..00009a6 100644 --- a/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv +++ b/hw/top_earlgrey/rtl/autogen/top_earlgrey_pkg.sv
@@ -219,7 +219,7 @@ /** * Peripheral size in bytes for otbn in top earlgrey. */ - parameter int unsigned TOP_EARLGREY_OTBN_SIZE_BYTES = 32'h400000; + parameter int unsigned TOP_EARLGREY_OTBN_SIZE_BYTES = 32'h10000; /** * Memory base address for rom in top earlgrey.
diff --git a/hw/top_earlgrey/sw/autogen/top_earlgrey.h b/hw/top_earlgrey/sw/autogen/top_earlgrey.h index 57f56ca..4438b21 100644 --- a/hw/top_earlgrey/sw/autogen/top_earlgrey.h +++ b/hw/top_earlgrey/sw/autogen/top_earlgrey.h
@@ -401,7 +401,7 @@ * address between #TOP_EARLGREY_OTBN_BASE_ADDR and * `TOP_EARLGREY_OTBN_BASE_ADDR + TOP_EARLGREY_OTBN_SIZE_BYTES`. */ -#define TOP_EARLGREY_OTBN_SIZE_BYTES 0x400000u +#define TOP_EARLGREY_OTBN_SIZE_BYTES 0x10000u /**