Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing the Delay Queue #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions IniReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ unsigned IDD6;
unsigned IDD6L;
unsigned IDD7;

// Delay Queue
unsigned int DQ_DEPTH;


//in bytes
unsigned JEDEC_DATA_BUS_BITS;
Expand Down Expand Up @@ -206,9 +209,30 @@ static ConfigMap configMap[] =
DEFINE_BOOL_PARAM(DEBUG_POWER,SYS_PARAM),
DEFINE_BOOL_PARAM(VIS_FILE_OUTPUT,SYS_PARAM),
DEFINE_BOOL_PARAM(VERIFICATION_OUTPUT,SYS_PARAM),
// Delay queue
// DEFINE_UINT_PARAM(DQ_DEPTH, SYS_PARAM),
{"DQ_DEPTH", &DQ_DEPTH, UINT, SYS_PARAM, true },
{"", NULL, UINT, SYS_PARAM, false} // tracer value to signify end of list; if you delete it, epic fail will result
};

IniReader::IniReader(void){
for (size_t i=0; configMap[i].variablePtr != NULL; i++)
{
switch (configMap[i].variableType)
{
case UINT:
case UINT64:
case FLOAT:
case BOOL:
*(unsigned *)configMap[i].variablePtr = 0;
break;
case STRING:
break;
}
}
}


void IniReader::WriteParams(std::ofstream &visDataOut, paramType type)
{
for (size_t i=0; configMap[i].variablePtr != NULL; i++)
Expand Down
1 change: 1 addition & 0 deletions IniReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef struct _configMap

class IniReader
{
IniReader(void);

public:
typedef std::map<string, string> OverrideMap;
Expand Down
40 changes: 37 additions & 3 deletions MultiChannelMemorySystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "AddressMapping.h"
#include "IniReader.h"

#include <queue>


using namespace DRAMSim;
Expand Down Expand Up @@ -388,6 +389,24 @@ void MultiChannelMemorySystem::actual_update()
}
csvOut->finalize();
}

// Delay Queue

vector<delayedInfo>::iterator it = delayedTransactions.begin();
while(it != delayedTransactions.end())
{
if ((*it).delayedTicks>0)
{
(*it).delayedTicks--;
it++;
}
else
{
struct delayedInfo t = *it;
addTransaction_delayed(t.isWrite, t.addr);
it = delayedTransactions.erase(it);
}
}

for (size_t i=0; i<NUM_CHANS; i++)
{
Expand All @@ -397,6 +416,7 @@ void MultiChannelMemorySystem::actual_update()

currentClockCycle++;
}

unsigned MultiChannelMemorySystem::findChannelNumber(uint64_t addr)
{
// Single channel case is a trivial shortcut case
Expand Down Expand Up @@ -425,10 +445,12 @@ unsigned MultiChannelMemorySystem::findChannelNumber(uint64_t addr)
return channelNumber;

}

ostream &MultiChannelMemorySystem::getLogFile()
{
return dramsim_log;
}

bool MultiChannelMemorySystem::addTransaction(const Transaction &trans)
{
// copy the transaction and send the pointer to the new transaction
Expand All @@ -443,8 +465,20 @@ bool MultiChannelMemorySystem::addTransaction(Transaction *trans)

bool MultiChannelMemorySystem::addTransaction(bool isWrite, uint64_t addr)
{
unsigned channelNumber = findChannelNumber(addr);
return channels[channelNumber]->addTransaction(isWrite, addr);
struct delayedInfo newTransaction = {addr, isWrite, DQ_DEPTH};
delayedTransactions.push_back(newTransaction);
return true;
}

void MultiChannelMemorySystem::addTransaction_delayed(bool isWrite, uint64_t addr)
{
unsigned channelNumber = findChannelNumber(addr);

if ( channels[channelNumber]->addTransaction(isWrite, addr) == false )
{
struct delayedInfo newTransaction = {addr, isWrite, 1};
delayedTransactions.push_back( newTransaction ) ;
}
}

/*
Expand Down Expand Up @@ -475,7 +509,6 @@ bool MultiChannelMemorySystem::willAcceptTransaction()
}



void MultiChannelMemorySystem::printStats(bool finalStats) {

(*csvOut) << "ms" <<currentClockCycle * tCK * 1E-6;
Expand All @@ -487,6 +520,7 @@ void MultiChannelMemorySystem::printStats(bool finalStats) {
}
csvOut->finalize();
}

void MultiChannelMemorySystem::RegisterCallbacks(
TransactionCompleteCB *readDone,
TransactionCompleteCB *writeDone,
Expand Down
13 changes: 12 additions & 1 deletion MultiChannelMemorySystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@
#include "ClockDomain.h"
#include "CSVWriter.h"

#include <vector>
#include <queue>

namespace DRAMSim {

struct delayedInfo{
uint64_t addr;
bool isWrite;
unsigned int delayedTicks;
};



class MultiChannelMemorySystem : public SimulatorObject
{
Expand All @@ -50,6 +59,7 @@ class MultiChannelMemorySystem : public SimulatorObject
bool addTransaction(bool isWrite, uint64_t addr);
bool willAcceptTransaction();
bool willAcceptTransaction(uint64_t addr);
void addTransaction_delayed(bool isWrite, uint64_t addr);
void update();
void printStats(bool finalStats=false);
ostream &getLogFile();
Expand All @@ -72,7 +82,8 @@ class MultiChannelMemorySystem : public SimulatorObject
private:
unsigned findChannelNumber(uint64_t addr);
void actual_update();
vector<MemorySystem*> channels;
vector<MemorySystem*> channels;
vector<delayedInfo> delayedTransactions;
unsigned megsOfMemory;
string deviceIniFilename;
string systemIniFilename;
Expand Down
2 changes: 2 additions & 0 deletions SystemConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ extern unsigned TRANSACTION_SIZE;
extern unsigned THROW_AWAY_BITS;
extern unsigned COL_LOW_BIT_WIDTH;

extern unsigned int DQ_DEPTH;

//in nanoseconds
extern unsigned REFRESH_PERIOD;
extern float tCK;
Expand Down