Changed interface of scheduler, small bugfix (wrong debug message in Controller).

This commit is contained in:
Lukas Steiner (2)
2019-07-29 11:05:03 +02:00
parent dbcdf3f61d
commit de650810dd
9 changed files with 35 additions and 16 deletions

View File

@@ -65,7 +65,7 @@ void DebugManager::openDebugFile(string filename)
}
DebugManager::DebugManager() :
writeToConsole(true), writeToFile(true)
writeToConsole(false), writeToFile(false)
{
}

View File

@@ -27,7 +27,7 @@ sc_time BankMachine::startBankMachine()
{
if (currentPayload == nullptr)
{
currentPayload = scheduler->getNextRequest(bank, currentState, currentRow);
currentPayload = scheduler->getNextRequest(bank, this);
if (currentPayload == nullptr)
return SC_ZERO_TIME;
}
@@ -90,3 +90,13 @@ void BankMachine::updateState(Command command)
else
SC_REPORT_FATAL("BankMachine", "Unknown phase");
}
Row BankMachine::getOpenRow()
{
return currentRow;
}
BmState BankMachine::getState()
{
return currentState;
}

View File

@@ -33,6 +33,10 @@ public:
sc_time startBankMachine();
std::pair<Command, tlm_generic_payload *> getNextCommand();
void updateState(Command);
Row getOpenRow();
BmState getState();
private:
tlm_generic_payload *currentPayload = nullptr;
BmState currentState = BmState::Precharged;

View File

@@ -21,13 +21,13 @@ ControllerNew::ControllerNew(sc_module_name name, TlmRecorder *tlmRecorder) :
state = new ControllerState("Controller", &Configuration::getInstance());
checker = new CheckerDDR3New(Configuration::getInstance(), *state);
scheduler = new SchedulerFifo();
scheduler = new SchedulerFrFcfs();
for (unsigned bankID = 0; bankID < Configuration::getInstance().memSpec->NumberOfBanks; bankID++)
{
bankMachines[Bank(bankID)] = new BankMachine(scheduler, checker, Bank(bankID));
commandFinishedTime[Bank(bankID)] = SC_ZERO_TIME;
}
commandMux = new CmdMuxStrict();
commandMux = new CmdMuxOldest();
}
ControllerNew::~ControllerNew()
@@ -134,11 +134,13 @@ void ControllerNew::controllerMethod()
releasePayload();
// (2) Accept new request from arbiter
if (sc_time_stamp() >= timeToAcquire && payloadToAcquire != nullptr
&& numberOfPayloads < Configuration::getInstance().MaxNrOfTransactions)
acquirePayload();
else
printDebugMessage("Total number of payloads exceeded, backpressure!");
if (sc_time_stamp() >= timeToAcquire && payloadToAcquire != nullptr)
{
if (numberOfPayloads < Configuration::getInstance().MaxNrOfTransactions)
acquirePayload();
else
printDebugMessage("Total number of payloads exceeded, backpressure!");
}
// (3) Update states of bank machines and get results if ready
for (auto it : bankMachines)

View File

@@ -6,7 +6,7 @@ void SchedulerFifo::storeRequest(tlm_generic_payload *payload)
buffer[bank].push(payload);
}
tlm_generic_payload *SchedulerFifo::getNextRequest(Bank bank, BmState, Row)
tlm_generic_payload *SchedulerFifo::getNextRequest(Bank bank, BankMachine *)
{
if (!buffer[bank].empty())
{

View File

@@ -14,7 +14,7 @@ class SchedulerFifo : public SchedulerIF
{
public:
void storeRequest(tlm_generic_payload *);
tlm_generic_payload *getNextRequest(Bank, BmState, Row);
tlm_generic_payload *getNextRequest(Bank, BankMachine *);
private:
std::map<Bank, std::queue<tlm_generic_payload *>> buffer;
};

View File

@@ -7,19 +7,21 @@ void SchedulerFrFcfs::storeRequest(tlm_generic_payload *payload)
buffer[bank].push_back(payload);
}
tlm_generic_payload *SchedulerFrFcfs::getNextRequest(Bank bank, BmState state, Row openRow)
tlm_generic_payload *SchedulerFrFcfs::getNextRequest(Bank bank, BankMachine *bankMachine)
{
if (!buffer[bank].empty())
{
if (state == BmState::Precharged)
BmState currentState = bankMachine->getState();
if (currentState == BmState::Precharged)
{
tlm_generic_payload *result = buffer[bank].front();
buffer[bank].erase(buffer[bank].begin());
return result;
}
else if (state == BmState::Activated)
else if (currentState == BmState::Activated)
{
// Search for row hit
Row openRow = bankMachine->getOpenRow();
for (auto it = buffer[bank].begin(); it != buffer[bank].end(); it++)
{
if (DramExtension::getRow(*it) == openRow)

View File

@@ -14,7 +14,7 @@ class SchedulerFrFcfs : public SchedulerIF
{
public:
void storeRequest(tlm_generic_payload *);
tlm_generic_payload *getNextRequest(Bank, BmState, Row);
tlm_generic_payload *getNextRequest(Bank, BankMachine *);
private:
std::map<Bank, std::vector<tlm_generic_payload *>> buffer;
};

View File

@@ -9,13 +9,14 @@
using namespace tlm;
enum class BmState;
class BankMachine;
class SchedulerIF
{
public:
virtual ~SchedulerIF() {}
virtual void storeRequest(tlm_generic_payload *) = 0;
virtual tlm_generic_payload *getNextRequest(Bank, BmState, Row) = 0;
virtual tlm_generic_payload *getNextRequest(Bank, BankMachine *) = 0;
protected:
void printDebugMessage(std::string message)
{