Add support for non-integer command lengths in simulator and TraceAnalyzer

This commit is contained in:
2022-04-20 12:29:28 +02:00
parent a3b0738364
commit 3e9b2bd329
7 changed files with 77 additions and 64 deletions

View File

@@ -390,8 +390,7 @@ void TlmRecorder::insertCommandLengths()
auto commandName = command.toString();
sqlite3_bind_text(insertCommandLengthsStatement, 1, commandName.c_str(), commandName.length(), nullptr);
sqlite3_bind_int(insertCommandLengthsStatement, 2,
static_cast<int>(lround(memSpec.getCommandLength(command) / memSpec.tCK)));
sqlite3_bind_double(insertCommandLengthsStatement, 2, memSpec.getCommandLengthInCylcles(command));
executeSqlStatement(insertCommandLengthsStatement);
};

View File

@@ -199,7 +199,7 @@ private:
" \n"
"CREATE TABLE CommandLengths( \n"
" Command TEXT, \n"
" Length INTEGER \n"
" Length DOUBLE \n"
"); \n"
" \n"
"CREATE TABLE Power( \n"

View File

@@ -74,7 +74,7 @@ MemSpec::MemSpec(const DRAMSysConfiguration::MemSpec &memSpec,
burstDuration(tCK * (static_cast<double>(defaultBurstLength) / dataRate)),
memorySizeBytes(0)
{
commandLengthInCycles = std::vector<unsigned>(Command::numberOfCommands(), 1);
commandLengthInCycles = std::vector<double>(Command::numberOfCommands(), 1);
}
sc_time MemSpec::getCommandLength(Command command) const
@@ -82,6 +82,11 @@ sc_time MemSpec::getCommandLength(Command command) const
return tCK * commandLengthInCycles[command];
}
double MemSpec::getCommandLengthInCylcles(Command command) const
{
return commandLengthInCycles[command];
}
uint64_t MemSpec::getSimMemSizeInBytes() const
{
return memorySizeBytes;

View File

@@ -96,6 +96,7 @@ public:
virtual TimeInterval getIntervalOnDataStrobe(Command command, const tlm::tlm_generic_payload &payload) const = 0;
sc_core::sc_time getCommandLength(Command) const;
double getCommandLengthInCylcles(Command) const;
uint64_t getSimMemSizeInBytes() const;
protected:
@@ -108,7 +109,7 @@ protected:
unsigned devicesPerRank);
// Command lengths in cycles on bus, usually one clock cycle
std::vector<unsigned> commandLengthInCycles;
std::vector<double> commandLengthInCycles;
sc_core::sc_time burstDuration;
uint64_t memorySizeBytes;
};

View File

