[otbn,dv] Fix up DMEM size for DV code

Commit 9535680 halves the bus-accessible size of DMEM. One side effect
is that the auto-generated otbn_reg_pkg::OTBN_DMEM_SIZE gets
halved (even though the memory doesn't actually change size). Put the
factor of 2 back in where needed.

Also, drop the IMEM/DMEM size parameters completely from the model,
since they aren't needed anyway (the Python ignores them and gets its
sizes directly from the hjson).

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otbn/dv/model/otbn_core_model.sv b/hw/ip/otbn/dv/model/otbn_core_model.sv
index 002ff2a..2c2fcf3 100644
--- a/hw/ip/otbn/dv/model/otbn_core_model.sv
+++ b/hw/ip/otbn/dv/model/otbn_core_model.sv
@@ -16,11 +16,6 @@
   import otbn_model_pkg::*;
   import edn_pkg::*;
 #(
-  // Size of the instruction memory, in bytes
-  parameter int ImemSizeByte = 4096,
-  // Size of the data memory, in bytes
-  parameter int DmemSizeByte = 4096,
-
   // The scope that contains the instruction and data memory (for DPI)
   parameter string MemScope = "",
 
@@ -56,13 +51,10 @@
   output bit             err_o // something went wrong
 );
 
-  localparam int ImemSizeWords = ImemSizeByte / 4;
-  localparam int DmemSizeWords = DmemSizeByte / (WLEN / 8);
-
   // Create and destroy an object through which we can talk to the ISS.
   chandle model_handle;
   initial begin
-    model_handle = otbn_model_init(MemScope, DesignScope, ImemSizeWords, DmemSizeWords);
+    model_handle = otbn_model_init(MemScope, DesignScope);
     assert(model_handle != null);
   end
   final begin
diff --git a/hw/ip/otbn/dv/model/otbn_model.cc b/hw/ip/otbn/dv/model/otbn_model.cc
index b5577f3..be1c77c 100644
--- a/hw/ip/otbn/dv/model/otbn_model.cc
+++ b/hw/ip/otbn/dv/model/otbn_model.cc
@@ -220,12 +220,8 @@
 }
 
 OtbnModel::OtbnModel(const std::string &mem_scope,
-                     const std::string &design_scope, unsigned imem_size_words,
-                     unsigned dmem_size_words)
-    : mem_util_(mem_scope),
-      design_scope_(design_scope),
-      imem_size_words_(imem_size_words),
-      dmem_size_words_(dmem_size_words) {}
+                     const std::string &design_scope)
+    : mem_util_(mem_scope), design_scope_(design_scope) {}
 
 OtbnModel::~OtbnModel() {}
 
@@ -638,10 +634,9 @@
   return good;
 }
 
