/*
* Copyright (c) 2013 ARM Limited
+ * Copyright (c) 2013 Cornell University
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* Authors: Vasileios Spiliopoulos
* Akash Bagdia
* Andreas Hansson
+ * Christopher Torng
*/
#include "debug/ClockDomain.hh"
#include "params/SrcClockDomain.hh"
#include "sim/clock_domain.hh"
#include "sim/voltage_domain.hh"
+#include "sim/clocked_object.hh"
double
ClockDomain::voltage() const
fatal("%s has a clock period of zero\n", name());
}
+ // Align all members to the current tick
+ for (auto m = members.begin(); m != members.end(); ++m) {
+ (*m)->updateClockPeriod();
+ }
+
_clockPeriod = clock_period;
DPRINTF(ClockDomain,
void
DerivedClockDomain::updateClockPeriod()
{
+ // Align all members to the current tick
+ for (auto m = members.begin(); m != members.end(); ++m) {
+ (*m)->updateClockPeriod();
+ }
+
// recalculate the clock period, relying on the fact that changes
// propagate downwards in the tree
_clockPeriod = parent.clockPeriod() * clockDivider;
/*
* Copyright (c) 2013 ARM Limited
+ * Copyright (c) 2013 Cornell University
* All rights reserved
*
* The license below extends only to copyright in the software and shall
*
* Authors: Vasileios Spiliopoulos
* Akash Bagdia
+ * Christopher Torng
*/
/**
#ifndef __SIM_CLOCK_DOMAIN_HH__
#define __SIM_CLOCK_DOMAIN_HH__
+#include <algorithm>
+
#include "base/statistics.hh"
#include "params/ClockDomain.hh"
#include "params/DerivedClockDomain.hh"
*/
class DerivedClockDomain;
class VoltageDomain;
+class ClockedObject;
/**
* The ClockDomain provides clock to group of clocked objects bundled
*/
std::vector<DerivedClockDomain*> children;
+ /**
+ * Pointers to members of this clock domain, so that when the clock
+ * period changes, we can update each member's tick.
+ */
+ std::vector<ClockedObject*> members;
+
public:
typedef ClockDomainParams Params;
*/
inline Tick clockPeriod() const { return _clockPeriod; }
+ /**
+ * Register a ClockedObject to this ClockDomain.
+ *
+ * @param ClockedObject to add as a member
+ */
+ void registerWithClockDomain(ClockedObject *c)
+ {
+ assert(c != NULL);
+ assert(std::find(members.begin(), members.end(), c) == members.end());
+ members.push_back(c);
+ }
+
/**
* Get the voltage domain.
*
*/
void clockPeriod(Tick clock_period);
+ // Explicitly import the otherwise hidden clockPeriod
+ using ClockDomain::clockPeriod;
};
/**
/*
* Copyright (c) 2012-2013 ARM Limited
+ * Copyright (c) 2013 Cornell University
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Andreas Hansson
+ * Christopher Torng
*/
/**
ClockedObject(const ClockedObjectParams* p) :
SimObject(p), tick(0), cycle(0), clockDomain(*p->clk_domain)
{
+ // Register with the clock domain, so that if the clock domain
+ // frequency changes, we can update this object's tick.
+ clockDomain.registerWithClockDomain(this);
}
/**
public:
+ /**
+ * Update the tick to the current tick.
+ *
+ */
+ inline void updateClockPeriod() const
+ {
+ update();
+ }
+
/**
* Determine the tick when a cycle begins, by default the current
* one, but the argument also enables the caller to determine a