@@ -86,7 +86,15 @@ MemSpecHBM3::MemSpecHBM3(const DRAMSysConfiguration::MemSpec &memSpec)
tREFI (tCK * memSpec.memTimingSpec.entries.at("REFI")),
tREFIPB (tCK * memSpec.memTimingSpec.entries.at("REFIPB"))
{
commandLengthInCycles[Command::ACT] = 2; // TODO 1.5
commandLengthInCycles[Command::ACT] = 1.5;
commandLengthInCycles[Command::PREPB] = 0.5;
commandLengthInCycles[Command::PREAB] = 0.5;
commandLengthInCycles[Command::REFPB] = 0.5;
commandLengthInCycles[Command::REFAB] = 0.5;
commandLengthInCycles[Command::RFMPB] = 0.5;
commandLengthInCycles[Command::RFMAB] = 0.5;
commandLengthInCycles[Command::PDXA] = 0.5;
commandLengthInCycles[Command::SREFEX] = 0.5;
uint64_t deviceSizeBits = static_cast<uint64_t>(banksPerRank) * rowsPerBank * columnsPerRow * bitWidth;
uint64_t deviceSizeBytes = deviceSizeBits / 8;

View File

@@ -38,38 +38,38 @@
struct CommandLengths
{
unsigned NOP = 1;
unsigned RD = 1;
unsigned WR = 1;
unsigned RDA = 1;
unsigned WRA = 1;
unsigned ACT = 1;
unsigned PREPB = 1;
unsigned REFPB = 1;
unsigned RFMPB = 1;
unsigned REFP2B = 1;
unsigned RFMP2B = 1;
unsigned PRESB = 1;
unsigned REFSB = 1;
unsigned RFMSB = 1;
unsigned PREAB = 1;
unsigned REFAB = 1;
unsigned RFMAB = 1;
unsigned PDEA = 1;
unsigned PDXA = 1;
unsigned PDEP = 1;
unsigned PDXP = 1;
unsigned SREFEN = 1;
unsigned SREFEX = 1;
double NOP = 1;
double RD = 1;
double WR = 1;
double RDA = 1;
double WRA = 1;
double ACT = 1;
double PREPB = 1;
double REFPB = 1;
double RFMPB = 1;
double REFP2B = 1;
double RFMP2B = 1;
double PRESB = 1;
double REFSB = 1;
double RFMSB = 1;
double PREAB = 1;
double REFAB = 1;
double RFMAB = 1;
double PDEA = 1;
double PDXA = 1;
double PDEP = 1;
double PDXP = 1;
double SREFEN = 1;
double SREFEX = 1;
CommandLengths(unsigned NOP, unsigned RD, unsigned WR,
unsigned RDA, unsigned WRA, unsigned ACT,
unsigned PREPB, unsigned REFPB, unsigned RFMPB,
unsigned REFP2B, unsigned RFMP2B,
unsigned PRESB, unsigned REFSB, unsigned RFMSB,
unsigned PREAB, unsigned REFAB, unsigned RFMAB,
unsigned PDEA, unsigned PDXA, unsigned PDEP, unsigned PDXP,
unsigned SREFEN, unsigned SREFEX) :
CommandLengths(double NOP, double RD, double WR,
double RDA, double WRA, double ACT,
double PREPB, double REFPB, double RFMPB,
double REFP2B, double RFMP2B,
double PRESB, double REFSB, double RFMSB,
double PREAB, double REFAB, double RFMAB,
double PDEA, double PDXA, double PDEP, double PDXP,
double SREFEN, double SREFEX) :
NOP(NOP), RD(RD), WR(WR),
RDA(RDA), WRA(WRA), ACT(ACT),
PREPB(PREPB), REFPB(REFPB), RFMPB(RFMPB),

View File

@@ -353,12 +353,12 @@ CommandLengths TraceDB::getCommandLengthsFromDB()
return {};
};
auto getCommandLength = [=, &table](const std::string &command) -> unsigned
auto getCommandLength = [=, &table](const std::string &command) -> double
{
QVariant length = getLengthFromDb(command);
if (length.isValid())
return length.toUInt();
return length.toDouble();
else
{
qDebug() << "CommandLength for" << command.c_str() << "not present in table" << table.c_str()
@@ -367,12 +367,12 @@ CommandLengths TraceDB::getCommandLengthsFromDB()
}
};
auto getCommandLengthOrElse = [=, &table](const std::string &command, const std::string &elseCommand) -> unsigned
auto getCommandLengthOrElse = [=, &table](const std::string &command, const std::string &elseCommand) -> double
{
QVariant length = getLengthFromDb(command);
if (length.isValid())
return length.toUInt();
return length.toDouble();
else
{
length = getLengthFromDb(command);
@@ -388,33 +388,33 @@ CommandLengths TraceDB::getCommandLengthsFromDB()
}
};
unsigned NOP = getCommandLength("NOP");
unsigned RD = getCommandLength("RD");
unsigned WR = getCommandLength("RD");
unsigned RDA = getCommandLength("RDA");
unsigned WRA = getCommandLength("WRA");
unsigned ACT = getCommandLength("ACT");
double NOP = getCommandLength("NOP");
double RD = getCommandLength("RD");
double WR = getCommandLength("RD");
double RDA = getCommandLength("RDA");
double WRA = getCommandLength("WRA");
double ACT = getCommandLength("ACT");
unsigned PREPB = getCommandLengthOrElse("PREPB", "PRE");
unsigned REFPB = getCommandLengthOrElse("REFPB", "REFB");
double PREPB = getCommandLengthOrElse("PREPB", "PRE");
double REFPB = getCommandLengthOrElse("REFPB", "REFB");
unsigned RFMPB = getCommandLength("RFMPB");
unsigned REFP2B = getCommandLength("REFP2B");
unsigned RFMP2B = getCommandLength("RFMP2B");
unsigned PRESB = getCommandLength("PRESB");
unsigned REFSB = getCommandLength("REFSB");
unsigned RFMSB = getCommandLength("RFMSB");
double RFMPB = getCommandLength("RFMPB");
double REFP2B = getCommandLength("REFP2B");
double RFMP2B = getCommandLength("RFMP2B");
double PRESB = getCommandLength("PRESB");
double REFSB = getCommandLength("REFSB");
double RFMSB = getCommandLength("RFMSB");
unsigned PREAB = getCommandLengthOrElse("PREAB", "PREA");
unsigned REFAB = getCommandLengthOrElse("REFAB", "REFA");
double PREAB = getCommandLengthOrElse("PREAB", "PREA");
double REFAB = getCommandLengthOrElse("REFAB", "REFA");
unsigned RFMAB = getCommandLength("RFMAB");
unsigned PDEA = getCommandLength("PDEA");
unsigned PDXA = getCommandLength("PDXA");
unsigned PDEP = getCommandLength("PDEP");
unsigned PDXP = getCommandLength("PDXP");
unsigned SREFEN = getCommandLength("SREFEN");
unsigned SREFEX = getCommandLength("SREFEX");
double RFMAB = getCommandLength("RFMAB");
double PDEA = getCommandLength("PDEA");
double PDXA = getCommandLength("PDXA");
double PDEP = getCommandLength("PDEP");
double PDXP = getCommandLength("PDXP");
double SREFEN = getCommandLength("SREFEN");
double SREFEX = getCommandLength("SREFEX");
return {NOP, RD, WR, RDA, WRA, ACT, PREPB, REFPB, RFMPB, REFP2B, RFMP2B, PRESB, REFSB, RFMSB,
PREAB, REFAB, RFMAB, PDEA, PDXA, PDEP, PDXP, SREFEN, SREFEX};