coherent_xbar.cc revision 9715
1/* 2 * Copyright (c) 2011-2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2006 The Regents of The University of Michigan 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution; 24 * neither the name of the copyright holders nor the names of its 25 * contributors may be used to endorse or promote products derived from 26 * this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Ali Saidi 41 * Andreas Hansson 42 * William Wang 43 */ 44 45/** 46 * @file 47 * Definition of a bus object. 48 */ 49 50#include "base/misc.hh" 51#include "base/trace.hh" 52#include "debug/BusAddrRanges.hh" 53#include "debug/CoherentBus.hh" 54#include "mem/coherent_bus.hh" 55#include "sim/system.hh" 56 57CoherentBus::CoherentBus(const CoherentBusParams *p) 58 : BaseBus(p), system(p->system) 59{ 60 // create the ports based on the size of the master and slave 61 // vector ports, and the presence of the default port, the ports 62 // are enumerated starting from zero 63 for (int i = 0; i < p->port_master_connection_count; ++i) { 64 std::string portName = csprintf("%s.master[%d]", name(), i); 65 MasterPort* bp = new CoherentBusMasterPort(portName, *this, i); 66 masterPorts.push_back(bp); 67 reqLayers.push_back(new ReqLayer(*bp, *this, 68 csprintf(".reqLayer%d", i))); 69 snoopLayers.push_back(new SnoopLayer(*bp, *this, 70 csprintf(".snoopLayer%d", i))); 71 } 72 73 // see if we have a default slave device connected and if so add 74 // our corresponding master port 75 if (p->port_default_connection_count) { 76 defaultPortID = masterPorts.size(); 77 std::string portName = name() + ".default"; 78 MasterPort* bp = new CoherentBusMasterPort(portName, *this, 79 defaultPortID); 80 masterPorts.push_back(bp); 81 reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d", 82 defaultPortID))); 83 snoopLayers.push_back(new SnoopLayer(*bp, *this, 84 csprintf(".snoopLayer%d", 85 defaultPortID))); 86 } 87 88 // create the slave ports, once again starting at zero 89 for (int i = 0; i < p->port_slave_connection_count; ++i) { 90 std::string portName = csprintf("%s.slave[%d]", name(), i); 91 SlavePort* bp = new CoherentBusSlavePort(portName, *this, i); 92 slavePorts.push_back(bp); 93 respLayers.push_back(new RespLayer(*bp, *this, 94 csprintf(".respLayer%d", i))); 95 } 96 97 clearPortCache(); 98} 99 100CoherentBus::~CoherentBus() 101{ 102 for (auto l = reqLayers.begin(); l != reqLayers.end(); ++l) 103 delete *l; 104 for (auto l = respLayers.begin(); l != respLayers.end(); ++l) 105 delete *l; 106 for (auto l = snoopLayers.begin(); l != snoopLayers.end(); ++l) 107 delete *l; 108} 109 110void 111CoherentBus::init() 112{ 113 // the base class is responsible for determining the block size 114 BaseBus::init(); 115 116 // iterate over our slave ports and determine which of our 117 // neighbouring master ports are snooping and add them as snoopers 118 for (SlavePortConstIter p = slavePorts.begin(); p != slavePorts.end(); 119 ++p) { 120 // check if the connected master port is snooping 121 if ((*p)->isSnooping()) { 122 DPRINTF(BusAddrRanges, "Adding snooping master %s\n", 123 (*p)->getMasterPort().name()); 124 snoopPorts.push_back(*p); 125 } 126 } 127 128 if (snoopPorts.empty()) 129 warn("CoherentBus %s has no snooping ports attached!\n", name()); 130} 131 132bool 133CoherentBus::recvTimingReq(PacketPtr pkt, PortID slave_port_id) 134{ 135 // determine the source port based on the id 136 SlavePort *src_port = slavePorts[slave_port_id]; 137 138 // remember if the packet is an express snoop 139 bool is_express_snoop = pkt->isExpressSnoop(); 140 141 // determine the destination based on the address 142 PortID master_port_id = findPort(pkt->getAddr()); 143 144 // test if the bus should be considered occupied for the current 145 // port, and exclude express snoops from the check 146 if (!is_express_snoop && !reqLayers[master_port_id]->tryTiming(src_port)) { 147 DPRINTF(CoherentBus, "recvTimingReq: src %s %s 0x%x BUS BUSY\n", 148 src_port->name(), pkt->cmdString(), pkt->getAddr()); 149 return false; 150 } 151 152 DPRINTF(CoherentBus, "recvTimingReq: src %s %s expr %d 0x%x\n", 153 src_port->name(), pkt->cmdString(), is_express_snoop, 154 pkt->getAddr()); 155 156 // store size and command as they might be modified when 157 // forwarding the packet 158 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 159 unsigned int pkt_cmd = pkt->cmdToIndex(); 160 161 // set the source port for routing of the response 162 pkt->setSrc(slave_port_id); 163 164 calcPacketTiming(pkt); 165 Tick packetFinishTime = pkt->busLastWordDelay + curTick(); 166 167 // uncacheable requests need never be snooped 168 if (!pkt->req->isUncacheable() && !system->bypassCaches()) { 169 // the packet is a memory-mapped request and should be 170 // broadcasted to our snoopers but the source 171 forwardTiming(pkt, slave_port_id); 172 } 173 174 // remember if we add an outstanding req so we can undo it if 175 // necessary, if the packet needs a response, we should add it 176 // as outstanding and express snoops never fail so there is 177 // not need to worry about them 178 bool add_outstanding = !is_express_snoop && pkt->needsResponse(); 179 180 // keep track that we have an outstanding request packet 181 // matching this request, this is used by the coherency 182 // mechanism in determining what to do with snoop responses 183 // (in recvTimingSnoop) 184 if (add_outstanding) { 185 // we should never have an exsiting request outstanding 186 assert(outstandingReq.find(pkt->req) == outstandingReq.end()); 187 outstandingReq.insert(pkt->req); 188 } 189 190 // since it is a normal request, attempt to send the packet 191 bool success = masterPorts[master_port_id]->sendTimingReq(pkt); 192 193 // if this is an express snoop, we are done at this point 194 if (is_express_snoop) { 195 assert(success); 196 snoopDataThroughBus += pkt_size; 197 } else { 198 // for normal requests, check if successful 199 if (!success) { 200 // inhibited packets should never be forced to retry 201 assert(!pkt->memInhibitAsserted()); 202 203 // if it was added as outstanding and the send failed, then 204 // erase it again 205 if (add_outstanding) 206 outstandingReq.erase(pkt->req); 207 208 // undo the calculation so we can check for 0 again 209 pkt->busFirstWordDelay = pkt->busLastWordDelay = 0; 210 211 DPRINTF(CoherentBus, "recvTimingReq: src %s %s 0x%x RETRY\n", 212 src_port->name(), pkt->cmdString(), pkt->getAddr()); 213 214 // update the bus state and schedule an idle event 215 reqLayers[master_port_id]->failedTiming(src_port, 216 clockEdge(headerCycles)); 217 } else { 218 // update the bus state and schedule an idle event 219 reqLayers[master_port_id]->succeededTiming(packetFinishTime); 220 dataThroughBus += pkt_size; 221 } 222 } 223 224 // stats updates only consider packets that were successfully sent 225 if (success) { 226 pktCount[slave_port_id][master_port_id]++; 227 totPktSize[slave_port_id][master_port_id] += pkt_size; 228 transDist[pkt_cmd]++; 229 } 230 231 return success; 232} 233 234bool 235CoherentBus::recvTimingResp(PacketPtr pkt, PortID master_port_id) 236{ 237 // determine the source port based on the id 238 MasterPort *src_port = masterPorts[master_port_id]; 239 240 // determine the destination based on what is stored in the packet 241 PortID slave_port_id = pkt->getDest(); 242 243 // test if the bus should be considered occupied for the current 244 // port 245 if (!respLayers[slave_port_id]->tryTiming(src_port)) { 246 DPRINTF(CoherentBus, "recvTimingResp: src %s %s 0x%x BUSY\n", 247 src_port->name(), pkt->cmdString(), pkt->getAddr()); 248 return false; 249 } 250 251 DPRINTF(CoherentBus, "recvTimingResp: src %s %s 0x%x\n", 252 src_port->name(), pkt->cmdString(), pkt->getAddr()); 253 254 // store size and command as they might be modified when 255 // forwarding the packet 256 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 257 unsigned int pkt_cmd = pkt->cmdToIndex(); 258 259 calcPacketTiming(pkt); 260 Tick packetFinishTime = pkt->busLastWordDelay + curTick(); 261 262 // the packet is a normal response to a request that we should 263 // have seen passing through the bus 264 assert(outstandingReq.find(pkt->req) != outstandingReq.end()); 265 266 // remove it as outstanding 267 outstandingReq.erase(pkt->req); 268 269 // send the packet through the destination slave port 270 bool success M5_VAR_USED = slavePorts[slave_port_id]->sendTimingResp(pkt); 271 272 // currently it is illegal to block responses... can lead to 273 // deadlock 274 assert(success); 275 276 respLayers[slave_port_id]->succeededTiming(packetFinishTime); 277 278 // stats updates 279 dataThroughBus += pkt_size; 280 pktCount[slave_port_id][master_port_id]++; 281 totPktSize[slave_port_id][master_port_id] += pkt_size; 282 transDist[pkt_cmd]++; 283 284 return true; 285} 286 287void 288CoherentBus::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id) 289{ 290 DPRINTF(CoherentBus, "recvTimingSnoopReq: src %s %s 0x%x\n", 291 masterPorts[master_port_id]->name(), pkt->cmdString(), 292 pkt->getAddr()); 293 294 // update stats here as we know the forwarding will succeed 295 transDist[pkt->cmdToIndex()]++; 296 snoopDataThroughBus += pkt->hasData() ? pkt->getSize() : 0; 297 298 // we should only see express snoops from caches 299 assert(pkt->isExpressSnoop()); 300 301 // set the source port for routing of the response 302 pkt->setSrc(master_port_id); 303 304 // forward to all snoopers 305 forwardTiming(pkt, InvalidPortID); 306 307 // a snoop request came from a connected slave device (one of 308 // our master ports), and if it is not coming from the slave 309 // device responsible for the address range something is 310 // wrong, hence there is nothing further to do as the packet 311 // would be going back to where it came from 312 assert(master_port_id == findPort(pkt->getAddr())); 313} 314 315bool 316CoherentBus::recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id) 317{ 318 // determine the source port based on the id 319 SlavePort* src_port = slavePorts[slave_port_id]; 320 321 // get the destination from the packet 322 PortID dest_port_id = pkt->getDest(); 323 324 // determine if the response is from a snoop request we 325 // created as the result of a normal request (in which case it 326 // should be in the outstandingReq), or if we merely forwarded 327 // someone else's snoop request 328 bool forwardAsSnoop = outstandingReq.find(pkt->req) == 329 outstandingReq.end(); 330 331 // test if the bus should be considered occupied for the current 332 // port, note that the check is bypassed if the response is being 333 // passed on as a normal response since this is occupying the 334 // response layer rather than the snoop response layer 335 if (forwardAsSnoop) { 336 if (!snoopLayers[dest_port_id]->tryTiming(src_port)) { 337 DPRINTF(CoherentBus, "recvTimingSnoopResp: src %s %s 0x%x BUSY\n", 338 src_port->name(), pkt->cmdString(), pkt->getAddr()); 339 return false; 340 } 341 } 342 343 DPRINTF(CoherentBus, "recvTimingSnoopResp: src %s %s 0x%x\n", 344 src_port->name(), pkt->cmdString(), pkt->getAddr()); 345 346 // store size and command as they might be modified when 347 // forwarding the packet 348 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 349 unsigned int pkt_cmd = pkt->cmdToIndex(); 350 351 // responses are never express snoops 352 assert(!pkt->isExpressSnoop()); 353 354 calcPacketTiming(pkt); 355 Tick packetFinishTime = pkt->busLastWordDelay + curTick(); 356 357 // forward it either as a snoop response or a normal response 358 if (forwardAsSnoop) { 359 // this is a snoop response to a snoop request we forwarded, 360 // e.g. coming from the L1 and going to the L2, and it should 361 // be forwarded as a snoop response 362 bool success M5_VAR_USED = 363 masterPorts[dest_port_id]->sendTimingSnoopResp(pkt); 364 pktCount[slave_port_id][dest_port_id]++; 365 totPktSize[slave_port_id][dest_port_id] += pkt_size; 366 assert(success); 367 368 snoopLayers[dest_port_id]->succeededTiming(packetFinishTime); 369 } else { 370 // we got a snoop response on one of our slave ports, 371 // i.e. from a coherent master connected to the bus, and 372 // since we created the snoop request as part of 373 // recvTiming, this should now be a normal response again 374 outstandingReq.erase(pkt->req); 375 376 // this is a snoop response from a coherent master, with a 377 // destination field set on its way through the bus as 378 // request, hence it should never go back to where the 379 // snoop response came from, but instead to where the 380 // original request came from 381 assert(slave_port_id != dest_port_id); 382 383 // as a normal response, it should go back to a master through 384 // one of our slave ports, at this point we are ignoring the 385 // fact that the response layer could be busy and do not touch 386 // its state 387 bool success M5_VAR_USED = 388 slavePorts[dest_port_id]->sendTimingResp(pkt); 389 390 // @todo Put the response in an internal FIFO and pass it on 391 // to the response layer from there 392 393 // currently it is illegal to block responses... can lead 394 // to deadlock 395 assert(success); 396 } 397 398 // stats updates 399 transDist[pkt_cmd]++; 400 snoopDataThroughBus += pkt_size; 401 402 return true; 403} 404 405 406void 407CoherentBus::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) 408{ 409 DPRINTF(CoherentBus, "%s for %s address %x size %d\n", __func__, 410 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 411 412 // snoops should only happen if the system isn't bypassing caches 413 assert(!system->bypassCaches()); 414 415 for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) { 416 SlavePort *p = *s; 417 // we could have gotten this request from a snooping master 418 // (corresponding to our own slave port that is also in 419 // snoopPorts) and should not send it back to where it came 420 // from 421 if (exclude_slave_port_id == InvalidPortID || 422 p->getId() != exclude_slave_port_id) { 423 // cache is not allowed to refuse snoop 424 p->sendTimingSnoopReq(pkt); 425 } 426 } 427} 428 429void 430CoherentBus::recvRetry(PortID master_port_id) 431{ 432 // responses and snoop responses never block on forwarding them, 433 // so the retry will always be coming from a port to which we 434 // tried to forward a request 435 reqLayers[master_port_id]->recvRetry(); 436} 437 438Tick 439CoherentBus::recvAtomic(PacketPtr pkt, PortID slave_port_id) 440{ 441 DPRINTF(CoherentBus, "recvAtomic: packet src %s addr 0x%x cmd %s\n", 442 slavePorts[slave_port_id]->name(), pkt->getAddr(), 443 pkt->cmdString()); 444 445 // add the request data 446 dataThroughBus += pkt->hasData() ? pkt->getSize() : 0; 447 448 MemCmd snoop_response_cmd = MemCmd::InvalidCmd; 449 Tick snoop_response_latency = 0; 450 451 // uncacheable requests need never be snooped 452 if (!pkt->req->isUncacheable() && !system->bypassCaches()) { 453 // forward to all snoopers but the source 454 std::pair<MemCmd, Tick> snoop_result = 455 forwardAtomic(pkt, slave_port_id); 456 snoop_response_cmd = snoop_result.first; 457 snoop_response_latency = snoop_result.second; 458 } 459 460 // even if we had a snoop response, we must continue and also 461 // perform the actual request at the destination 462 PortID dest_id = findPort(pkt->getAddr()); 463 464 // forward the request to the appropriate destination 465 Tick response_latency = masterPorts[dest_id]->sendAtomic(pkt); 466 467 // if we got a response from a snooper, restore it here 468 if (snoop_response_cmd != MemCmd::InvalidCmd) { 469 // no one else should have responded 470 assert(!pkt->isResponse()); 471 pkt->cmd = snoop_response_cmd; 472 response_latency = snoop_response_latency; 473 } 474 475 // add the response data 476 if (pkt->isResponse()) 477 dataThroughBus += pkt->hasData() ? pkt->getSize() : 0; 478 479 // @todo: Not setting first-word time 480 pkt->busLastWordDelay = response_latency; 481 return response_latency; 482} 483 484Tick 485CoherentBus::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id) 486{ 487 DPRINTF(CoherentBus, "recvAtomicSnoop: packet src %s addr 0x%x cmd %s\n", 488 masterPorts[master_port_id]->name(), pkt->getAddr(), 489 pkt->cmdString()); 490 491 // add the request snoop data 492 snoopDataThroughBus += pkt->hasData() ? pkt->getSize() : 0; 493 494 // forward to all snoopers 495 std::pair<MemCmd, Tick> snoop_result = 496 forwardAtomic(pkt, InvalidPortID); 497 MemCmd snoop_response_cmd = snoop_result.first; 498 Tick snoop_response_latency = snoop_result.second; 499 500 if (snoop_response_cmd != MemCmd::InvalidCmd) 501 pkt->cmd = snoop_response_cmd; 502 503 // add the response snoop data 504 if (pkt->isResponse()) 505 snoopDataThroughBus += pkt->hasData() ? pkt->getSize() : 0; 506 507 // @todo: Not setting first-word time 508 pkt->busLastWordDelay = snoop_response_latency; 509 return snoop_response_latency; 510} 511 512std::pair<MemCmd, Tick> 513CoherentBus::forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id) 514{ 515 // the packet may be changed on snoops, record the original 516 // command to enable us to restore it between snoops so that 517 // additional snoops can take place properly 518 MemCmd orig_cmd = pkt->cmd; 519 MemCmd snoop_response_cmd = MemCmd::InvalidCmd; 520 Tick snoop_response_latency = 0; 521 522 // snoops should only happen if the system isn't bypassing caches 523 assert(!system->bypassCaches()); 524 525 for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) { 526 SlavePort *p = *s; 527 // we could have gotten this request from a snooping master 528 // (corresponding to our own slave port that is also in 529 // snoopPorts) and should not send it back to where it came 530 // from 531 if (exclude_slave_port_id == InvalidPortID || 532 p->getId() != exclude_slave_port_id) { 533 Tick latency = p->sendAtomicSnoop(pkt); 534 // in contrast to a functional access, we have to keep on 535 // going as all snoopers must be updated even if we get a 536 // response 537 if (pkt->isResponse()) { 538 // response from snoop agent 539 assert(pkt->cmd != orig_cmd); 540 assert(pkt->memInhibitAsserted()); 541 // should only happen once 542 assert(snoop_response_cmd == MemCmd::InvalidCmd); 543 // save response state 544 snoop_response_cmd = pkt->cmd; 545 snoop_response_latency = latency; 546 // restore original packet state for remaining snoopers 547 pkt->cmd = orig_cmd; 548 } 549 } 550 } 551 552 // the packet is restored as part of the loop and any potential 553 // snoop response is part of the returned pair 554 return std::make_pair(snoop_response_cmd, snoop_response_latency); 555} 556 557void 558CoherentBus::recvFunctional(PacketPtr pkt, PortID slave_port_id) 559{ 560 if (!pkt->isPrint()) { 561 // don't do DPRINTFs on PrintReq as it clutters up the output 562 DPRINTF(CoherentBus, 563 "recvFunctional: packet src %s addr 0x%x cmd %s\n", 564 slavePorts[slave_port_id]->name(), pkt->getAddr(), 565 pkt->cmdString()); 566 } 567 568 // uncacheable requests need never be snooped 569 if (!pkt->req->isUncacheable() && !system->bypassCaches()) { 570 // forward to all snoopers but the source 571 forwardFunctional(pkt, slave_port_id); 572 } 573 574 // there is no need to continue if the snooping has found what we 575 // were looking for and the packet is already a response 576 if (!pkt->isResponse()) { 577 PortID dest_id = findPort(pkt->getAddr()); 578 579 masterPorts[dest_id]->sendFunctional(pkt); 580 } 581} 582 583void 584CoherentBus::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id) 585{ 586 if (!pkt->isPrint()) { 587 // don't do DPRINTFs on PrintReq as it clutters up the output 588 DPRINTF(CoherentBus, 589 "recvFunctionalSnoop: packet src %s addr 0x%x cmd %s\n", 590 masterPorts[master_port_id]->name(), pkt->getAddr(), 591 pkt->cmdString()); 592 } 593 594 // forward to all snoopers 595 forwardFunctional(pkt, InvalidPortID); 596} 597 598void 599CoherentBus::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id) 600{ 601 // snoops should only happen if the system isn't bypassing caches 602 assert(!system->bypassCaches()); 603 604 for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) { 605 SlavePort *p = *s; 606 // we could have gotten this request from a snooping master 607 // (corresponding to our own slave port that is also in 608 // snoopPorts) and should not send it back to where it came 609 // from 610 if (exclude_slave_port_id == InvalidPortID || 611 p->getId() != exclude_slave_port_id) 612 p->sendFunctionalSnoop(pkt); 613 614 // if we get a response we are done 615 if (pkt->isResponse()) { 616 break; 617 } 618 } 619} 620 621unsigned int 622CoherentBus::drain(DrainManager *dm) 623{ 624 // sum up the individual layers 625 unsigned int total = 0; 626 for (auto l = reqLayers.begin(); l != reqLayers.end(); ++l) 627 total += (*l)->drain(dm); 628 for (auto l = respLayers.begin(); l != respLayers.end(); ++l) 629 total += (*l)->drain(dm); 630 for (auto l = snoopLayers.begin(); l != snoopLayers.end(); ++l) 631 total += (*l)->drain(dm); 632 return total; 633} 634 635void 636CoherentBus::regStats() 637{ 638 // register the stats of the base class and our three bus layers 639 BaseBus::regStats(); 640 for (auto l = reqLayers.begin(); l != reqLayers.end(); ++l) 641 (*l)->regStats(); 642 for (auto l = respLayers.begin(); l != respLayers.end(); ++l) 643 (*l)->regStats(); 644 for (auto l = snoopLayers.begin(); l != snoopLayers.end(); ++l) 645 (*l)->regStats(); 646 647 dataThroughBus 648 .name(name() + ".data_through_bus") 649 .desc("Total data (bytes)") 650 ; 651 652 snoopDataThroughBus 653 .name(name() + ".snoop_data_through_bus") 654 .desc("Total snoop data (bytes)") 655 ; 656 657 throughput 658 .name(name() + ".throughput") 659 .desc("Throughput (bytes/s)") 660 .precision(0) 661 ; 662 663 throughput = (dataThroughBus + snoopDataThroughBus) / simSeconds; 664} 665 666CoherentBus * 667CoherentBusParams::create() 668{ 669 return new CoherentBus(this); 670} 671