From 06d2125d26086b2ef9f94a5fa701aa75375beacf Mon Sep 17 00:00:00 2001 From: "Tommaso Marinelli (imec)" Date: Fri, 11 Oct 2024 19:29:09 +0200 Subject: [PATCH] Fix RowHit/RowOpen lambdas in LPDDR5 The use of the RowOpen/RowHit lambdas to detect the bank state during a RD/WR operation does not consider the Pre-Opened state, specific to LPDDR5. This results in assuming the default case, which provokes an execution error. This commit fixes this behavior by using custom lambdas for LPDDR5, to include the additional state. A similar fix was provided by the PSAL-POSTECH group in https://github.com/PSAL-POSTECH/ramulator2, commit bb1d54f5117a6232f13724bb40f903776645a737. Fixes issue #66. --- src/dram/impl/LPDDR5.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/dram/impl/LPDDR5.cpp b/src/dram/impl/LPDDR5.cpp index 78de3de..ac95d89 100644 --- a/src/dram/impl/LPDDR5.cpp +++ b/src/dram/impl/LPDDR5.cpp @@ -504,16 +504,45 @@ class LPDDR5 : public IDRAM, public Implementation { void set_rowhits() { m_rowhits.resize(m_levels.size(), std::vector>(m_commands.size())); - m_rowhits[m_levels["bank"]][m_commands["RD16"]] = Lambdas::RowHit::Bank::RDWR; - m_rowhits[m_levels["bank"]][m_commands["WR16"]] = Lambdas::RowHit::Bank::RDWR; + auto rowhit_func = [] (Node* node, int cmd, int target_id, Clk_t clk) { + switch (node->m_state) { + case m_states["Closed"]: return false; + case m_states["Pre-Opened"]: return false; + case m_states["Opened"]: + if (node->m_row_state.find(target_id) != node->m_row_state.end()) { + return true; + } + else { + return false; + } + case m_states["Refreshing"]: return false; + default: { + spdlog::error("[RowHit::Bank] Invalid bank state for an RD/WR command!"); + std::exit(-1); + } + } + }; + m_rowhits[m_levels["bank"]][m_commands["RD16"]] = rowhit_func; + m_rowhits[m_levels["bank"]][m_commands["WR16"]] = rowhit_func; } - void set_rowopens() { m_rowopens.resize(m_levels.size(), std::vector>(m_commands.size())); - m_rowopens[m_levels["bank"]][m_commands["RD16"]] = Lambdas::RowOpen::Bank::RDWR; - m_rowopens[m_levels["bank"]][m_commands["WR16"]] = Lambdas::RowOpen::Bank::RDWR; + auto rowopen_func = [] (Node* node, int cmd, int target_id, Clk_t clk) { + switch (node->m_state) { + case m_states["Closed"]: return false; + case m_states["Pre-Opened"]: return false; + case m_states["Opened"]: return true; + case m_states["Refreshing"]: return false; + default: { + spdlog::error("[RowOpen::Bank] Invalid bank state for an RD/WR command!"); + std::exit(-1); + } + } + }; + m_rowopens[m_levels["bank"]][m_commands["RD16"]] = rowopen_func; + m_rowopens[m_levels["bank"]][m_commands["WR16"]] = rowopen_func; }