summaryrefslogtreecommitdiff
path: root/src/mem/ruby/slicc_interface/AbstractController.cc
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2013-03-22 15:53:24 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2013-03-22 15:53:24 -0500
commit8573a69d8f7bf7b3f074e3e0ac64994801c551be (patch)
tree825b13a2bda66152fda68c5f463f627a4ba2c174 /src/mem/ruby/slicc_interface/AbstractController.cc
parenteccc86e8095995d49326a9fffc3a1088b97b03fc (diff)
downloadgem5-8573a69d8f7bf7b3f074e3e0ac64994801c551be.tar.xz
ruby: move stall and wakeup functions to AbstractController
These functions are currently implemented in one of the files related to Slicc. Since these are purely C++ functions, they are better suited to be in the base class.
Diffstat (limited to 'src/mem/ruby/slicc_interface/AbstractController.cc')
-rw-r--r--src/mem/ruby/slicc_interface/AbstractController.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc b/src/mem/ruby/slicc_interface/AbstractController.cc
index 1615f8c1d..13107038c 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -86,3 +86,87 @@ AbstractController::connectWithPeer(AbstractController *c)
getQueuesFromPeer(c);
c->getQueuesFromPeer(this);
}
+
+void
+AbstractController::stallBuffer(MessageBuffer* buf, Address addr)
+{
+ if (m_waiting_buffers.count(addr) == 0) {
+ MsgVecType* msgVec = new MsgVecType;
+ msgVec->resize(m_max_in_port_rank, NULL);
+ m_waiting_buffers[addr] = msgVec;
+ }
+ (*(m_waiting_buffers[addr]))[m_cur_in_port_rank] = buf;
+}
+
+void
+AbstractController::wakeUpBuffers(Address addr)
+{
+ if (m_waiting_buffers.count(addr) > 0) {
+ //
+ // Wake up all possible lower rank (i.e. lower priority) buffers that could
+ // be waiting on this message.
+ //
+ for (int in_port_rank = m_cur_in_port_rank - 1;
+ in_port_rank >= 0;
+ in_port_rank--) {
+ if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
+ (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
+ }
+ }
+ delete m_waiting_buffers[addr];
+ m_waiting_buffers.erase(addr);
+ }
+}
+
+void
+AbstractController::wakeUpAllBuffers(Address addr)
+{
+ if (m_waiting_buffers.count(addr) > 0) {
+ //
+ // Wake up all possible lower rank (i.e. lower priority) buffers that could
+ // be waiting on this message.
+ //
+ for (int in_port_rank = m_max_in_port_rank - 1;
+ in_port_rank >= 0;
+ in_port_rank--) {
+ if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
+ (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
+ }
+ }
+ delete m_waiting_buffers[addr];
+ m_waiting_buffers.erase(addr);
+ }
+}
+
+void
+AbstractController::wakeUpAllBuffers()
+{
+ //
+ // Wake up all possible buffers that could be waiting on any message.
+ //
+
+ std::vector<MsgVecType*> wokeUpMsgVecs;
+
+ if(m_waiting_buffers.size() > 0) {
+ for (WaitingBufType::iterator buf_iter = m_waiting_buffers.begin();
+ buf_iter != m_waiting_buffers.end();
+ ++buf_iter) {
+ for (MsgVecType::iterator vec_iter = buf_iter->second->begin();
+ vec_iter != buf_iter->second->end();
+ ++vec_iter) {
+ if (*vec_iter != NULL) {
+ (*vec_iter)->reanalyzeAllMessages();
+ }
+ }
+ wokeUpMsgVecs.push_back(buf_iter->second);
+ }
+
+ for (std::vector<MsgVecType*>::iterator wb_iter = wokeUpMsgVecs.begin();
+ wb_iter != wokeUpMsgVecs.end();
+ ++wb_iter) {
+ delete (*wb_iter);
+ }
+
+ m_waiting_buffers.clear();
+ }
+}