Jason Lowe-Power has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/58469 )

Change subject: mem-ruby: Add check for single protocol
......................................................................

mem-ruby: Add check for single protocol

Now that multiple protocols are built into a single binary, it's
possible that the user instantiates machines from different protocols.
Right now, Ruby doesn't allow this. This changes informs the user if
this happens with a hopefully helpful error statement.

This was tested by using machine from different protocols and the error
condition was hit.

Change-Id: I1ca4b60c360bf6fa5531291003079b39e407da26
Signed-off-by: Jason Lowe-Power <ja...@lowepower.com>
---
M src/mem/ruby/system/RubySystem.cc
M src/mem/ruby/system/RubySystem.hh
M src/mem/slicc/symbols/StateMachine.py
3 files changed, 35 insertions(+), 3 deletions(-)



diff --git a/src/mem/ruby/system/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc
index 91c4bc3..9d25ce8 100644
--- a/src/mem/ruby/system/RubySystem.cc
+++ b/src/mem/ruby/system/RubySystem.cc
@@ -104,8 +104,19 @@
 }

 void
-RubySystem::registerAbstractController(AbstractController* cntrl)
+RubySystem::registerAbstractController(AbstractController* cntrl,
+                                       std::string protocol_str)
 {
+    // Check and enforce that controllers can only come from one protocol
+    if (m_protocol_str.empty()) {
+        m_protocol_str = protocol_str;
+    } else {
+        fatal_if(protocol_str != m_protocol_str,
+ "Ruby only supports using machines from a single protocol. " + "The current machine %s is part of the protocol %s. Other "
+                 "controllers instantiated were part of protocol %s.",
+                 cntrl->name(), protocol_str, m_protocol_str);
+    }
     m_abs_cntrl_vec.push_back(cntrl);

     MachineID id = cntrl->getMachineID();
diff --git a/src/mem/ruby/system/RubySystem.hh b/src/mem/ruby/system/RubySystem.hh
index e16d699..b1e7b4b 100644
--- a/src/mem/ruby/system/RubySystem.hh
+++ b/src/mem/ruby/system/RubySystem.hh
@@ -35,6 +35,7 @@
 #ifndef __MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
 #define __MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__

+#include <string>
 #include <unordered_map>

 #include "base/callback.hh"
@@ -104,7 +105,7 @@
     bool functionalWrite(Packet *ptr);

     void registerNetwork(Network*);
-    void registerAbstractController(AbstractController*);
+    void registerAbstractController(AbstractController*, std::string);
     void registerMachineID(const MachineID& mach_id, Network* network);
     void registerRequestorIDs();

@@ -145,6 +146,8 @@
     memory::SimpleMemory *m_phys_mem;
     const bool m_access_backing_store;

+    std::string m_protocol_str;
+
     //std::vector<Network *> m_networks;
     std::vector<std::unique_ptr<Network>> m_networks;
     std::vector<AbstractController *> m_abs_cntrl_vec;
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 2faf19a..90f789f 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -619,7 +619,7 @@
     m_machineID.type = MachineType_${ident};
     m_machineID.num = m_version;
     m_num_controllers++;
-    p.ruby_system->registerAbstractController(this);
+    p.ruby_system->registerAbstractController(this, "${protocol}");

     m_in_ports = $num_in_ports;
 ''')

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/58469
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I1ca4b60c360bf6fa5531291003079b39e407da26
Gerrit-Change-Number: 58469
Gerrit-PatchSet: 1
Gerrit-Owner: Jason Lowe-Power <power...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to