diff --git a/DRAMSys/simulator/src/controller/scheduler/Fr_Fcfs_read_priority.cpp b/DRAMSys/simulator/src/controller/scheduler/Fr_Fcfs_read_priority.cpp index 92c07c63..57a5b7b3 100644 --- a/DRAMSys/simulator/src/controller/scheduler/Fr_Fcfs_read_priority.cpp +++ b/DRAMSys/simulator/src/controller/scheduler/Fr_Fcfs_read_priority.cpp @@ -49,8 +49,8 @@ std::pair FR_FCFS_RP::getNextRequest(Bank bank) // Order of Priority: // 1. Read Hits (Hazard Check) // 2. Write Hits - // 3. Read Miss (Hazard Check) TODO - // 4. Write Miss TODO + // 3. Read Miss (Hazard Check) + // 4. Write Miss // 1. Seach for read hit: for(auto it = buffer[bank].begin(); it!=buffer[bank].end(); it++) @@ -66,13 +66,14 @@ std::pair FR_FCFS_RP::getNextRequest(Bank bank) if(hazardDetection(bank, it) == false) { buffer[bank].erase(it); + printDebugMessage("Read Hit found"); return pair(getReadWriteCommand(*read),read); } } } } - // 2. Seach for write hit: + // 2. Search for write hit: for(auto it = buffer[bank].begin(); it!=buffer[bank].end(); it++) { gp* write = *it; @@ -84,14 +85,40 @@ std::pair FR_FCFS_RP::getNextRequest(Bank bank) == controllerCore.getRowBufferStates().getRowInRowBuffer(bank)) { buffer[bank].erase(it); + printDebugMessage("Write Hit found"); return pair(getReadWriteCommand(*write),write); } } } - // For now return the oldest request. TODO: do read first! - return pair(getNextCommand(buffer[bank].front()), - buffer[bank].front()); + // For now return the oldest request but prefere also reads before writes: + + // 3. Search for read miss: + for(auto it = buffer[bank].begin(); it!=buffer[bank].end(); it++) + { + gp* read = *it; + + if(read->get_command() == tlm::TLM_READ_COMMAND) + { + if(hazardDetection(bank, it) == false) + { + printDebugMessage("Read miss found"); + return pair(getNextCommand(read),read); + } + } + } + + // 3. Search for write miss: + for(auto it = buffer[bank].begin(); it!=buffer[bank].end(); it++) + { + gp* write = *it; + + if(write->get_command() == tlm::TLM_WRITE_COMMAND) + { + printDebugMessage("Write miss found"); + return pair(getNextCommand(write),write); + } + } reportFatal("FR_FCFS_RP", "Never should go here ..."); }