diff --git a/DRAMSys/simulator/src/controller/Controller.h b/DRAMSys/simulator/src/controller/Controller.h index 38a8142e..ae0fccb0 100644 --- a/DRAMSys/simulator/src/controller/Controller.h +++ b/DRAMSys/simulator/src/controller/Controller.h @@ -88,11 +88,14 @@ public: ~Controller() { - delete controllerCore; + delete controllerCore; delete scheduler; } void terminateSimulation(); + + sc_time getIdleTime(); + // ------- CONTROLLER CORE --------- virtual void send(const ScheduledCommand& command, tlm_generic_payload& payload) override; virtual void send(Trigger trigger, sc_time time, tlm_generic_payload& payload) override; @@ -138,6 +141,14 @@ private: DebugManager& debugManager; TlmRecorder *tlmRecorder; + + // Bandwith realted: + sc_time idleStart; + bool idleState = false; + sc_time idleTime; + void startBandwithIdleCollector(); + void endBandwithIdleCollector(); + }; // --- IMPLEMENTATION ----- @@ -353,6 +364,11 @@ tlm_sync_enum Controller::nb_transport_fw(tlm_generic_payload &payload tlmRecorder->recordPhase(payload, phase, recTime); frontendPEQ.notify(payload, phase, notDelay); + + //Bandwith IDLE + if ((getTotalNumberOfPayloadsInSystem()== 0)&& idleState){ + endBandwithIdleCollector(); + } } else if (phase == END_RESP) { @@ -361,6 +377,11 @@ tlm_sync_enum Controller::nb_transport_fw(tlm_generic_payload &payload printDebugMessage("[fw] Recording " + phaseNameToString(phase) + " at " + recTime.to_string() + " notification in " + notDelay.to_string()); + // Badnwith IDLE + if (getTotalNumberOfPayloadsInSystem()==1){ + startBandwithIdleCollector(); + } + tlmRecorder->recordPhase(payload, phase, recTime); frontendPEQ.notify(payload, phase, notDelay); } @@ -378,6 +399,7 @@ void Controller::frontendPEQCallback(tlm_generic_payload &payload, con { if (phase == BEGIN_REQ) { + printDebugMessage(string("Payload in system: ") + to_string(getTotalNumberOfPayloadsInSystem())); payload.acquire(); payloadEntersSystem(payload); if (getTotalNumberOfPayloadsInSystem() > controllerCore->config.MaxNrOfTransactions) @@ -454,7 +476,7 @@ void Controller::scheduleNextFromScheduler(Bank bank) { return; } - + pair nextRequest = scheduler->getNextRequest(bank); if(nextRequest.second != NULL) { @@ -598,5 +620,25 @@ void Controller::terminateSimulation() } } +template +void Controller::startBandwithIdleCollector(){ + printDebugMessage("IDLE Start"); + printDebugMessage("IDLE Time: "+idleTime.to_string()); + idleStart = sc_time_stamp(); + idleState = true; +} + +template +void Controller::endBandwithIdleCollector(){ + printDebugMessage("IDLE End"); + idleTime += sc_time_stamp()-idleStart; + idleState = false; +} +template +sc_time Controller::getIdleTime(){ + printDebugMessage("IDLE Time: "+idleTime.to_string()); + return idleTime; +} + #endif /* CONTROLLERWRAPPER_H_ */