Skip to content

Commit

Permalink
get_next_matching_gates_until tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SJulianS committed May 13, 2024
1 parent 51356ca commit 753ebea
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion tests/netlist/decorators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,39 @@ namespace hal {
// test NetlistModificationDecorator::get_next_matching_gates_until
const auto trav_dec = NetlistTraversalDecorator(*(nl.get()));

// TODO implement
// successors
{
const auto res = trav_dec.get_next_matching_gates_until(dff1, true, [](const Gate* g) { return g->get_type()->has_property(GateTypeProperty::combinational); }, false, nullptr, nullptr);
EXPECT_TRUE(res.is_ok());
EXPECT_EQ(res.get(), std::set<Gate*>({and0, or2, or0, or3, and1, or4}));
}
{
const auto res = trav_dec.get_next_matching_gates_until(dff1, true, [](const Gate* g) { return g->get_type()->has_property(GateTypeProperty::combinational); }, true, nullptr, [](const Endpoint* ep, u32 current_depth) { return !ep->get_gate()->get_type()->has_property(GateTypeProperty::ff); });
EXPECT_TRUE(res.is_ok());
EXPECT_EQ(res.get(), std::set<Gate*>({and0, or2, or0, or3, and1, or4}));
}

// predecessors
{
const auto res = trav_dec.get_next_matching_gates_until(dff5, false, [](const Gate* g) { return g->get_type()->has_property(GateTypeProperty::combinational); }, false, nullptr, nullptr);
EXPECT_TRUE(res.is_ok());
EXPECT_EQ(res.get(), std::set<Gate*>({or3, and0, and1, inv6}));
}
{
const auto res = trav_dec.get_next_matching_gates_until(dff4, false, [](const Gate* g) { return g->get_type()->has_property(GateTypeProperty::combinational); }, false, nullptr, nullptr);
EXPECT_TRUE(res.is_ok());
EXPECT_EQ(res.get(), std::set<Gate*>({or2, inv0, and0, inv6}));
}
{
const auto res = trav_dec.get_next_matching_gates_until(dff5, false, [](const Gate* g) { return g->get_type()->has_property(GateTypeProperty::combinational); }, true, nullptr, [](const Endpoint* ep, u32 current_depth) { return !ep->get_gate()->get_type()->has_property(GateTypeProperty::ff); });
EXPECT_TRUE(res.is_ok());
EXPECT_EQ(res.get(), std::set<Gate*>({or3, and0, and1, inv6}));
}
{
const auto res = trav_dec.get_next_matching_gates_until(dff5, false, [](const Gate* g) { return g->get_type()->has_property(GateTypeProperty::combinational); }, true, [](const Endpoint* ep, u32 current_depth) { return ep->get_pin()->get_type() == PinType::data || ep->get_pin()->get_type() == PinType::none; }, [](const Endpoint* ep, u32 current_depth) { return !ep->get_gate()->get_type()->has_property(GateTypeProperty::ff); });
EXPECT_TRUE(res.is_ok());
EXPECT_EQ(res.get(), std::set<Gate*>({or3, and0, and1}));
}
}
{
// test NetlistModificationDecorator::get_next_matching_gates_until_depth
Expand Down

0 comments on commit 753ebea

Please sign in to comment.