-OtbnModel *otbn_model_init(const char *mem_scope, const char *design_scope,
-                           unsigned imem_words, unsigned dmem_words) {
+OtbnModel *otbn_model_init(const char *mem_scope, const char *design_scope) {
   assert(mem_scope && design_scope);
-  return new OtbnModel(mem_scope, design_scope, imem_words, dmem_words);
+  return new OtbnModel(mem_scope, design_scope);
 }
 
 void otbn_model_destroy(OtbnModel *model) { delete model; }
diff --git a/hw/ip/otbn/dv/model/otbn_model.h b/hw/ip/otbn/dv/model/otbn_model.h
index 616010b..dad95f6 100644
--- a/hw/ip/otbn/dv/model/otbn_model.h
+++ b/hw/ip/otbn/dv/model/otbn_model.h
@@ -16,8 +16,7 @@
 
 class OtbnModel {
  public:
-  OtbnModel(const std::string &mem_scope, const std::string &design_scope,
-            unsigned imem_size_words, unsigned dmem_size_words);
+  OtbnModel(const std::string &mem_scope, const std::string &design_scope);
   ~OtbnModel();
 
   // Replace any current loop warps with those from memutil. Returns 0
@@ -109,7 +108,6 @@
   std::unique_ptr<ISSWrapper> iss_;
   OtbnMemUtil mem_util_;
   std::string design_scope_;
-  unsigned imem_size_words_, dmem_size_words_;
 };
 
 #endif  // OPENTITAN_HW_IP_OTBN_DV_MODEL_OTBN_MODEL_H_
diff --git a/hw/ip/otbn/dv/model/otbn_model_dpi.h b/hw/ip/otbn/dv/model/otbn_model_dpi.h
index 069df88..17d0c26 100644
--- a/hw/ip/otbn/dv/model/otbn_model_dpi.h
+++ b/hw/ip/otbn/dv/model/otbn_model_dpi.h
@@ -16,8 +16,7 @@
 extern "C" {
 
 // Create an OtbnModel object. Will always succeed.
-OtbnModel *otbn_model_init(const char *mem_scope, const char *design_scope,
-                           unsigned imem_words, unsigned dmem_words);
+OtbnModel *otbn_model_init(const char *mem_scope, const char *design_scope);
 
 // Delete an OtbnModel
 void otbn_model_destroy(OtbnModel *model);
diff --git a/hw/ip/otbn/dv/model/otbn_model_pkg.sv b/hw/ip/otbn/dv/model/otbn_model_pkg.sv
index e87044c..0e7da38 100644
--- a/hw/ip/otbn/dv/model/otbn_model_pkg.sv
+++ b/hw/ip/otbn/dv/model/otbn_model_pkg.sv
@@ -10,9 +10,7 @@
   import otbn_pkg::WLEN;
 
   import "DPI-C" context function chandle otbn_model_init(string mem_scope,
-                                                          string design_scope,
-                                                          int unsigned imem_words,
-                                                          int unsigned dmem_words);
+                                                          string design_scope);
 
   import "DPI-C" function void otbn_model_destroy(chandle model);
 
diff --git a/hw/ip/otbn/dv/uvm/env/otbn_env_cov.sv b/hw/ip/otbn/dv/uvm/env/otbn_env_cov.sv
index 02d6ace..c4c053b 100644
--- a/hw/ip/otbn/dv/uvm/env/otbn_env_cov.sv
+++ b/hw/ip/otbn/dv/uvm/env/otbn_env_cov.sv
@@ -11,7 +11,7 @@
 class otbn_env_cov extends cip_base_env_cov #(.CFG_T(otbn_env_cfg));
   `uvm_component_utils(otbn_env_cov)
 
-  localparam int DmemSizeByte = int'(otbn_reg_pkg::OTBN_DMEM_SIZE);
+  localparam int DmemSizeByte = 2 * int'(otbn_reg_pkg::OTBN_DMEM_SIZE);
   localparam int ImemSizeByte = int'(otbn_reg_pkg::OTBN_IMEM_SIZE);
 
   // A field for each known mnemonic, cast to a mnem_str_t. We have to do this because VCS (at
diff --git a/hw/ip/otbn/dv/uvm/env/otbn_env_pkg.sv b/hw/ip/otbn/dv/uvm/env/otbn_env_pkg.sv
index ba4ab31..808101e 100644
--- a/hw/ip/otbn/dv/uvm/env/otbn_env_pkg.sv
+++ b/hw/ip/otbn/dv/uvm/env/otbn_env_pkg.sv
@@ -96,7 +96,7 @@
   typedef class otbn_scoreboard;
 
   parameter int ImemIndexWidth = vbits(int'(otbn_reg_pkg::OTBN_IMEM_SIZE) / 4);
-  parameter int DmemIndexWidth = vbits(int'(otbn_reg_pkg::OTBN_DMEM_SIZE) / 32);
+  parameter int DmemIndexWidth = vbits(2 * int'(otbn_reg_pkg::OTBN_DMEM_SIZE) / 32);
 
   // package sources
   `include "otbn_env_cfg.sv"
diff --git a/hw/ip/otbn/dv/uvm/env/seq_lib/otbn_base_vseq.sv b/hw/ip/otbn/dv/uvm/env/seq_lib/otbn_base_vseq.sv
index 32e0858..f4aebfd 100644
--- a/hw/ip/otbn/dv/uvm/env/seq_lib/otbn_base_vseq.sv
+++ b/hw/ip/otbn/dv/uvm/env/seq_lib/otbn_base_vseq.sv
@@ -76,7 +76,8 @@
 
   protected function automatic void
   get_queue_entries(bit for_imem, ref otbn_loaded_word entries[$]);
-    // Get the size of this memory (to make sure the number of loaded words makes sense)
+    // Get the bus-accessible size of this memory (to make sure the number of loaded words makes
+    // sense)
     int unsigned mem_size = for_imem ? OTBN_IMEM_SIZE : OTBN_DMEM_SIZE;
 
     // Iterate over the segments for this memory
diff --git a/hw/ip/otbn/dv/uvm/tb.sv b/hw/ip/otbn/dv/uvm/tb.sv
index ed35a91..44cc915 100644
--- a/hw/ip/otbn/dv/uvm/tb.sv
+++ b/hw/ip/otbn/dv/uvm/tb.sv
@@ -196,8 +196,6 @@
   bit [31:0] model_insn_cnt;
 
   otbn_core_model #(
-    .DmemSizeByte (otbn_reg_pkg::OTBN_DMEM_SIZE),
-    .ImemSizeByte (otbn_reg_pkg::OTBN_IMEM_SIZE),
     .MemScope     ("..dut"),
     .DesignScope  ("..dut.u_otbn_core")
   ) u_model (
@@ -266,6 +264,7 @@
 
   initial begin
     mem_bkdr_util imem_util, dmem_util;
+    int unsigned real_dmem_size, dmem_depth;
 
     // drive clk and rst_n from clk_if
     clk_rst_if.set_active();
@@ -303,11 +302,16 @@
                     .depth (otbn_reg_pkg::OTBN_IMEM_SIZE / 4),
                     .n_bits (otbn_reg_pkg::OTBN_IMEM_SIZE / 4 * 39),
                     .err_detection_scheme (mem_bkdr_util_pkg::Ecc_39_32));
