summaryrefslogtreecommitdiff
path: root/src/mem/ruby/network/simple/Switch.cc
diff options
context:
space:
mode:
authorJoel Hestness <jthestness@gmail.com>2015-08-14 00:19:44 -0500
committerJoel Hestness <jthestness@gmail.com>2015-08-14 00:19:44 -0500
commit581bae9ecbafd5e94c5405ca925a55cc6e5d7488 (patch)
treec4e9136882984e561b7c1c618361e4262b482869 /src/mem/ruby/network/simple/Switch.cc
parentbf06911b3f6d992dc78489d66410f4580a17db7b (diff)
downloadgem5-581bae9ecbafd5e94c5405ca925a55cc6e5d7488.tar.xz
ruby: Expose MessageBuffers as SimObjects
Expose MessageBuffers from SLICC controllers as SimObjects that can be manipulated in Python. This patch has numerous benefits: 1) First and foremost, it exposes MessageBuffers as SimObjects that can be manipulated in Python code. This allows parameters to be set and checked in Python code to avoid obfuscating parameters within protocol files. Further, now as SimObjects, MessageBuffer parameters are printed to config output files as a way to track parameters across simulations (e.g. buffer sizes) 2) Cleans up special-case code for responseFromMemory buffers, and aligns their instantiation and use with mandatoryQueue buffers. These two special buffers are the only MessageBuffers that are exposed to components outside of SLICC controllers, and they're both slave ends of these buffers. They should be exposed outside of SLICC in the same way, and this patch does it. 3) Distinguishes buffer-specific parameters from buffer-to-network parameters. Specifically, buffer size, randomization, ordering, recycle latency, and ports are all specific to a MessageBuffer, while the virtual network ID and type are intrinsics of how the buffer is connected to network ports. The former are specified in the Python object, while the latter are specified in the controller *.sm files. Unlike buffer-specific parameters, which may need to change depending on the simulated system structure, buffer-to-network parameters can be specified statically for most or all different simulated systems.
Diffstat (limited to 'src/mem/ruby/network/simple/Switch.cc')
-rw-r--r--src/mem/ruby/network/simple/Switch.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/mem/ruby/network/simple/Switch.cc b/src/mem/ruby/network/simple/Switch.cc
index 431a7b28f..b9d0b8010 100644
--- a/src/mem/ruby/network/simple/Switch.cc
+++ b/src/mem/ruby/network/simple/Switch.cc
@@ -43,6 +43,8 @@ using m5::stl_helpers::operator<<;
Switch::Switch(const Params *p) : BasicRouter(p)
{
m_perfect_switch = new PerfectSwitch(m_id, this, p->virt_nets);
+ m_port_buffers = p->port_buffers;
+ m_num_connected_buffers = 0;
}
Switch::~Switch()
@@ -53,7 +55,7 @@ Switch::~Switch()
deletePointers(m_throttles);
// Delete MessageBuffers
- deletePointers(m_buffers_to_free);
+ deletePointers(m_port_buffers);
}
void
@@ -97,15 +99,10 @@ Switch::addOutPort(const vector<MessageBuffer*>& out,
out[i]->setSender(this);
}
- MessageBuffer* buffer_ptr = new MessageBuffer;
- // Make these queues ordered
- buffer_ptr->setOrdering(true);
- if (m_network_ptr->getBufferSize() > 0) {
- buffer_ptr->resize(m_network_ptr->getBufferSize());
- }
-
+ assert(m_num_connected_buffers < m_port_buffers.size());
+ MessageBuffer* buffer_ptr = m_port_buffers[m_num_connected_buffers];
+ m_num_connected_buffers++;
intermediateBuffers.push_back(buffer_ptr);
- m_buffers_to_free.push_back(buffer_ptr);
buffer_ptr->setSender(this);
buffer_ptr->setReceiver(this);
@@ -188,8 +185,8 @@ bool
Switch::functionalRead(Packet *pkt)
{
// Access the buffers in the switch for performing a functional read
- for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
- if (m_buffers_to_free[i]->functionalRead(pkt)) {
+ for (unsigned int i = 0; i < m_port_buffers.size(); ++i) {
+ if (m_port_buffers[i]->functionalRead(pkt)) {
return true;
}
}
@@ -201,8 +198,8 @@ Switch::functionalWrite(Packet *pkt)
{
// Access the buffers in the switch for performing a functional write
uint32_t num_functional_writes = 0;
- for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
- num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt);
+ for (unsigned int i = 0; i < m_port_buffers.size(); ++i) {
+ num_functional_writes += m_port_buffers[i]->functionalWrite(pkt);
}
return num_functional_writes;
}