diff -r 0fea324c832c -r fa8ef864296e src/base/vnc/vncinput.cc --- a/src/base/vnc/vncinput.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/base/vnc/vncinput.cc Thu Nov 15 16:09:55 2012 -0600 @@ -46,6 +46,7 @@ #include "base/vnc/vncinput.hh" #include "base/output.hh" //simout +#include "base/trace.hh" #include "debug/VNC.hh" using namespace std; diff -r 0fea324c832c -r fa8ef864296e src/dev/intel_8254_timer.hh --- a/src/dev/intel_8254_timer.hh Sat Nov 10 17:18:02 2012 -0600 +++ b/src/dev/intel_8254_timer.hh Thu Nov 15 16:09:55 2012 -0600 @@ -38,6 +38,7 @@ #include "base/bitunion.hh" #include "base/types.hh" +#include "base/trace.hh" #include "debug/Intel8254Timer.hh" #include "sim/eventq.hh" #include "sim/serialize.hh" diff -r 0fea324c832c -r fa8ef864296e src/mem/comm_monitor.cc --- a/src/mem/comm_monitor.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/mem/comm_monitor.cc Thu Nov 15 16:09:55 2012 -0600 @@ -38,6 +38,7 @@ * Andreas Hansson */ +#include "base/trace.hh" #include "debug/CommMonitor.hh" #include "mem/comm_monitor.hh" #include "sim/stats.hh" diff -r 0fea324c832c -r fa8ef864296e src/mem/packet_queue.cc --- a/src/mem/packet_queue.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/mem/packet_queue.cc Thu Nov 15 16:09:55 2012 -0600 @@ -41,6 +41,7 @@ * Andreas Hansson */ +#include "base/trace.hh" #include "debug/Drain.hh" #include "debug/PacketQueue.hh" #include "mem/packet_queue.hh" diff -r 0fea324c832c -r fa8ef864296e src/mem/physical.cc --- a/src/mem/physical.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/mem/physical.cc Thu Nov 15 16:09:55 2012 -0600 @@ -50,6 +50,7 @@ #include #include +#include "base/trace.hh" #include "debug/BusAddrRanges.hh" #include "debug/Checkpoint.hh" #include "mem/abstract_mem.hh" diff -r 0fea324c832c -r fa8ef864296e src/mem/ruby/network/Topology.cc --- a/src/mem/ruby/network/Topology.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/mem/ruby/network/Topology.cc Thu Nov 15 16:09:55 2012 -0600 @@ -28,6 +28,7 @@ #include +#include "base/trace.hh" #include "debug/RubyNetwork.hh" #include "mem/protocol/MachineType.hh" #include "mem/ruby/common/NetDest.hh" diff -r 0fea324c832c -r fa8ef864296e src/mem/ruby/system/System.cc --- a/src/mem/ruby/system/System.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/mem/ruby/system/System.cc Thu Nov 15 16:09:55 2012 -0600 @@ -226,7 +226,7 @@ // Restore eventq head eventq_head = eventq->replaceHead(eventq_head); // Restore curTick - curTick(curtick_original); + setCurTick(curtick_original); uint8_t *raw_data = NULL; @@ -357,7 +357,7 @@ // save the event queue head Event* eventq_head = eventq->replaceHead(NULL); // set curTick to 0 and reset Ruby System's clock - curTick(0); + setCurTick(0); resetClock(); // Schedule an event to start cache warmup @@ -377,7 +377,7 @@ // Restore eventq head eventq_head = eventq->replaceHead(eventq_head); // Restore curTick and Ruby System's clock - curTick(curtick_original); + setCurTick(curtick_original); resetClock(); } } diff -r 0fea324c832c -r fa8ef864296e src/mem/simple_dram.cc --- a/src/mem/simple_dram.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/mem/simple_dram.cc Thu Nov 15 16:09:55 2012 -0600 @@ -38,6 +38,7 @@ * Ani Udipi */ +#include "base/trace.hh" #include "debug/Drain.hh" #include "debug/DRAM.hh" #include "debug/DRAMWR.hh" diff -r 0fea324c832c -r fa8ef864296e src/sim/clocked_object.hh --- a/src/sim/clocked_object.hh Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/clocked_object.hh Thu Nov 15 16:09:55 2012 -0600 @@ -47,6 +47,7 @@ #include "base/intmath.hh" #include "params/ClockedObject.hh" +#include "sim/core.hh" #include "sim/sim_object.hh" /** diff -r 0fea324c832c -r fa8ef864296e src/sim/core.hh --- a/src/sim/core.hh Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/core.hh Thu Nov 15 16:09:55 2012 -0600 @@ -39,12 +39,10 @@ #include #include "base/types.hh" +#include "sim/eventq.hh" /// The universal simulation clock. -extern Tick _curTick; - -inline Tick curTick() { return _curTick; } -inline void curTick(Tick newVal) { _curTick = newVal; } +inline Tick curTick() { return mainEventQueue.getCurTick(); } const Tick retryTime = 1000; diff -r 0fea324c832c -r fa8ef864296e src/sim/core.cc --- a/src/sim/core.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/core.cc Thu Nov 15 16:09:55 2012 -0600 @@ -35,11 +35,10 @@ #include "base/callback.hh" #include "base/output.hh" #include "sim/core.hh" +#include "sim/eventq.hh" using namespace std; -Tick _curTick = 0; - namespace SimClock { /// The simulated frequency of curTick(). (In ticks per second) Tick Frequency; diff -r 0fea324c832c -r fa8ef864296e src/sim/eventq.hh --- a/src/sim/eventq.hh Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/eventq.hh Thu Nov 15 16:09:55 2012 -0600 @@ -44,7 +44,6 @@ #include "base/flags.hh" #include "base/misc.hh" -#include "base/trace.hh" #include "base/types.hh" #include "debug/Event.hh" #include "sim/serialize.hh" @@ -361,6 +360,7 @@ private: std::string objName; Event *head; + Tick _curTick; void insert(Event *event); void remove(Event *event); @@ -379,6 +379,9 @@ void reschedule(Event *event, Tick when, bool always = false); Tick nextTick() const { return head->when(); } + void setCurTick(Tick newVal) { _curTick = newVal; } + Tick getCurTick() { return _curTick; } + Event *serviceOne(); // process all events up to the given timestamp. we inline a @@ -398,6 +401,8 @@ //assert(head->when() >= when && "event scheduled in the past"); serviceOne(); } + + setCurTick(when); } // return true if no events are queued @@ -476,68 +481,10 @@ { eventq->reschedule(event, when, always); } + + void setCurTick(Tick newVal) { eventq->setCurTick(newVal); } }; -inline void -EventQueue::schedule(Event *event, Tick when) -{ - assert(when >= curTick()); - assert(!event->scheduled()); - assert(event->initialized()); - - event->setWhen(when, this); - insert(event); - event->flags.set(Event::Scheduled); - if (this == &mainEventQueue) - event->flags.set(Event::IsMainQueue); - else - event->flags.clear(Event::IsMainQueue); - - if (DTRACE(Event)) - event->trace("scheduled"); -} - -inline void -EventQueue::deschedule(Event *event) -{ - assert(event->scheduled()); - assert(event->initialized()); - - remove(event); - - event->flags.clear(Event::Squashed); - event->flags.clear(Event::Scheduled); - - if (DTRACE(Event)) - event->trace("descheduled"); - - if (event->flags.isSet(Event::AutoDelete)) - delete event; -} - -inline void -EventQueue::reschedule(Event *event, Tick when, bool always) -{ - assert(when >= curTick()); - assert(always || event->scheduled()); - assert(event->initialized()); - - if (event->scheduled()) - remove(event); - - event->setWhen(when, this); - insert(event); - event->flags.clear(Event::Squashed); - event->flags.set(Event::Scheduled); - if (this == &mainEventQueue) - event->flags.set(Event::IsMainQueue); - else - event->flags.clear(Event::IsMainQueue); - - if (DTRACE(Event)) - event->trace("rescheduled"); -} - template void DelayFunction(EventQueue *eventq, Tick when, T *object) diff -r 0fea324c832c -r fa8ef864296e src/sim/eventq.cc --- a/src/sim/eventq.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/eventq.cc Thu Nov 15 16:09:55 2012 -0600 @@ -42,7 +42,7 @@ #include "cpu/smt.hh" #include "debug/Config.hh" #include "sim/core.hh" -#include "sim/eventq.hh" +#include "sim/eventq_impl.hh" using namespace std; @@ -201,6 +201,9 @@ // handle action if (!event->squashed()) { + // forward current cycle to the time when this event occurs. + setCurTick(event->when()); + event->process(); if (event->isExitEvent()) { assert(!event->flags.isSet(Event::AutoDelete) || @@ -263,6 +266,8 @@ void EventQueue::serialize(ostream &os) { + paramOut(os, "curTick", getCurTick()); + std::list eventPtrs; int numEvents = 0; @@ -294,6 +299,10 @@ void EventQueue::unserialize(Checkpoint *cp, const std::string §ion) { + Tick tick; + paramIn(cp, section, "curTick", tick); + setCurTick(tick); + int numEvents; UNSERIALIZE_SCALAR(numEvents); @@ -429,5 +438,5 @@ } EventQueue::EventQueue(const string &n) - : objName(n), head(NULL) + : objName(n), head(NULL), _curTick(0) {} diff -r 0fea324c832c -r fa8ef864296e src/sim/eventq_impl.hh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sim/eventq_impl.hh Thu Nov 15 16:09:55 2012 -0600 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2012 The Regents of The University of Michigan + * Copyright (c) 2012 Mark D. Hill and David A. Wood + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Steve Reinhardt + * Nathan Binkert + * Nilay Vaish + */ + +#ifndef __SIM_EVENTQ_IMPL_HH__ +#define __SIM_EVENTQ_IMPL_HH__ + +#include "base/trace.hh" +#include "sim/eventq.hh" + +inline void +EventQueue::schedule(Event *event, Tick when) +{ + assert(when >= getCurTick()); + assert(!event->scheduled()); + assert(event->initialized()); + + event->setWhen(when, this); + insert(event); + event->flags.set(Event::Scheduled); + if (this == &mainEventQueue) + event->flags.set(Event::IsMainQueue); + else + event->flags.clear(Event::IsMainQueue); + + if (DTRACE(Event)) + event->trace("scheduled"); +} + +inline void +EventQueue::deschedule(Event *event) +{ + assert(event->scheduled()); + assert(event->initialized()); + + remove(event); + + event->flags.clear(Event::Squashed); + event->flags.clear(Event::Scheduled); + + if (DTRACE(Event)) + event->trace("descheduled"); + + if (event->flags.isSet(Event::AutoDelete)) + delete event; +} + +inline void +EventQueue::reschedule(Event *event, Tick when, bool always) +{ + assert(when >= getCurTick()); + assert(always || event->scheduled()); + assert(event->initialized()); + + if (event->scheduled()) + remove(event); + + event->setWhen(when, this); + insert(event); + event->flags.clear(Event::Squashed); + event->flags.set(Event::Scheduled); + if (this == &mainEventQueue) + event->flags.set(Event::IsMainQueue); + else + event->flags.clear(Event::IsMainQueue); + + if (DTRACE(Event)) + event->trace("rescheduled"); +} + +#endif // __SIM_EVENTQ_IMPL_HH__ diff -r 0fea324c832c -r fa8ef864296e src/sim/root.cc --- a/src/sim/root.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/root.cc Thu Nov 15 16:09:55 2012 -0600 @@ -32,6 +32,7 @@ */ #include "base/misc.hh" +#include "base/trace.hh" #include "config/the_isa.hh" #include "debug/TimeSync.hh" #include "sim/full_system.hh" diff -r 0fea324c832c -r fa8ef864296e src/sim/serialize.cc --- a/src/sim/serialize.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/serialize.cc Thu Nov 15 16:09:55 2012 -0600 @@ -454,8 +454,6 @@ Globals::serialize(ostream &os) { nameOut(os); - paramOut(os, "curTick", curTick()); - nameOut(os, "MainEventQueue"); mainEventQueue.serialize(os); } @@ -463,10 +461,6 @@ void Globals::unserialize(Checkpoint *cp, const std::string §ion) { - Tick tick; - paramIn(cp, section, "curTick", tick); - curTick(tick); - mainEventQueue.unserialize(cp, "MainEventQueue"); } diff -r 0fea324c832c -r fa8ef864296e src/sim/sim_object.hh --- a/src/sim/sim_object.hh Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/sim_object.hh Thu Nov 15 16:09:55 2012 -0600 @@ -46,7 +46,7 @@ #include "enums/MemoryMode.hh" #include "params/SimObject.hh" #include "sim/drain.hh" -#include "sim/eventq.hh" +#include "sim/eventq_impl.hh" #include "sim/serialize.hh" class BaseCPU; diff -r 0fea324c832c -r fa8ef864296e src/sim/simulate.cc --- a/src/sim/simulate.cc Sat Nov 10 17:18:02 2012 -0600 +++ b/src/sim/simulate.cc Thu Nov 15 16:09:55 2012 -0600 @@ -65,9 +65,6 @@ assert(curTick() <= mainEventQueue.nextTick() && "event scheduled in the past"); - // forward current cycle to the time of the first event on the - // queue - curTick(mainEventQueue.nextTick()); Event *exit_event = mainEventQueue.serviceOne(); if (exit_event != NULL) { // hit some kind of exit event; return to Python