+
+    // DMEM is twice as big as the bus-accessible part
+    real_dmem_size = 2 * otbn_reg_pkg::OTBN_DMEM_SIZE;
+    dmem_depth = real_dmem_size / 32;
+
     dmem_util = new(.name ("dmem_util"),
                     .path ({"tb.dut.u_dmem.u_prim_ram_1p_adv.",
                             "u_mem.gen_generic.u_impl_generic.mem"}),
-                    .depth (otbn_reg_pkg::OTBN_DMEM_SIZE / 32),
-                    .n_bits (otbn_reg_pkg::OTBN_DMEM_SIZE / 32 * 312),
+                    .depth (dmem_depth),
+                    .n_bits (dmem_depth * 312),
                     .err_detection_scheme (mem_bkdr_util_pkg::Ecc_39_32));
 
     uvm_config_db#(mem_bkdr_util)::set(null, "*.env", imem_util.get_name(), imem_util);
diff --git a/hw/ip/otbn/dv/verilator/otbn_top_sim.sv b/hw/ip/otbn/dv/verilator/otbn_top_sim.sv
index aa11074..36be3e7 100644
--- a/hw/ip/otbn/dv/verilator/otbn_top_sim.sv
+++ b/hw/ip/otbn/dv/verilator/otbn_top_sim.sv
@@ -295,8 +295,6 @@
   bit        otbn_model_err;
 
   otbn_core_model #(
-    .DmemSizeByte    ( DmemSizeByte ),
-    .ImemSizeByte    ( ImemSizeByte ),
     .MemScope        ( ".." ),
     .DesignScope     ( DesignScope )
   ) u_otbn_core_model (
diff --git a/hw/ip/otbn/rtl/otbn.sv b/hw/ip/otbn/rtl/otbn.sv
index 71e99bc..5fb0dfe 100644
--- a/hw/ip/otbn/rtl/otbn.sv
+++ b/hw/ip/otbn/rtl/otbn.sv
@@ -836,8 +836,6 @@
     assign edn_urnd_data_valid = edn_urnd_req & edn_urnd_ack;
 
     otbn_core_model #(
-      .DmemSizeByte(DmemSizeByte),
-      .ImemSizeByte(ImemSizeByte),
       .MemScope(".."),
       .DesignScope("")
     ) u_otbn_core_model (