cpu: Support trace termination in BaseTrafficGen
authorAndreas Sandberg <andreas.sandberg@arm.com>
Wed, 2 May 2018 13:04:04 +0000 (14:04 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 13 Jul 2018 09:26:23 +0000 (09:26 +0000)
Make the BaseTrafficGen handle cases where getNextPacket() can't find
a new packet and returns NULL. In that case, assume the generator has
run out of packets and switch to the next generator.

Change-Id: I5ca6ead550005812fb849ed9ce6b5007a65ddfa7
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/11517
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/cpu/testers/traffic_gen/base.cc

index 95878f078a82aa7cfad6b758cd320ad225dbfb47..fe2577835c383b99e3fe317ed4ee4a8aba47017f 100644 (file)
@@ -169,13 +169,13 @@ BaseTrafficGen::update()
 
         // suppress packets that are not destined for a memory, such as
         // device accesses that could be part of a trace
-        if (system->isMemAddr(pkt->getAddr())) {
+        if (pkt && system->isMemAddr(pkt->getAddr())) {
             numPackets++;
             if (!port.sendTimingReq(pkt)) {
                 retryPkt = pkt;
                 retryPktTick = curTick();
             }
-        } else {
+        } else if (pkt) {
             DPRINTF(TrafficGen, "Suppressed packet %s 0x%x\n",
                     pkt->cmdString(), pkt->getAddr());
 
@@ -229,11 +229,19 @@ BaseTrafficGen::transition()
 void
 BaseTrafficGen::scheduleUpdate()
 {
+    // Has the generator run out of work? In that case, force a
+    // transition if a transition period hasn't been configured.
+    while (activeGenerator &&
+           nextPacketTick == MaxTick && nextTransitionTick == MaxTick) {
+        transition();
+    }
+
+    if (!activeGenerator)
+        return;
+
     // schedule next update event based on either the next execute
     // tick or the next transition, which ever comes first
     const Tick nextEventTick = std::min(nextPacketTick, nextTransitionTick);
-    if (nextEventTick == MaxTick)
-        return;
 
     DPRINTF(TrafficGen, "Next event scheduled at %lld\n", nextEventTick);