Add raw MPKC module for calculating MPKC rate

This commit is contained in:
Thanh C. Tran
2017-05-11 23:27:47 +02:00
parent 65c1abcc7a
commit ea8213da17

View File

@@ -0,0 +1,55 @@
/*
* MPKC.h
*
* Created on: May 11, 2017
* Author: thanhtran
*/
#ifndef MPKC_H_
#define MPKC_H_
#include "../../../common/Utils.h"
using namespace std;
class MPKC: public sc_module
{
public:
MPKC(sc_module_name /*_name*/, sc_time memClk) : memClk(memClk)
{
lastGeneratedRequests = std::make_pair(0, 0);
SC_THREAD(updateMPKC);
}
SC_HAS_PROCESS(MPKC);
void updateMPKC()
{
while(true)
{
mpkc = 1 / (lastGeneratedRequests.second + numClk*memClk -lastGeneratedRequests.first);
wait(memClk);
numClk++;
}
}
float getMPKC()
{
return mpkc;
}
void sendNewRequest(sc_time timeOfGeneration)
{
std::swap(lastGeneratedRequests.first, lastGeneratedRequests.second);
lastGeneratedRequests.second = timeOfGeneration;
numClk = 0;
}
private:
unsigned int numClk = 0;
sc_time memClk;
float mpkc = 0;
std::pair<sc_time, sc_time> lastGeneratedRequests;
};
#endif /* MPKC_H_ */