summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/SimpleMemory.py2
-rw-r--r--src/mem/simple_mem.cc29
-rw-r--r--src/mem/simple_mem.hh9
3 files changed, 13 insertions, 27 deletions
diff --git a/src/mem/SimpleMemory.py b/src/mem/SimpleMemory.py
index 51de3374d..c47d04222 100644
--- a/src/mem/SimpleMemory.py
+++ b/src/mem/SimpleMemory.py
@@ -44,6 +44,6 @@ from AbstractMemory import *
class SimpleMemory(AbstractMemory):
type = 'SimpleMemory'
- port = VectorSlavePort("Slave ports")
+ port = SlavePort("Slave ports")
latency = Param.Latency('30ns', "Request to response latency")
latency_var = Param.Latency('0ns', "Request to response latency variance")
diff --git a/src/mem/simple_mem.cc b/src/mem/simple_mem.cc
index aa9168bf7..b9db64276 100644
--- a/src/mem/simple_mem.cc
+++ b/src/mem/simple_mem.cc
@@ -49,24 +49,17 @@ using namespace std;
SimpleMemory::SimpleMemory(const Params* p) :
AbstractMemory(p),
- lat(p->latency), lat_var(p->latency_var)
+ port(name() + ".port", *this), lat(p->latency), lat_var(p->latency_var)
{
- for (size_t i = 0; i < p->port_port_connection_count; ++i) {
- ports.push_back(new MemoryPort(csprintf("%s-port-%d", name(), i),
- *this));
- }
}
void
SimpleMemory::init()
{
- for (vector<MemoryPort*>::iterator p = ports.begin(); p != ports.end();
- ++p) {
- if (!(*p)->isConnected()) {
- fatal("SimpleMemory port %s is unconnected!\n", (*p)->name());
- } else {
- (*p)->sendRangeChange();
- }
+ // allow unconnected memories as this is used in several ruby
+ // systems at the moment
+ if (port.isConnected()) {
+ port.sendRangeChange();
}
}
@@ -102,22 +95,14 @@ SimpleMemory::getSlavePort(const std::string &if_name, int idx)
if (if_name != "port") {
return MemObject::getSlavePort(if_name, idx);
} else {
- if (idx >= static_cast<int>(ports.size())) {
- fatal("SimpleMemory::getSlavePort: unknown index %d\n", idx);
- }
-
- return *ports[idx];
+ return port;
}
}
unsigned int
SimpleMemory::drain(Event *de)
{
- int count = 0;
- for (vector<MemoryPort*>::iterator p = ports.begin(); p != ports.end();
- ++p) {
- count += (*p)->drain(de);
- }
+ int count = port.drain(de);
if (count)
changeState(Draining);
diff --git a/src/mem/simple_mem.hh b/src/mem/simple_mem.hh
index 5f136ed51..95bfa57ad 100644
--- a/src/mem/simple_mem.hh
+++ b/src/mem/simple_mem.hh
@@ -54,9 +54,10 @@
#include "params/SimpleMemory.hh"
/**
- * The simple memory is a basic multi-ported memory with an infinite
- * throughput and a fixed latency, potentially with a variance added
- * to it. It uses a SimpleTimingPort to implement the timing accesses.
+ * The simple memory is a basic single-ported memory controller with
+ * an infinite throughput and a fixed latency, potentially with a
+ * variance added to it. It uses a SimpleTimingPort to implement the
+ * timing accesses.
*/
class SimpleMemory : public AbstractMemory
{
@@ -81,7 +82,7 @@ class SimpleMemory : public AbstractMemory
};
- std::vector<MemoryPort*> ports;
+ MemoryPort port;
Tick lat;
Tick lat_var;