#include "base/misc.hh"
#include "base/trace.hh"
#include "mem/bus.hh"
-#include "sim/builder.hh"
+#include "params/Bus.hh"
Port *
Bus::getPort(const std::string &if_name, int idx)
// If the bus is busy, or other devices are in line ahead of the current
// one, put this device on the retry list.
- if (!(pkt->isResponse() || pkt->isExpressSnoop()) &&
+ if (!pkt->isExpressSnoop() &&
(tickNextIdle > curTick ||
(retryList.size() && (!inRetry || src_port != retryList.front()))))
{
return false;
}
- occupyBus(pkt);
+ if (!pkt->isExpressSnoop()) {
+ occupyBus(pkt);
+ }
short dest = pkt->getDest();
int dest_port_id;
if (dest == Packet::Broadcast) {
dest_port_id = findPort(pkt->getAddr());
- dest_port = interfaces[dest_port_id];
+ dest_port = (dest_port_id == defaultId) ?
+ defaultPort : interfaces[dest_port_id];
for (SnoopIter s_iter = snoopPorts.begin();
s_iter != snoopPorts.end();
s_iter++) {
assert(dest >= 0 && dest < maxId);
assert(dest != src); // catch infinite loops
dest_port_id = dest;
- dest_port = interfaces[dest_port_id];
+ dest_port = (dest_port_id == defaultId) ?
+ defaultPort : interfaces[dest_port_id];
}
if (dest_port_id == src) {
int orig_src = pkt->getSrc();
int target_port_id = findPort(pkt->getAddr());
- Port *target_port = interfaces[target_port_id];
+ Port *target_port = (target_port_id == defaultId) ?
+ defaultPort : interfaces[target_port_id];
SnoopIter s_end = snoopPorts.end();
for (SnoopIter s_iter = snoopPorts.begin(); s_iter != s_end; s_iter++) {
assert(pkt->getDest() == Packet::Broadcast);
int port_id = findPort(pkt->getAddr());
- Port *port = interfaces[port_id];
+ Port *port = (port_id == defaultId) ? defaultPort : interfaces[port_id];
// The packet may be changed by another bus on snoops, restore the
// id after each
int src_id = pkt->getSrc();
tickNextIdle = (curTick / clock) * clock + clock;
}
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(Bus)
-
- Param<int> bus_id;
- Param<int> clock;
- Param<int> width;
- Param<bool> responder_set;
- Param<int> block_size;
-
-END_DECLARE_SIM_OBJECT_PARAMS(Bus)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(Bus)
- INIT_PARAM(bus_id, "a globally unique bus id"),
- INIT_PARAM(clock, "bus clock speed"),
- INIT_PARAM(width, "width of the bus (bits)"),
- INIT_PARAM(responder_set, "Is a default responder set by the user"),
- INIT_PARAM(block_size, "Default blocksize if no device has one")
-END_INIT_SIM_OBJECT_PARAMS(Bus)
-
-CREATE_SIM_OBJECT(Bus)
+Bus *
+BusParams::create()
{
- return new Bus(getInstanceName(), bus_id, clock, width, responder_set,
- block_size);
+ return new Bus(name, bus_id, clock, width, responder_set, block_size);
}
-
-REGISTER_SIM_OBJECT("Bus", Bus)