summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/base/vnc/vncinput.cc1
-rw-r--r--src/dev/intel_8254_timer.hh3
-rw-r--r--src/dev/mc146818.hh2
-rw-r--r--src/mem/comm_monitor.cc1
-rw-r--r--src/mem/packet_queue.cc1
-rw-r--r--src/mem/packet_queue.hh2
-rw-r--r--src/mem/physical.cc1
-rw-r--r--src/mem/ruby/network/Topology.cc1
-rw-r--r--src/mem/ruby/system/System.cc6
-rw-r--r--src/mem/simple_dram.cc1
-rw-r--r--src/python/swig/event.i2
-rw-r--r--src/sim/clocked_object.hh1
-rw-r--r--src/sim/core.cc3
-rw-r--r--src/sim/core.hh6
-rw-r--r--src/sim/debug.cc2
-rw-r--r--src/sim/eventq.cc7
-rw-r--r--src/sim/eventq.hh69
-rw-r--r--src/sim/eventq_impl.hh100
-rw-r--r--src/sim/root.cc1
-rw-r--r--src/sim/serialize.cc2
-rw-r--r--src/sim/sim_events.cc2
-rw-r--r--src/sim/sim_object.hh2
-rw-r--r--src/sim/simulate.cc5
23 files changed, 137 insertions, 84 deletions
diff --git a/src/base/vnc/vncinput.cc b/src/base/vnc/vncinput.cc
index 526f61bc1..071804583 100644
--- a/src/base/vnc/vncinput.cc
+++ b/src/base/vnc/vncinput.cc
@@ -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 --git a/src/dev/intel_8254_timer.hh b/src/dev/intel_8254_timer.hh
index 72b9b9c72..ad751447e 100644
--- a/src/dev/intel_8254_timer.hh
+++ b/src/dev/intel_8254_timer.hh
@@ -38,8 +38,9 @@
#include "base/bitunion.hh"
#include "base/types.hh"
+#include "base/trace.hh"
#include "debug/Intel8254Timer.hh"
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
#include "sim/serialize.hh"
/** Programmable Interval Timer (Intel 8254) */
diff --git a/src/dev/mc146818.hh b/src/dev/mc146818.hh
index c2f1e2dd8..0c7baf47b 100644
--- a/src/dev/mc146818.hh
+++ b/src/dev/mc146818.hh
@@ -33,7 +33,7 @@
#ifndef __DEV_MC146818_HH__
#define __DEV_MC146818_HH__
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
/** Real-Time Clock (MC146818) */
class MC146818 : public EventManager
diff --git a/src/mem/comm_monitor.cc b/src/mem/comm_monitor.cc
index aea028692..7e98f64f6 100644
--- a/src/mem/comm_monitor.cc
+++ b/src/mem/comm_monitor.cc
@@ -38,6 +38,7 @@
* Andreas Hansson
*/
+#include "base/trace.hh"
#include "debug/CommMonitor.hh"
#include "mem/comm_monitor.hh"
#include "sim/stats.hh"
diff --git a/src/mem/packet_queue.cc b/src/mem/packet_queue.cc
index eb94cc397..8030cb38f 100644
--- a/src/mem/packet_queue.cc
+++ b/src/mem/packet_queue.cc
@@ -41,6 +41,7 @@
* Andreas Hansson
*/
+#include "base/trace.hh"
#include "debug/Drain.hh"
#include "debug/PacketQueue.hh"
#include "mem/packet_queue.hh"
diff --git a/src/mem/packet_queue.hh b/src/mem/packet_queue.hh
index 2321ec4f2..b3df8d71f 100644
--- a/src/mem/packet_queue.hh
+++ b/src/mem/packet_queue.hh
@@ -56,8 +56,8 @@
#include <list>
#include "mem/port.hh"
-#include "sim/eventq.hh"
#include "sim/drain.hh"
+#include "sim/eventq_impl.hh"
/**
* A packet queue is a class that holds deferred packets and later
diff --git a/src/mem/physical.cc b/src/mem/physical.cc
index f55b95048..2b750f0ed 100644
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -50,6 +50,7 @@
#include <iostream>
#include <string>
+#include "base/trace.hh"
#include "debug/BusAddrRanges.hh"
#include "debug/Checkpoint.hh"
#include "mem/abstract_mem.hh"
diff --git a/src/mem/ruby/network/Topology.cc b/src/mem/ruby/network/Topology.cc
index 082b2c4ac..7ccc9e3e2 100644
--- a/src/mem/ruby/network/Topology.cc
+++ b/src/mem/ruby/network/Topology.cc
@@ -28,6 +28,7 @@
#include <cassert>
+#include "base/trace.hh"
#include "debug/RubyNetwork.hh"
#include "mem/protocol/MachineType.hh"
#include "mem/ruby/common/NetDest.hh"
diff --git a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc
index 65bad07b3..6a0721217 100644
--- a/src/mem/ruby/system/System.cc
+++ b/src/mem/ruby/system/System.cc
@@ -226,7 +226,7 @@ RubySystem::serialize(std::ostream &os)
// 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 @@ RubySystem::startup()
// 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 @@ RubySystem::startup()
// Restore eventq head
eventq_head = eventq->replaceHead(eventq_head);
// Restore curTick and Ruby System's clock
- curTick(curtick_original);
+ setCurTick(curtick_original);
resetClock();
}
}
diff --git a/src/mem/simple_dram.cc b/src/mem/simple_dram.cc
index b17ce68d0..62825d139 100644
--- a/src/mem/simple_dram.cc
+++ b/src/mem/simple_dram.cc
@@ -38,6 +38,7 @@
* Ani Udipi
*/
+#include "base/trace.hh"
#include "debug/Drain.hh"
#include "debug/DRAM.hh"
#include "debug/DRAMWR.hh"
diff --git a/src/python/swig/event.i b/src/python/swig/event.i
index 1f7740eab..788ea7cfa 100644
--- a/src/python/swig/event.i
+++ b/src/python/swig/event.i
@@ -33,7 +33,7 @@
%{
#include "base/types.hh"
#include "python/swig/pyevent.hh"
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/simulate.hh"
diff --git a/src/sim/clocked_object.hh b/src/sim/clocked_object.hh
index 9a4c1034a..d9630139a 100644
--- a/src/sim/clocked_object.hh
+++ b/src/sim/clocked_object.hh
@@ -47,6 +47,7 @@
#include "base/intmath.hh"
#include "params/ClockedObject.hh"
+#include "sim/core.hh"
#include "sim/sim_object.hh"
/**
diff --git a/src/sim/core.cc b/src/sim/core.cc
index ab75e1d9a..aa618bdb3 100644
--- a/src/sim/core.cc
+++ b/src/sim/core.cc
@@ -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 --git a/src/sim/core.hh b/src/sim/core.hh
index 4f842ab48..b5a082bcb 100644
--- a/src/sim/core.hh
+++ b/src/sim/core.hh
@@ -39,12 +39,10 @@
#include <string>
#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 --git a/src/sim/debug.cc b/src/sim/debug.cc
index fadd89ae1..51b92740e 100644
--- a/src/sim/debug.cc
+++ b/src/sim/debug.cc
@@ -36,7 +36,7 @@
#include "base/debug.hh"
#include "sim/debug.hh"
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc
index b32b330e7..d81937a86 100644
--- a/src/sim/eventq.cc
+++ b/src/sim/eventq.cc
@@ -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 @@ EventQueue::serviceOne()
// 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) ||
@@ -429,5 +432,5 @@ Event::dump() const
}
EventQueue::EventQueue(const string &n)
- : objName(n), head(NULL)
+ : objName(n), head(NULL), _curTick(0)
{}
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 5362dcf34..5d5764a6a 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -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 @@ class EventQueue : public Serializable
private:
std::string objName;
Event *head;
+ Tick _curTick;
void insert(Event *event);
void remove(Event *event);
@@ -379,6 +379,9 @@ class EventQueue : public Serializable
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 @@ class EventQueue : public Serializable
//assert(head->when() >= when && "event scheduled in the past");
serviceOne();
}
+
+ setCurTick(when);
}
// return true if no events are queued
@@ -476,67 +481,9 @@ class EventManager
{
eventq->reschedule(event, when, always);
}
-};
-
-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");
-}
+ void setCurTick(Tick newVal) { eventq->setCurTick(newVal); }
+};
template <class T, void (T::* F)()>
void
diff --git a/src/sim/eventq_impl.hh b/src/sim/eventq_impl.hh
new file mode 100644
index 000000000..c53a4da77
--- /dev/null
+++ b/src/sim/eventq_impl.hh
@@ -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 --git a/src/sim/root.cc b/src/sim/root.cc
index b8fadf190..f77159486 100644
--- a/src/sim/root.cc
+++ b/src/sim/root.cc
@@ -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 --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 54b7926d6..9ef92d449 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -465,7 +465,7 @@ Globals::unserialize(Checkpoint *cp, const std::string &section)
{
Tick tick;
paramIn(cp, section, "curTick", tick);
- curTick(tick);
+ mainEventQueue.setCurTick(tick);
mainEventQueue.unserialize(cp, "MainEventQueue");
}
diff --git a/src/sim/sim_events.cc b/src/sim/sim_events.cc
index 2354e89f7..0ae7e573e 100644
--- a/src/sim/sim_events.cc
+++ b/src/sim/sim_events.cc
@@ -32,7 +32,7 @@
#include "base/callback.hh"
#include "base/hostinfo.hh"
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/stats.hh"
diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh
index f04289e2f..6424f631b 100644
--- a/src/sim/sim_object.hh
+++ b/src/sim/sim_object.hh
@@ -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 --git a/src/sim/simulate.cc b/src/sim/simulate.cc
index 238e68787..6962fab9f 100644
--- a/src/sim/simulate.cc
+++ b/src/sim/simulate.cc
@@ -33,7 +33,7 @@
#include "base/pollevent.hh"
#include "base/types.hh"
#include "sim/async.hh"
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/simulate.hh"
@@ -65,9 +65,6 @@ simulate(Tick num_cycles)
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