Implement ReadyBatch class

# Explain what has been changed

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
This commit is contained in:
Thanh C. Tran
2017-02-23 22:35:09 +01:00
parent 42b1c96afd
commit 413916f402
2 changed files with 45 additions and 1 deletions

View File

@@ -1 +1,43 @@
#include "ReadyBatch.h"
ReadyBatch::ReadyBatch()
{
fifosize = Configuration::getInstance().ReadyBatchSize;
thresholdAge(Configuration::getInstance().ReadyBatchThresholdAge, SC_NS);
}
unsigned int ReadyBatch::getNumRequests()
{
return readybatch.size();
}
Row ReadyBatch::getRow()
{
return DramExtension::getExtension(readybatch.front()).getRow();
}
sc_time ReadyBatch::getTimeOfOldestRequest()
{
sc_time oldestTime = sc_time_stamp();
for (auto reqPayload = readybatch.begin(); reqPayload != readybatch.end(); reqPayload++)
{
sc_time requestTimeOfGeneration = GenerationExtension::getExtension(*reqPayload).TimeOfGeneration();
if (requestTimeOfGeneration < oldestTime)
{
oldestTime = requestTimeOfGeneration;
}
}
return oldestTime;
}
bool ReadyBatch::addTransaction(gp* payload)
{
sc_time currentAge = sc_time_stamp() - getTimeOfOldestRequest();
Row newRow = DramExtension::getExtension(payload).getRow();
if (getNumRequests == fifosize || currentAge >= thresholdAge || newRow != getRow()) {
return false;
} else {
readybatch.emplace_back(payload);
return true;
}
}

View File

@@ -3,6 +3,7 @@
#include "tlm.h"
#include "../../common/dramExtension.h"
#include "../core/configuration/Configuration.h"
typedef tlm::tlm_generic_payload gp;
@@ -11,11 +12,12 @@ using namespace std;
class ReadyBatch
{
public:
ReadyBatch(unsigned int fifosize) : fifosize(fifosize){}
ReadyBatch();
bool addTransaction(gp* payload);
private:
std::deque<gp*> readybatch;
unsigned int fifosize;
sc_time thresholdAge;
Row getRow();
sc_time getTimeOfOldestRequest();