[dv, cosim] Refactor co-sim DPI to use an unified 'mpact_get_register' API Bug: 443772447 Change-Id: I6813f5beb7a2dba968c717a0d7d5567c7a10fd76
diff --git a/tests/uvm/common/cosim/kelvin_cosim_checker_pkg.sv b/tests/uvm/common/cosim/kelvin_cosim_checker_pkg.sv index 517d342..12e0041 100644 --- a/tests/uvm/common/cosim/kelvin_cosim_checker_pkg.sv +++ b/tests/uvm/common/cosim/kelvin_cosim_checker_pkg.sv
@@ -121,7 +121,9 @@ bit pc_match_found = 0; int match_index = -1; - mpact_pc = mpact_get_pc(); + if (mpact_get_register("pc", mpact_pc) != 0) begin + `uvm_error("COSIM_API_FAIL", "Failed to get PC from MPACT simulator.") + end foreach (retired_instr_q[j]) begin if (retired_instr_q[j].pc == mpact_pc) begin @@ -171,6 +173,7 @@ int unsigned mpact_gpr_val; int unsigned rd_index; logic [31:0] rtl_wdata; + string reg_name; `uvm_info(get_type_name(), "Comparing GPR writeback state...", UVM_HIGH) @@ -188,7 +191,10 @@ end else if (rtl_info.x_wb != 0) begin rd_index = $clog2(rtl_info.x_wb); - mpact_gpr_val = mpact_get_gpr(rd_index); + reg_name = $sformatf("x%0d", rd_index); + if (mpact_get_register(reg_name, mpact_gpr_val) != 0) begin + `uvm_error("COSIM_API_FAIL", $sformatf("Failed to get GPR '%s'", reg_name)) + end // Get the specific write data from the correct retire channel and register index rtl_wdata = rvvi_vif.x_wdata[0][rtl_info.retire_index][rd_index];
diff --git a/tests/uvm/common/cosim/kelvin_cosim_dpi_if.sv b/tests/uvm/common/cosim/kelvin_cosim_dpi_if.sv index 5e6d216..66f7ffc 100644 --- a/tests/uvm/common/cosim/kelvin_cosim_dpi_if.sv +++ b/tests/uvm/common/cosim/kelvin_cosim_dpi_if.sv
@@ -41,17 +41,11 @@ // Returns '1' (true) if halted. import "DPI-C" context function bit mpact_is_halted(); - // Function to get the program counter. - import "DPI-C" context function int unsigned mpact_get_pc(); - - // Function to get a general-purpose register value. - import "DPI-C" context function int unsigned mpact_get_gpr( - input int unsigned index - ); - - // Function to get a control and status register value. - import "DPI-C" context function int unsigned mpact_get_csr( - input int unsigned address + // Function to get a register value (GPR, PC, CSR) by its string name. + // The C pointer 'uint32_t* value' maps to an 'output' argument in SV. + import "DPI-C" context function int mpact_get_register( + input string name, + output int unsigned value ); // Function to finalize the MPACT simulator.