summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
Diffstat (limited to 'sim')
-rw-r--r--sim/stat_control.cc2
-rw-r--r--sim/syscall_emul.hh4
-rw-r--r--sim/universe.cc69
3 files changed, 56 insertions, 19 deletions
diff --git a/sim/stat_control.cc b/sim/stat_control.cc
index 8a8eaa790..4d72ce213 100644
--- a/sim/stat_control.cc
+++ b/sim/stat_control.cc
@@ -105,7 +105,7 @@ InitSimStats()
;
simFreq
- .scalar(ticksPerSecond)
+ .scalar(Clock::Frequency)
.name("sim_freq")
.desc("Frequency of simulated ticks")
;
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh
index 69c17c330..cc1692bfb 100644
--- a/sim/syscall_emul.hh
+++ b/sim/syscall_emul.hh
@@ -222,9 +222,7 @@ template <class T1, class T2>
void
getElapsedTime(T1 &sec, T2 &usec)
{
- int cycles_per_usec = ticksPerSecond / one_million;
-
- int elapsed_usecs = curTick / cycles_per_usec;
+ int elapsed_usecs = curTick / Clock::Int::us;
sec = elapsed_usecs / one_million;
usec = elapsed_usecs % one_million;
}
diff --git a/sim/universe.cc b/sim/universe.cc
index 9137baaf0..8419e1fe4 100644
--- a/sim/universe.cc
+++ b/sim/universe.cc
@@ -42,16 +42,41 @@
using namespace std;
Tick curTick = 0;
-Tick ticksPerSecond;
-double __ticksPerMS;
-double __ticksPerUS;
-double __ticksPerNS;
-double __ticksPerPS;
-
bool fullSystem;
ostream *outputStream;
ostream *configStream;
+/// The simulated frequency of curTick. (This is only here for a short time)
+Tick ticksPerSecond;
+
+namespace Clock {
+/// The simulated frequency of curTick. (In ticks per second)
+Tick Frequency;
+
+namespace Float {
+double s;
+double ms;
+double us;
+double ns;
+double ps;
+
+double Hz;
+double kHz;
+double MHz;
+double GHZ;
+/* namespace Float */ }
+
+namespace Int {
+Tick s;
+Tick ms;
+Tick us;
+Tick ns;
+Tick ps;
+/* namespace Float */ }
+
+/* namespace Clock */ }
+
+
// Dummy Object
class Root : public SimObject
{
@@ -92,17 +117,31 @@ CREATE_SIM_OBJECT(Root)
panic("FULL_SYSTEM not compiled but configuration is full_system");
#endif
- ticksPerSecond = frequency;
- double freq = double(ticksPerSecond);
- __ticksPerMS = freq / 1.0e3;
- __ticksPerUS = freq / 1.0e6;
- __ticksPerNS = freq / 1.0e9;
- __ticksPerPS = freq / 1.0e12;
-
outputStream = simout.find(output_file);
+ Root *root = new Root(getInstanceName());
- return new Root(getInstanceName());
+ ticksPerSecond = frequency;
+
+ using namespace Clock;
+ Frequency = frequency;
+ Float::s = static_cast<double>(Frequency);
+ Float::ms = Float::s / 1.0e3;
+ Float::us = Float::s / 1.0e6;
+ Float::ns = Float::s / 1.0e9;
+ Float::ps = Float::s / 1.0e12;
+
+ Float::Hz = 1.0 / Float::s;
+ Float::kHz = 1.0 / Float::ms;
+ Float::MHz = 1.0 / Float::us;
+ Float::GHZ = 1.0 / Float::ns;
+
+ Int::s = Frequency;
+ Int::ms = Int::s / 1000;
+ Int::us = Int::ms / 1000;
+ Int::ns = Int::us / 1000;
+ Int::ps = Int::ns / 1000;
+
+ return root;
}
REGISTER_SIM_OBJECT("Root", Root)
-