diff options
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/BaseCPU.py | 16 | ||||
-rw-r--r-- | src/cpu/base.hh | 24 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/cpu/BaseCPU.py b/src/cpu/BaseCPU.py index c27fd1c27..6e5f6ff1a 100644 --- a/src/cpu/BaseCPU.py +++ b/src/cpu/BaseCPU.py @@ -77,6 +77,22 @@ class BaseCPU(MemObject): type = 'BaseCPU' abstract = True + @classmethod + def export_method_cxx_predecls(cls, code): + code('#include "cpu/base.hh"') + + + @classmethod + def export_methods(cls, code): + code(''' + void switchOut(); + void takeOverFrom(BaseCPU *cpu); +''') + + def takeOverFrom(self, old_cpu): + self._ccObject.takeOverFrom(old_cpu._ccObject) + + system = Param.System(Parent.any, "system object") cpu_id = Param.Int(-1, "CPU identifier") numThreads = Param.Unsigned(1, "number of HW thread contexts") diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 82864ae7b..0c1d19856 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -278,13 +278,27 @@ class BaseCPU : public MemObject void registerThreadContexts(); - /// Prepare for another CPU to take over execution. When it is - /// is ready (drained pipe) it signals the sampler. + /** + * Prepare for another CPU to take over execution. + * + * When this method exits, all internal state should have been + * flushed. After the method returns, the simulator calls + * takeOverFrom() on the new CPU with this CPU as its parameter. + */ virtual void switchOut(); - /// Take over execution from the given CPU. Used for warm-up and - /// sampling. - virtual void takeOverFrom(BaseCPU *); + /** + * Load the state of a CPU from the previous CPU object, invoked + * on all new CPUs that are about to be switched in. + * + * A CPU model implementing this method is expected to initialize + * its state from the old CPU and connect its memory (unless they + * are already connected) to the memories connected to the old + * CPU. + * + * @param cpu CPU to initialize read state from. + */ + virtual void takeOverFrom(BaseCPU *cpu); /** * Number of threads we're actually simulating (<= SMT_MAX_THREADS). |