summaryrefslogtreecommitdiff
path: root/src/sim/clocked_object.hh
diff options
context:
space:
mode:
authorAkash Bagdia <akash.bagdia@arm.com>2013-06-27 05:49:49 -0400
committerAkash Bagdia <akash.bagdia@arm.com>2013-06-27 05:49:49 -0400
commit7d7ab738622e7969a7db85ff970e406c950b2576 (patch)
tree805e31d199b63e10eeb2017e880699ae3953f4e5 /src/sim/clocked_object.hh
parent4de3205afaac1fd11876b33675aa6f49c9632764 (diff)
downloadgem5-7d7ab738622e7969a7db85ff970e406c950b2576.tar.xz
sim: Add the notion of clock domains to all ClockedObjects
This patch adds the notion of source- and derived-clock domains to the ClockedObjects. As such, all clock information is moved to the clock domain, and the ClockedObjects are grouped into domains. The clock domains are either source domains, with a specific clock period, or derived domains that have a parent domain and a divider (potentially chained). For piece of logic that runs at a derived clock (a ratio of the clock its parent is running at) the necessary derived clock domain is created from its corresponding parent clock domain. For now, the derived clock domain only supports a divider, thus ensuring a lower speed compared to its parent. Multiplier functionality implies a PLL logic that has not been modelled yet (create a separate clock instead). The clock domains should be used as a mechanism to provide a controllable clock source that affects clock for every clocked object lying beneath it. The clock of the domain can (in a future patch) be controlled by a handler responsible for dynamic frequency scaling of the respective clock domains. All the config scripts have been retro-fitted with clock domains. For the System a default SrcClockDomain is created. For CPUs that run at a different speed than the system, there is a seperate clock domain created. This domain incorporates the CPU and the associated caches. As before, Ruby runs under its own clock domain. The clock period of all domains are pre-computed, such that no virtual functions or multiplications are needed when calling clockPeriod. Instead, the clock period is pre-computed when any changes occur. For this to be possible, each clock domain tracks its children.
Diffstat (limited to 'src/sim/clocked_object.hh')
-rw-r--r--src/sim/clocked_object.hh40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/sim/clocked_object.hh b/src/sim/clocked_object.hh
index d836c48cc..c959c5c04 100644
--- a/src/sim/clocked_object.hh
+++ b/src/sim/clocked_object.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012-2013 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -49,6 +49,7 @@
#include "base/misc.hh"
#include "params/ClockedObject.hh"
#include "sim/core.hh"
+#include "sim/clock_domain.hh"
#include "sim/sim_object.hh"
/**
@@ -88,7 +89,7 @@ class ClockedObject : public SimObject
// optimise for the common case and see if the tick should be
// advanced by a single clock period
- tick += clock;
+ tick += clockPeriod();
++cycle;
// see if we are done at this point
@@ -98,26 +99,25 @@ class ClockedObject : public SimObject
// if not, we have to recalculate the cycle and tick, we
// perform the calculations in terms of relative cycles to
// allow changes to the clock period in the future
- Cycles elapsedCycles(divCeil(curTick() - tick, clock));
+ Cycles elapsedCycles(divCeil(curTick() - tick, clockPeriod()));
cycle += elapsedCycles;
- tick += elapsedCycles * clock;
+ tick += elapsedCycles * clockPeriod();
}
- // Clock period in ticks
- Tick clock;
+ /**
+ * The clock domain this clocked object belongs to
+ */
+ ClockDomain &clockDomain;
protected:
/**
- * Create a clocked object and set the clock based on the
+ * Create a clocked object and set the clock domain based on the
* parameters.
*/
ClockedObject(const ClockedObjectParams* p) :
- SimObject(p), tick(0), cycle(0), clock(p->clock)
+ SimObject(p), tick(0), cycle(0), clockDomain(*p->clk_domain)
{
- if (clock == 0) {
- fatal("%s has a clock period of zero\n", name());
- }
}
/**
@@ -132,9 +132,9 @@ class ClockedObject : public SimObject
*/
void resetClock() const
{
- Cycles elapsedCycles(divCeil(curTick(), clock));
+ Cycles elapsedCycles(divCeil(curTick(), clockPeriod()));
cycle = elapsedCycles;
- tick = elapsedCycles * clock;
+ tick = elapsedCycles * clockPeriod();
}
public:
@@ -154,7 +154,7 @@ class ClockedObject : public SimObject
update();
// figure out when this future cycle is
- return tick + clock * cycles;
+ return tick + clockPeriod() * cycles;
}
/**
@@ -181,12 +181,18 @@ class ClockedObject : public SimObject
Tick nextCycle() const
{ return clockEdge(Cycles(1)); }
- inline uint64_t frequency() const { return SimClock::Frequency / clock; }
+ inline uint64_t frequency() const
+ {
+ return SimClock::Frequency / clockPeriod();
+ }
- inline Tick clockPeriod() const { return clock; }
+ inline Tick clockPeriod() const
+ {
+ return clockDomain.clockPeriod();
+ }
inline Cycles ticksToCycles(Tick t) const
- { return Cycles(t / clock); }
+ { return Cycles(t / clockPeriod()); }
};