diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-08-07 09:59:22 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-08-07 09:59:22 +0100 |
commit | f7ff27afe8610460e88b7032391d679a3b8920f4 (patch) | |
tree | fd0ed94e531e2946aeb1ad0eb3f818d40f3962bc /src/sim/clocked_object.hh | |
parent | 9b2426ecfc4f004fe77badb4cc64f93af3a2d0d3 (diff) | |
download | gem5-f7ff27afe8610460e88b7032391d679a3b8920f4.tar.xz |
sim: Split ClockedObject to make it usable to non-SimObjects
Split ClockedObject into two classes: Clocked that provides the basic
clock functionality, and ClockedObject that inherits from Clocked and
SimObject to provide the functionality of the old ClockedObject.
Diffstat (limited to 'src/sim/clocked_object.hh')
-rw-r--r-- | src/sim/clocked_object.hh | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/sim/clocked_object.hh b/src/sim/clocked_object.hh index d878f4704..e064d7a32 100644 --- a/src/sim/clocked_object.hh +++ b/src/sim/clocked_object.hh @@ -55,14 +55,14 @@ #include "sim/sim_object.hh" /** - * The ClockedObject class extends the SimObject with a clock and - * accessor functions to relate ticks to the cycles of the object. + * Helper class for objects that need to be clocked. Clocked objects + * typically inherit from this class. Objects that need SimObject + * functionality as well should inherit from ClockedObject. */ -class ClockedObject : public SimObject +class Clocked { private: - // the tick value of the next clock edge (>= curTick()) at the // time of the last call to update() mutable Tick tick; @@ -72,13 +72,6 @@ class ClockedObject : public SimObject mutable Cycles cycle; /** - * Prevent inadvertent use of the copy constructor and assignment - * operator by making them private. - */ - ClockedObject(ClockedObject&); - ClockedObject& operator=(ClockedObject&); - - /** * Align cycle and tick to the next clock edge if not already done. When * complete, tick must be at least curTick(). */ @@ -118,18 +111,21 @@ class ClockedObject : public SimObject * Create a clocked object and set the clock domain based on the * parameters. */ - ClockedObject(const ClockedObjectParams* p) : - SimObject(p), tick(0), cycle(0), clockDomain(*p->clk_domain) + Clocked(ClockDomain &clk_domain) + : tick(0), cycle(0), clockDomain(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); } + Clocked(Clocked &) = delete; + Clocked &operator=(Clocked &) = delete; + /** * Virtual destructor due to inheritance. */ - virtual ~ClockedObject() { } + virtual ~Clocked() { } /** * Reset the object's clock using the current global tick value. Likely @@ -221,4 +217,16 @@ class ClockedObject : public SimObject }; +/** + * The ClockedObject class extends the SimObject with a clock and + * accessor functions to relate ticks to the cycles of the object. + */ +class ClockedObject + : public SimObject, public Clocked +{ + public: + ClockedObject(const ClockedObjectParams *p) + : SimObject(p), Clocked(*p->clk_domain) { } +}; + #endif //__SIM_CLOCKED_OBJECT_HH__ |