This updates the interface between ReNode and Mpact simulators.

This adds a cpu_type string to the connect and construct calls from ReNode.
This allows the cpu type that is configured in ReNode to be passed to Mpact,
allowing the Mpact simulator interface to customize the simulator instance
according to the configured CPU type.

PiperOrigin-RevId: 661288754
Change-Id: I25d9653562d8e1a53247080c626d96729d70203a
diff --git a/riscv/riscv32_renode.cc b/riscv/riscv32_renode.cc
index a04b951..421dd3a 100644
--- a/riscv/riscv32_renode.cc
+++ b/riscv/riscv32_renode.cc
@@ -8,7 +8,8 @@
 #include "riscv/riscv_state.h"
 
 ::mpact::sim::util::renode::RenodeDebugInterface *CreateMpactSim(
-    std::string name, ::mpact::sim::util::MemoryInterface *renode_sysbus) {
+    std::string name, std::string cpu_type,
+    ::mpact::sim::util::MemoryInterface *renode_sysbus) {
   auto *top = new ::mpact::sim::riscv::RiscVRenode(
       name, renode_sysbus, ::mpact::sim::riscv::RiscVXlen ::RV32);
   return top;
diff --git a/riscv/riscv32_renode.h b/riscv/riscv32_renode.h
index c1b5c0c..b068ae7 100644
--- a/riscv/riscv32_renode.h
+++ b/riscv/riscv32_renode.h
@@ -10,6 +10,7 @@
 // use with ReNode.
 
 extern ::mpact::sim::util::renode::RenodeDebugInterface *CreateMpactSim(
-    std::string name, ::mpact::sim::util::MemoryInterface *renode_sysbus);
+    std::string name, std::string cpu_type,
+    ::mpact::sim::util::MemoryInterface *renode_sysbus);
 
 #endif  // THIRD_PARTY_MPACT_RISCV_RISCV32_RENODE_H_
diff --git a/riscv/riscv64_renode.cc b/riscv/riscv64_renode.cc
index 70d8e3b..fbec443 100644
--- a/riscv/riscv64_renode.cc
+++ b/riscv/riscv64_renode.cc
@@ -8,8 +8,9 @@
 #include "riscv/riscv_state.h"
 
 ::mpact::sim::util::renode::RenodeDebugInterface *CreateMpactSim(
-    std::string name, ::mpact::sim::util::MemoryInterface *renode_sysbus) {
+    std::string name, std::string cpu_type,
+    ::mpact::sim::util::MemoryInterface *renode_sysbus) {
   auto *top = new ::mpact::sim::riscv::RiscVRenode(
-      name, renode_sysbus, ::mpact::sim::riscv::RiscVXlen ::RV64);
+      name, renode_sysbus, ::mpact::sim::riscv::RiscVXlen::RV64);
   return top;
 }
diff --git a/riscv/riscv64_renode.h b/riscv/riscv64_renode.h
index 1fece6e..b367b98 100644
--- a/riscv/riscv64_renode.h
+++ b/riscv/riscv64_renode.h
@@ -10,6 +10,7 @@
 // use with ReNode.
 
 extern ::mpact::sim::util::renode::RenodeDebugInterface *CreateMpactSim(
-    std::string name, ::mpact::sim::util::MemoryInterface *renode_sysbus);
+    std::string name, std::string cpu_type,
+    ::mpact::sim::util::MemoryInterface *renode_sysbus);
 
 #endif  // THIRD_PARTY_MPACT_RISCV_RISCV64_RENODE_H_
diff --git a/riscv/test/librenode_mpact_riscv32_so_test.cc b/riscv/test/librenode_mpact_riscv32_so_test.cc
index 16669f7..138bba5 100644
--- a/riscv/test/librenode_mpact_riscv32_so_test.cc
+++ b/riscv/test/librenode_mpact_riscv32_so_test.cc
@@ -95,7 +95,7 @@
   EXPECT_NE(dlsym(lib_, "set_irq_value"), nullptr);
 }
 
-using ConstructType = int32_t (*)(int32_t);
+using ConstructType = int32_t (*)(char *, int32_t);
 using StepType = uint64_t (*)(int32_t, uint64_t, int32_t *);
 using SetConfigType = int32_t (*)(int32_t, const char *[], const char *[],
                                   int32_t);
@@ -127,7 +127,8 @@
   CHECK_NE(get_reg_info_size, nullptr);
   CHECK_NE(get_reg_info, nullptr);
   // Construct a simulator instance.
-  int32_t id = construct(256);
+  char cpu_type[] = "Mpact.RiscV32";
+  int32_t id = construct(cpu_type, 256);
   CHECK_GE(id, 0);
   // Load the program.
   int32_t status = 0;
diff --git a/riscv/test/librenode_mpact_riscv64_so_test.cc b/riscv/test/librenode_mpact_riscv64_so_test.cc
index 5072245..e7724ff 100644
--- a/riscv/test/librenode_mpact_riscv64_so_test.cc
+++ b/riscv/test/librenode_mpact_riscv64_so_test.cc
@@ -95,7 +95,7 @@
   EXPECT_NE(dlsym(lib_, "set_irq_value"), nullptr);
 }
 
-using ConstructType = int32_t (*)(int32_t);
+using ConstructType = int32_t (*)(char *, int32_t);
 using StepType = uint64_t (*)(int32_t, uint64_t, int32_t *);
 using SetConfigType = int32_t (*)(int32_t, const char *[], const char *[],
                                   int32_t);
@@ -127,7 +127,8 @@
   CHECK_NE(get_reg_info_size, nullptr);
   CHECK_NE(get_reg_info, nullptr);
   // Construct a simulator instance.
-  int32_t id = construct(256);
+  char cpu_type[] = "Mpact.RiscV64";
+  int32_t id = construct(cpu_type, 256);
   CHECK_GE(id, 0);
   // Load the program.
   int32_t status = 0;