@@ -88,11 +88,16 @@ public:
|
||||
|
||||
~Controller()
|
||||
{
|
||||
delete controllerCore;
|
||||
delete controllerCore;
|
||||
delete scheduler;
|
||||
}
|
||||
|
||||
void terminateSimulation();
|
||||
|
||||
sc_time getIdleTime();
|
||||
sc_time getEndTime();
|
||||
sc_time getStartTime();
|
||||
|
||||
// ------- 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 +143,17 @@ private:
|
||||
|
||||
DebugManager& debugManager;
|
||||
TlmRecorder *tlmRecorder;
|
||||
|
||||
// Bandwidth realted:
|
||||
sc_time idleStart;
|
||||
bool idleState = false;
|
||||
sc_time idleTime;
|
||||
sc_time endTime;
|
||||
sc_time startTime;
|
||||
int startTimeSet = false;
|
||||
void startBandwidthIdleCollector();
|
||||
void endBandwidthIdleCollector();
|
||||
|
||||
};
|
||||
|
||||
// --- IMPLEMENTATION -----
|
||||
@@ -353,6 +369,11 @@ tlm_sync_enum Controller<BUSWIDTH>::nb_transport_fw(tlm_generic_payload &payload
|
||||
|
||||
tlmRecorder->recordPhase(payload, phase, recTime);
|
||||
frontendPEQ.notify(payload, phase, notDelay);
|
||||
|
||||
//Bandwidth IDLE
|
||||
if ((getTotalNumberOfPayloadsInSystem()== 0)&& idleState){
|
||||
endBandwidthIdleCollector();
|
||||
}
|
||||
}
|
||||
else if (phase == END_RESP)
|
||||
{
|
||||
@@ -361,6 +382,11 @@ tlm_sync_enum Controller<BUSWIDTH>::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){
|
||||
startBandwidthIdleCollector();
|
||||
}
|
||||
|
||||
tlmRecorder->recordPhase(payload, phase, recTime);
|
||||
frontendPEQ.notify(payload, phase, notDelay);
|
||||
}
|
||||
@@ -378,6 +404,7 @@ void Controller<BUSWIDTH>::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)
|
||||
@@ -422,6 +449,12 @@ void Controller<BUSWIDTH>::payloadEntersSystem(tlm_generic_payload &payload)
|
||||
"Payload enters system on bank " + to_string(bank.ID()) + ". Total number of payloads in Controller: "
|
||||
+ to_string(getTotalNumberOfPayloadsInSystem()));
|
||||
numberOfPayloadsInSystem[bank]++;
|
||||
// Set Start Time for Simulation
|
||||
if (startTimeSet == false){
|
||||
printDebugMessage("Simulation Timer Start");
|
||||
startTime = sc_time_stamp()-Configuration::getInstance().memSpec.clk;
|
||||
startTimeSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
template<unsigned int BUSWIDTH>
|
||||
@@ -454,7 +487,7 @@ void Controller<BUSWIDTH>::scheduleNextFromScheduler(Bank bank)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pair<Command, tlm::tlm_generic_payload*> nextRequest = scheduler->getNextRequest(bank);
|
||||
if(nextRequest.second != NULL)
|
||||
{
|
||||
@@ -598,5 +631,36 @@ void Controller<BUSWIDTH>::terminateSimulation()
|
||||
}
|
||||
}
|
||||
|
||||
template<unsigned int BUSWIDTH>
|
||||
void Controller<BUSWIDTH>::startBandwidthIdleCollector(){
|
||||
printDebugMessage("IDLE Start");
|
||||
idleStart = sc_time_stamp();
|
||||
endTime = sc_time_stamp();
|
||||
idleState = true;
|
||||
}
|
||||
|
||||
template<unsigned int BUSWIDTH>
|
||||
void Controller<BUSWIDTH>::endBandwidthIdleCollector(){
|
||||
printDebugMessage("IDLE End");
|
||||
idleTime += sc_time_stamp()-idleStart+ Configuration::getInstance().memSpec.clk;
|
||||
idleState = false;
|
||||
}
|
||||
template<unsigned int BUSWIDTH>
|
||||
sc_time Controller<BUSWIDTH>::getIdleTime(){
|
||||
printDebugMessage("IDLE Time: "+idleTime.to_string());
|
||||
return idleTime;
|
||||
}
|
||||
template<unsigned int BUSWIDTH>
|
||||
sc_time Controller<BUSWIDTH>::getEndTime(){
|
||||
printDebugMessage("End Time: "+endTime.to_string());
|
||||
return endTime;
|
||||
}
|
||||
template<unsigned int BUSWIDTH>
|
||||
sc_time Controller<BUSWIDTH>::getStartTime(){
|
||||
printDebugMessage("Start Time: "+startTime.to_string());
|
||||
return startTime;
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONTROLLERWRAPPER_H_ */
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <cassert>
|
||||
#include "../common/DebugManager.h"
|
||||
#include "../common/dramExtension.h"
|
||||
#include "../controller/Controller.h"
|
||||
#include "../controller/core/TimingCalculation.h"
|
||||
#include "../controller/core/configuration/Configuration.h"
|
||||
#include "../common/protocol.h"
|
||||
@@ -74,7 +75,7 @@ struct Dram : sc_module
|
||||
libDRAMPower *DRAMPower;
|
||||
double sumOfEnergyWindows = 0.0;
|
||||
|
||||
// Bandwith realted:
|
||||
// Bandwidth realted:
|
||||
unsigned long long int numberOfTransactionsServed;
|
||||
sc_time firstAccess;
|
||||
sc_time lastAccess;
|
||||
@@ -87,6 +88,7 @@ struct Dram : sc_module
|
||||
map< unsigned long int, std::array<unsigned char, BUSWIDTH/2> > memory;
|
||||
|
||||
TlmRecorder *tlmRecorder;
|
||||
Controller<>* dramController;
|
||||
|
||||
SC_CTOR(Dram) : tSocket("socket")
|
||||
{
|
||||
@@ -214,17 +216,26 @@ struct Dram : sc_module
|
||||
double averagePower = (totalEnergy / sc_time_stamp().to_seconds()) / 1e9;
|
||||
|
||||
// Print the final total energy and the average power for the simulation
|
||||
cout << name() << string("\tTotal Energy: \t") + to_string(totalEnergy) + string("\t[pJ]") << endl;
|
||||
cout << name() << string("\tAverage Power: \t") + to_string(averagePower) + string("\t[mW]") << endl;
|
||||
cout << name() << string("\tTotal Energy: \t") << fixed <<std::setprecision( 2 )<< totalEnergy << string(" pJ") << endl;
|
||||
cout << name() << string("\tAverage Power: \t") << fixed <<std::setprecision( 2 )<< averagePower<< string(" mW") << endl;
|
||||
}
|
||||
|
||||
// Bandwidth:
|
||||
|
||||
sc_time activeTime = numberOfTransactionsServed * Configuration::getInstance().memSpec.BurstLength / Configuration::getInstance().memSpec.DataRate * Configuration::getInstance().memSpec.clk;
|
||||
double bandwidth = (activeTime/(lastAccess-firstAccess)*100);
|
||||
|
||||
cout << name() << string("\tTotal Bandwidth: \t") + to_string(bandwidth) << " %" << endl;
|
||||
cout << name() << string("\tTotal Bandwidth/IDLE: \tTODO %") << endl;
|
||||
|
||||
sc_time idleTime = dramController->getIdleTime();
|
||||
sc_time endTime = dramController->getEndTime();
|
||||
sc_time startTime = dramController->getStartTime();
|
||||
double bandwidth = (activeTime/(endTime-startTime)*100);
|
||||
double bandwidth_IDLE = ((activeTime)/(endTime-startTime-idleTime)*100);
|
||||
// | clk in Mhz e.g. 800 [MHz] | * | DataRate e.g. 2 | * | BusWidth e.g. 8 | / | 1024 |
|
||||
double maxBandwidth = ( (1000000/Configuration::getInstance().memSpec.clk.to_double()) * Configuration::getInstance().memSpec.DataRate * Configuration::getInstance().memSpec.BusWidth ) / ( 1024 );
|
||||
cout << name() << string("\tTotal Time: \t") <<(endTime-startTime).to_string() << endl;
|
||||
//cout << name() << string("\tTotal IDLE: \t") <<idleTime.to_string() << endl;
|
||||
//cout << name() << string("\tTotal Active DataBus: \t") << activeTime.to_string() << endl;
|
||||
cout << name() << string("\tAVG BW: \t") <<std::fixed<<std::setprecision(2) << ((bandwidth/100)*maxBandwidth) << " GiB/s (" << bandwidth << " %)" << endl;
|
||||
cout << name() << string("\tAVG BW/IDLE: \t") <<std::fixed<<std::setprecision(2) << ((bandwidth_IDLE/100)*maxBandwidth) <<" GiB/s ("<< (bandwidth_IDLE) << " %)" << endl;
|
||||
cout << name() << string("\tMAX BW: \t") <<std::fixed<<std::setprecision(2) <<maxBandwidth << " GiB/s" << endl;
|
||||
// Clean up:
|
||||
for (auto e : ememory) {
|
||||
delete e;
|
||||
@@ -567,6 +578,10 @@ struct Dram : sc_module
|
||||
{
|
||||
tlmRecorder = rec;
|
||||
}
|
||||
void setDramController(Controller<> *contr)
|
||||
{
|
||||
dramController = contr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* DRAM_H_ */
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "../common/Utils.h"
|
||||
#include "../simulation/StlDataPlayer.h"
|
||||
#include "../simulation/TemperatureController.h"
|
||||
#include "../controller/Controller.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -144,6 +145,7 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT
|
||||
str = "dram" + std::to_string(i);
|
||||
Dram<> *dram = new Dram<>(str.c_str());
|
||||
dram->setTlmRecorder(tlmRecorders[i]);
|
||||
dram->setDramController(controllers[i]);
|
||||
drams.push_back(dram);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user