From e8381142b061fbdf2f22d958f1c7559e9ffb3bd8 Mon Sep 17 00:00:00 2001 From: Dam Sunwoo Date: Mon, 22 Apr 2013 13:20:31 -0400 Subject: sim: separate nextCycle() and clockEdge() in clockedObjects Previously, nextCycle() could return the *current* cycle if the current tick was already aligned with the clock edge. This behavior is not only confusing (not quite what the function name implies), but also caused problems in the drainResume() function. When exiting/re-entering the sim loop (e.g., to take checkpoints), the CPUs will drain and resume. Due to the previous behavior of nextCycle(), the CPU tick events were being rescheduled in the same ticks that were already processed before draining. This caused divergence from runs that did not exit/re-entered the sim loop. (Initially a cycle difference, but a significant impact later on.) This patch separates out the two behaviors (nextCycle() and clockEdge()), uses nextCycle() in drainResume, and uses clockEdge() everywhere else. Nothing (other than name) should change except for the drainResume timing. --- src/sim/clocked_object.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/sim') diff --git a/src/sim/clocked_object.hh b/src/sim/clocked_object.hh index bf132bee1..d836c48cc 100644 --- a/src/sim/clocked_object.hh +++ b/src/sim/clocked_object.hh @@ -172,13 +172,14 @@ class ClockedObject : public SimObject } /** - * Based on the clock of the object, determine the tick when the - * next cycle begins, in other words, return the next clock edge. + * Based on the clock of the object, determine the tick when the next + * cycle begins, in other words, return the next clock edge. + * (This can never be the current tick.) * * @return The tick when the next cycle starts */ Tick nextCycle() const - { return clockEdge(); } + { return clockEdge(Cycles(1)); } inline uint64_t frequency() const { return SimClock::Frequency / clock; } -- cgit v1.2.3