From bb99b9e8837f2cb5857e4c254fede9236e43ae1b Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Mon, 20 Mar 2023 16:51:36 +0100 Subject: [PATCH] Add fix for LP5 rank2rank timings. --- .../configuration/memspec/MemSpecLPDDR5.h | 6 +- .../controller/checker/CheckerLPDDR5.cpp | 72 ++++++++++++++++--- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/extensions/standards/LPDDR5/DRAMSys/configuration/memspec/MemSpecLPDDR5.h b/extensions/standards/LPDDR5/DRAMSys/configuration/memspec/MemSpecLPDDR5.h index 49b1c284..e354b741 100644 --- a/extensions/standards/LPDDR5/DRAMSys/configuration/memspec/MemSpecLPDDR5.h +++ b/extensions/standards/LPDDR5/DRAMSys/configuration/memspec/MemSpecLPDDR5.h @@ -62,14 +62,16 @@ public: const sc_core::sc_time tRRD; //const sc_core::sc_time tCCD; const sc_core::sc_time tRL; - //const sc_core::sc_time tRPST; + const sc_core::sc_time tRPRE; + const sc_core::sc_time tRPST; //const sc_core::sc_time tDQSCK; const sc_core::sc_time tRBTP; const sc_core::sc_time tWL; //const sc_core::sc_time tDQSS; //const sc_core::sc_time tDQS2DQ; const sc_core::sc_time tWR; - //const sc_core::sc_time tWPRE; + const sc_core::sc_time tWPRE; + const sc_core::sc_time tWPST; //const sc_core::sc_time tWTR; //const sc_core::sc_time tXP; //const sc_core::sc_time tSR; diff --git a/extensions/standards/LPDDR5/DRAMSys/controller/checker/CheckerLPDDR5.cpp b/extensions/standards/LPDDR5/DRAMSys/controller/checker/CheckerLPDDR5.cpp index f5f68f3a..292cab83 100644 --- a/extensions/standards/LPDDR5/DRAMSys/controller/checker/CheckerLPDDR5.cpp +++ b/extensions/standards/LPDDR5/DRAMSys/controller/checker/CheckerLPDDR5.cpp @@ -122,9 +122,11 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener if (lastCommandStart != sc_max_time()) { if (lastBurstLengthByCommand[Command::RD] == 32) - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST32 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_32 + + memSpec->tCK + memSpec->tRPST + memSpec->tRPRE); else - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST16 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_16 + + memSpec->tCK + memSpec->tRPST + memSpec->tRPRE); } lastCommandStart = lastScheduledByCommandAndBankGroup[Command::RDA][bankGroup.ID()]; @@ -157,9 +159,11 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener { // TODO: BG mode with BL32 if (lastBurstLengthByCommand[Command::RDA] == 32) - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST32 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_32 + + memSpec->tCK + memSpec->tRPST + memSpec->tRPRE); else - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST16 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_16 + + memSpec->tCK + memSpec->tRPST + memSpec->tRPRE); } lastCommandStart = lastScheduledByCommandAndBankGroup[Command::WR][bankGroup.ID()]; @@ -184,6 +188,19 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener + memSpec->BL_n_min_16 + memSpec->tWTR_S); } + lastCommandStart = lastScheduledByCommand[Command::WR] != lastScheduledByCommandAndRank[Command::WR][rank.ID()] ? + lastScheduledByCommand[Command::WR] : sc_max_time(); + if (lastCommandStart != sc_max_time()) + { + // TODO: BG mode with BL32 + if (lastBurstLengthByCommand[Command::WR] == 32) + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tWL + memSpec->BL_n_min_32 + memSpec->tCK - memSpec->tRL); + else + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tWL + memSpec->BL_n_min_16 + memSpec->tCK - memSpec->tRL); + } + lastCommandStart = lastScheduledByCommandAndBankGroup[Command::WRA][bankGroup.ID()]; if (lastCommandStart != sc_max_time()) { @@ -205,6 +222,19 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tWL + memSpec->BL_n_min_16 + memSpec->tWTR_S); } + + lastCommandStart = lastScheduledByCommand[Command::WRA] != lastScheduledByCommandAndRank[Command::WRA][rank.ID()] ? + lastScheduledByCommand[Command::WRA] : sc_max_time(); + if (lastCommandStart != sc_max_time()) + { + // TODO: BG mode with BL32 + if (lastBurstLengthByCommand[Command::WRA] == 32) + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tWL + memSpec->BL_n_min_32 + memSpec->tCK - memSpec->tRL); + else + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tWL + memSpec->BL_n_min_16 + memSpec->tCK - memSpec->tRL); + } } else if (command == Command::WR || command == Command::WRA) { @@ -239,6 +269,19 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener + memSpec->BL_n_min_16 + memSpec->tWCK2DQO - memSpec->tWL); } + lastCommandStart = lastScheduledByCommand[Command::RD] != lastScheduledByCommandAndRank[Command::RD][rank.ID()] ? + lastScheduledByCommand[Command::RD] : sc_max_time(); + if (lastCommandStart != sc_max_time()) + { + // TODO: BG mode with BL32 + if (lastBurstLengthByCommand[Command::RD] == 32) + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tRL + memSpec->BL_n_min_32 + memSpec->tWCK2DQO + memSpec->tRPST - memSpec->tWL); + else + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tRL + memSpec->BL_n_min_16 + memSpec->tWCK2DQO + memSpec->tRPST - memSpec->tWL); + } + lastCommandStart = lastScheduledByCommandAndBankGroup[Command::RDA][bankGroup.ID()]; if (lastCommandStart != sc_max_time()) { @@ -261,6 +304,19 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener + memSpec->BL_n_min_16 + memSpec->tWCK2DQO - memSpec->tWL); } + lastCommandStart = lastScheduledByCommand[Command::RDA] != lastScheduledByCommandAndRank[Command::RDA][rank.ID()] ? + lastScheduledByCommand[Command::RDA] : sc_max_time(); + if (lastCommandStart != sc_max_time()) + { + // TODO: BG mode with BL32 + if (lastBurstLengthByCommand[Command::RDA] == 32) + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tRL + memSpec->BL_n_min_32 + memSpec->tWCK2DQO + memSpec->tRPST - memSpec->tWL); + else + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + + memSpec->tRL + memSpec->BL_n_min_16 + memSpec->tWCK2DQO + memSpec->tRPST - memSpec->tWL); + } + lastCommandStart = lastScheduledByCommandAndBankGroup[Command::WR][bankGroup.ID()]; if (lastCommandStart != sc_max_time()) { @@ -291,9 +347,9 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener { // TODO: BG mode with BL32 if (lastBurstLengthByCommand[Command::WR] == 32) - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST32 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_32 + memSpec->tCK); else - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST16 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_16 + memSpec->tCK); } lastCommandStart = lastScheduledByCommandAndBankGroup[Command::WRA][bankGroup.ID()]; @@ -325,9 +381,9 @@ sc_time CheckerLPDDR5::timeToSatisfyConstraints(Command command, const tlm_gener if (lastCommandStart != sc_max_time()) { if (lastBurstLengthByCommand[Command::WRA] == 32) - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST32 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_32 + memSpec->tCK); else - earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + tBURST16 + memSpec->tRTRS); + earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->BL_n_min_16 + memSpec->tCK); } } else if (command == Command::ACT)