Skip to content

Commit

Permalink
Scoreboard view fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongchan authored and klingaard committed Jan 23, 2024
1 parent 4626e0d commit 8be6ae4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sparta/src/Scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scoreboard*(sparta::TreeNode *)> findScoreboard =
Expand Down
37 changes: 37 additions & 0 deletions sparta/test/Scoreboard/Scoreboard_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sparta::Scoreboard,
sparta::Scoreboard::ScoreboardParameters> 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<sparta::Scoreboard::ScoreboardParameters *>(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);
Expand All @@ -577,6 +612,8 @@ int main ()

testScoreboardClearing();

testScoreboardNonCore();

testPrintBits();

REPORT_ERROR;
Expand Down

0 comments on commit 8be6ae4

Please sign in to comment.