From b4b03a60b170362aa0ae9dcfd224ed4fbce69683 Mon Sep 17 00:00:00 2001 From: Christopher Torng Date: Sun, 29 Dec 2013 19:29:45 -0600 Subject: sim: Add support for dynamic frequency scaling This patch provides support for DFS by having ClockedObjects register themselves with their clock domain at construction time in a member list. Using this list, a clock domain can update each member's tick to the curTick() before modifying the clock period. Committed by: Nilay Vaish --- src/sim/clock_domain.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/sim/clock_domain.cc') diff --git a/src/sim/clock_domain.cc b/src/sim/clock_domain.cc index 8b563d598..ff96f2808 100644 --- a/src/sim/clock_domain.cc +++ b/src/sim/clock_domain.cc @@ -1,5 +1,6 @@ /* * 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 @@ -37,6 +38,7 @@ * Authors: Vasileios Spiliopoulos * Akash Bagdia * Andreas Hansson + * Christopher Torng */ #include "debug/ClockDomain.hh" @@ -45,6 +47,7 @@ #include "params/SrcClockDomain.hh" #include "sim/clock_domain.hh" #include "sim/voltage_domain.hh" +#include "sim/clocked_object.hh" double ClockDomain::voltage() const @@ -65,6 +68,11 @@ SrcClockDomain::clockPeriod(Tick clock_period) 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, @@ -105,6 +113,11 @@ DerivedClockDomain::DerivedClockDomain(const Params *p) : 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; -- cgit v1.2.3