changeset 354202312a21 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=354202312a21
description:
MEM: Use base class Master/SlavePort pointers in the bus
This patch makes some rather trivial simplifications to the bus in
that it changes the use of BusMasterPort and BusSlavePort pointers to
simply use MasterPort and SlavePort (iterators are also updated
accordingly).
This change is a step towards a future patch that introduces a
separation of the interface and the structural port itself.
diffstat:
src/mem/bus.cc | 46 +++++++++++++++++++++-------------------------
src/mem/bus.hh | 10 ++++++----
2 files changed, 27 insertions(+), 29 deletions(-)
diffs (147 lines):
diff -r 1ebd7c856abc -r 354202312a21 src/mem/bus.cc
--- a/src/mem/bus.cc Wed Apr 25 10:41:23 2012 -0400
+++ b/src/mem/bus.cc Wed Apr 25 10:45:23 2012 -0400
@@ -75,7 +75,7 @@
// are enumerated starting from zero
for (int i = 0; i < p->port_master_connection_count; ++i) {
std::string portName = csprintf("%s-p%d", name(), i);
- BusMasterPort* bp = new BusMasterPort(portName, this, i);
+ MasterPort* bp = new BusMasterPort(portName, this, i);
masterPorts.push_back(bp);
}
@@ -84,14 +84,14 @@
if (p->port_default_connection_count) {
defaultPortId = masterPorts.size();
std::string portName = csprintf("%s-default", name());
- BusMasterPort* bp = new BusMasterPort(portName, this, defaultPortId);
+ MasterPort* bp = new BusMasterPort(portName, this, defaultPortId);
masterPorts.push_back(bp);
}
// create the slave ports, once again starting at zero
for (int i = 0; i < p->port_slave_connection_count; ++i) {
std::string portName = csprintf("%s-p%d", name(), i);
- BusSlavePort* bp = new BusSlavePort(portName, this, i);
+ SlavePort* bp = new BusSlavePort(portName, this, i);
slavePorts.push_back(bp);
}
@@ -125,11 +125,10 @@
void
Bus::init()
{
- std::vector<BusSlavePort*>::iterator p;
-
// iterate over our slave ports and determine which of our
// neighbouring master ports are snooping and add them as snoopers
- for (p = slavePorts.begin(); p != slavePorts.end(); ++p) {
+ for (SlavePortConstIter p = slavePorts.begin(); p != slavePorts.end();
+ ++p) {
if ((*p)->getMasterPort().isSnooping()) {
DPRINTF(BusAddrRanges, "Adding snooping neighbour %s\n",
(*p)->getMasterPort().name());
@@ -397,9 +396,8 @@
void
Bus::forwardTiming(PacketPtr pkt, int exclude_slave_port_id)
{
- SnoopIter s_end = snoopPorts.end();
- for (SnoopIter s_iter = snoopPorts.begin(); s_iter != s_end; s_iter++) {
- BusSlavePort *p = *s_iter;
+ for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) {
+ SlavePort *p = *s;
// we could have gotten this request from a snooping master
// (corresponding to our own slave port that is also in
// snoopPorts) and should not send it back to where it came
@@ -594,9 +592,8 @@
MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
Tick snoop_response_latency = 0;
- SnoopIter s_end = snoopPorts.end();
- for (SnoopIter s_iter = snoopPorts.begin(); s_iter != s_end; s_iter++) {
- BusSlavePort *p = *s_iter;
+ for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) {
+ SlavePort *p = *s;
// we could have gotten this request from a snooping master
// (corresponding to our own slave port that is also in
// snoopPorts) and should not send it back to where it came
@@ -676,9 +673,8 @@
void
Bus::forwardFunctional(PacketPtr pkt, int exclude_slave_port_id)
{
- SnoopIter s_end = snoopPorts.end();
- for (SnoopIter s_iter = snoopPorts.begin(); s_iter != s_end; s_iter++) {
- BusSlavePort *p = *s_iter;
+ for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) {
+ SlavePort *p = *s;
// we could have gotten this request from a snooping master
// (corresponding to our own slave port that is also in
// snoopPorts) and should not send it back to where it came
@@ -723,7 +719,7 @@
} else {
assert(id < masterPorts.size() && id >= 0);
- BusMasterPort *port = masterPorts[id];
+ MasterPort *port = masterPorts[id];
// Clean out any previously existent ids
for (PortIter portIter = portMap.begin();
@@ -749,12 +745,11 @@
}
DPRINTF(BusAddrRanges, "port list has %d entries\n", portMap.size());
- // tell all our peers that our address range has changed.
- // Don't tell the device that caused this change, it already knows
- std::vector<BusSlavePort*>::const_iterator intIter;
-
- for (intIter = slavePorts.begin(); intIter != slavePorts.end(); intIter++)
- (*intIter)->sendRangeChange();
+ // tell all our neighbouring master ports that our address range
+ // has changed
+ for (SlavePortConstIter p = slavePorts.begin(); p != slavePorts.end();
+ ++p)
+ (*p)->sendRangeChange();
inRecvRangeChange.erase(id);
}
@@ -821,9 +816,10 @@
if (tmp_bs > max_bs)
max_bs = tmp_bs;
}
- SnoopIter s_end = snoopPorts.end();
- for (SnoopIter s_iter = snoopPorts.begin(); s_iter != s_end; s_iter++) {
- unsigned tmp_bs = (*s_iter)->peerBlockSize();
+
+ for (SlavePortConstIter s = snoopPorts.begin(); s != snoopPorts.end();
+ ++s) {
+ unsigned tmp_bs = (*s)->peerBlockSize();
if (tmp_bs > max_bs)
max_bs = tmp_bs;
}
diff -r 1ebd7c856abc -r 354202312a21 src/mem/bus.hh
--- a/src/mem/bus.hh Wed Apr 25 10:41:23 2012 -0400
+++ b/src/mem/bus.hh Wed Apr 25 10:45:23 2012 -0400
@@ -218,8 +218,7 @@
AddrRangeList defaultRange;
- typedef std::vector<BusSlavePort*>::iterator SnoopIter;
- std::vector<BusSlavePort*> snoopPorts;
+ std::vector<SlavePort*> snoopPorts;
/**
* Store the outstanding requests so we can determine which ones
@@ -428,8 +427,11 @@
std::set<Port::PortId> inRecvRangeChange;
/** The master and slave ports of the bus */
- std::vector<BusSlavePort*> slavePorts;
- std::vector<BusMasterPort*> masterPorts;
+ std::vector<SlavePort*> slavePorts;
+ std::vector<MasterPort*> masterPorts;
+
+ typedef std::vector<SlavePort*>::iterator SlavePortIter;
+ typedef std::vector<SlavePort*>::const_iterator SlavePortConstIter;
/** An array of pointers to ports that retry should be called on because
the
* original send failed for whatever reason.*/
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev