[otbn] Pass "design scope" instead of a "standalone" flag to model This patch doesn't add any new behaviour, but the point is that future patches can bind checkers in to the design, starting at this scope. 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 2a46854..660aa5d 100644 --- a/hw/ip/otbn/dv/model/otbn_core_model.sv +++ b/hw/ip/otbn/dv/model/otbn_core_model.sv
@@ -21,11 +21,10 @@ parameter string ImemScope = "", // Scope of the data memory (for DPI) parameter string DmemScope = "", - - // True if this is a "standalone" model, which should write DMEM on completion. If false, we - // assume there's a real implementation running alongside and we check that the DMEM contents - // match on completion. - parameter bit StandaloneModel = 1'b0, + // Scope of an RTL OTBN implementation (for DPI). If empty, this is a "standalone" model, which + // should update DMEM on completion. If not empty, we assume it's the scope for the top-level of a + // real implementation running alongside and we check DMEM contents on completion. + parameter string DesignScope = "", localparam int ImemAddrWidth = prim_util_pkg::vbits(ImemSizeByte), localparam int DmemAddrWidth = prim_util_pkg::vbits(DmemSizeByte) @@ -107,11 +106,11 @@ unique case (retcode) 0: new_run = 1'b1; 1: begin - // The model has just finished running. If this is a standalone model, write the ISS's DMEM - // contents back to the simulation. Otherwise, check the ISS and simulation agree (TODO: We - // don't do error handling properly at the moment; for now, the C++ code just prints error - // messages to stderr). - if (StandaloneModel) begin + // The model has just finished running. If this is a standalone model (which we can tell + // because DesignScope is empty), write the ISS's DMEM contents back to the simulation. + // Otherwise, check the ISS and simulation agree (TODO: We don't do error handling properly + // at the moment; for now, the C++ code just prints error messages to stderr). + if (DesignScope.len() == 0) begin void'(otbn_model_load_dmem(model_handle, DmemScope, DmemSizeWords)); end else begin void'(otbn_model_check_dmem(model_handle, DmemScope, DmemSizeWords));
diff --git a/hw/ip/otbn/dv/verilator/otbn_top_sim.sv b/hw/ip/otbn/dv/verilator/otbn_top_sim.sv index 1880ebc..6bab4cc 100644 --- a/hw/ip/otbn/dv/verilator/otbn_top_sim.sv +++ b/hw/ip/otbn/dv/verilator/otbn_top_sim.sv
@@ -181,6 +181,7 @@ localparam string ImemScope = "..u_imem.u_mem.gen_generic.u_impl_generic"; localparam string DmemScope = "..u_dmem.u_mem.gen_generic.u_impl_generic"; + localparam string DesignScope = "..u_otbn_core"; logic otbn_model_done; @@ -189,7 +190,7 @@ .ImemSizeByte ( ImemSizeByte ), .DmemScope ( DmemScope ), .ImemScope ( ImemScope ), - .StandaloneModel ( 1'b0 ) + .DesignScope ( DesignScope ) ) u_otbn_core_model ( .clk_i ( IO_CLK ), .rst_ni ( IO_RST_N ),
diff --git a/hw/ip/otbn/rtl/otbn.sv b/hw/ip/otbn/rtl/otbn.sv index 0a9e677..fc49a67 100644 --- a/hw/ip/otbn/rtl/otbn.sv +++ b/hw/ip/otbn/rtl/otbn.sv
@@ -433,7 +433,7 @@ .ImemSizeByte(ImemSizeByte), .DmemScope(DmemScope), .ImemScope(ImemScope), - .StandaloneModel(1'b1) + .DesignScope("") ) u_otbn_core_model ( .clk_i, .rst_ni,