mem-cache: Avoid write merging if there are reads in between
[gem5.git] / src / sim / core.cc
index c961e9eb8ed7255c3f560c2f9220e6db446b0731..cb9051f383d2862bc4a4fe6eb8cbd9ecfed3979c 100644 (file)
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2006 The Regents of The University of Michigan
+ * Copyright (c) 2013 Advanced Micro Devices, Inc.
+ * Copyright (c) 2013 Mark D. Hill and David A. Wood
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  *          Steve Reinhardt
  */
 
+#include "sim/core.hh"
+
 #include <iostream>
 #include <string>
 
 #include "base/callback.hh"
+#include "base/cprintf.hh"
+#include "base/logging.hh"
 #include "base/output.hh"
-#include "sim/core.hh"
+#include "sim/eventq.hh"
 
 using namespace std;
 
-Tick curTick = 0;
-
-namespace Clock {
-/// The simulated frequency of curTick. (In ticks per second)
+namespace SimClock {
+/// The simulated frequency of curTick(). (In ticks per second)
 Tick Frequency;
 
 namespace Float {
@@ -54,8 +58,8 @@ double ps;
 double Hz;
 double kHz;
 double MHz;
-double GHZ;
-/* namespace Float */ }
+double GHz;
+} // namespace Float
 
 namespace Int {
 Tick s;
@@ -63,15 +67,27 @@ Tick ms;
 Tick us;
 Tick ns;
 Tick ps;
-/* namespace Float */ }
+} // namespace Float
+
+} // namespace SimClock
+
+namespace {
+
+bool _clockFrequencyFixed = false;
+
+// Default to 1 THz (1 Tick == 1 ps)
+Tick _ticksPerSecond = 1e12;
 
-/* namespace Clock */ }
+} // anonymous namespace
 
 void
-setClockFrequency(Tick ticksPerSecond)
+fixClockFrequency()
 {
-    using namespace Clock;
-    Frequency = ticksPerSecond;
+    if (_clockFrequencyFixed)
+        return;
+
+    using namespace SimClock;
+    Frequency = _ticksPerSecond;
     Float::s = static_cast<double>(Frequency);
     Float::ms = Float::s / 1.0e3;
     Float::us = Float::s / 1.0e6;
@@ -81,7 +97,7 @@ setClockFrequency(Tick ticksPerSecond)
     Float::Hz  = 1.0 / Float::s;
     Float::kHz = 1.0 / Float::ms;
     Float::MHz = 1.0 / Float::us;
-    Float::GHZ = 1.0 / Float::ns;
+    Float::GHz = 1.0 / Float::ns;
 
     Int::s  = Frequency;
     Int::ms = Int::s / 1000;
@@ -89,21 +105,25 @@ setClockFrequency(Tick ticksPerSecond)
     Int::ns = Int::us / 1000;
     Int::ps = Int::ns / 1000;
 
+    cprintf("Global frequency set at %d ticks per second\n", _ticksPerSecond);
+
+    _clockFrequencyFixed = true;
 }
+bool clockFrequencyFixed() { return _clockFrequencyFixed; }
 
 void
-setOutputDir(const string &dir)
+setClockFrequency(Tick tps)
 {
-    simout.setDirectory(dir);
+    panic_if(_clockFrequencyFixed,
+            "Global frequency already fixed at %f ticks/s.", _ticksPerSecond);
+    _ticksPerSecond = tps;
 }
-
-ostream *outputStream;
-ostream *configStream;
+Tick getClockFrequency() { return _ticksPerSecond; }
 
 void
-setOutputFile(const string &file)
+setOutputDir(const string &dir)
 {
-    outputStream = simout.find(file);
+    simout.setDirectory(dir);
 }
 
 /**
@@ -126,7 +146,7 @@ registerExitCallback(Callback *callback)
 }
 
 /**
- * Do C++ simulator exit processing.  Exported to SWIG to be invoked
+ * Do C++ simulator exit processing.  Exported to Python to be invoked
  * when simulator terminates via Python's atexit mechanism.
  */
 void