From 8be6ae44679af20f880aaa31a99ef2f5234fe1ed Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 18 Jan 2024 00:38:44 -0600 Subject: [PATCH] Scoreboard view fix --- sparta/src/Scoreboard.cpp | 4 +++ sparta/test/Scoreboard/Scoreboard_test.cpp | 37 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/sparta/src/Scoreboard.cpp b/sparta/src/Scoreboard.cpp index 362eb1938d..28b45bea00 100644 --- a/sparta/src/Scoreboard.cpp +++ b/sparta/src/Scoreboard.cpp @@ -314,6 +314,10 @@ namespace sparta // we could bind to a Scoreboard in another CPU! That'd be // bad. auto cpu_node = parent->findAncestorByName("core*"); + // if a core node is not available, search from the root + if(cpu_node == nullptr){ + cpu_node = parent->getRoot(); + } sparta_assert(cpu_node != nullptr, "Could not find the core nodes in this simulation"); std::function findScoreboard = diff --git a/sparta/test/Scoreboard/Scoreboard_test.cpp b/sparta/test/Scoreboard/Scoreboard_test.cpp index 4b36efae5a..5e3b3ccf24 100644 --- a/sparta/test/Scoreboard/Scoreboard_test.cpp +++ b/sparta/test/Scoreboard/Scoreboard_test.cpp @@ -559,6 +559,41 @@ void testScoreboardClearing() rtn.enterTeardown(); } +void testScoreboardNonCore() +{ + // testing scoreboard view is able to find scoreboards when there is not a "core" node + sparta::RootTreeNode rtn; + sparta::Scheduler sched; + sparta::ClockManager cm(&sched); + sparta::Clock::Handle root_clk; + root_clk = cm.makeRoot(&rtn, "root_clk"); + cm.normalize(); + rtn.setClock(root_clk.get()); + + sparta::TreeNode cpu(&rtn, "custom", "Dummy CPU"); + + sparta::ResourceFactory fact; + + sparta::ResourceTreeNode sbtn(&cpu, + SB_NAMES[0], + sparta::TreeNode::GROUP_NAME_NONE, + sparta::TreeNode::GROUP_IDX_NONE, + "Test scoreboard", + &fact); + + sparta::Scoreboard::ScoreboardParameters * params = + dynamic_cast(sbtn.getParameterSet()); + params->latency_matrix = GPR_FORWARDING_MATRIX; + + rtn.enterConfiguring(); + rtn.enterFinalized(); + sparta::ScoreboardView view(UNIT_NAMES[0], SB_NAMES[0], &sbtn); + + auto is_set = view.isSet({0b1000}); + EXPECT_TRUE(is_set); + rtn.enterTeardown(); +} void testPrintBits() { sparta::Scoreboard::RegisterBitMask some_bits(0b011000110011); @@ -577,6 +612,8 @@ int main () testScoreboardClearing(); + testScoreboardNonCore(); + testPrintBits(); REPORT_ERROR;