Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
make links needing first only; fix bug in get_split_child and some sp…
Browse files Browse the repository at this point in the history
…lit algo things
  • Loading branch information
iopapamanoglou committed Nov 14, 2024
1 parent 81b56fe commit 55f1e39
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/faebryk/core/cpp/src/pathfinder/bfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath &)> visito
if (!it->get()->hibernated) {
open_path_queue.push_back(std::move(*it));
it = hibernated_paths.erase(it);
} else if (!it->get()->filtered) {
hibernated_paths.erase(it);
} else {
++it;
}
Expand Down
18 changes: 12 additions & 6 deletions src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GI_refs_weak get_split_children(GI_ref_weak split_point) {
true, {{Node::Type::get_moduleinterface_type()}}, false);
GI_refs_weak out;
for (auto &c : children) {
out.push_back(c->get_self_gif().get());
out.push_back(c->get_parent_gif().get());
}
return out;
}
Expand Down Expand Up @@ -54,10 +54,11 @@ std::optional<PathStackElement> _extend_path_hierarchy_stack(Edge &edge) {
void _extend_fold_stack(PathStackElement &elem, UnresolvedStack &unresolved_stack,
PathStack &split_stack) {
if (!unresolved_stack.empty() && unresolved_stack.back().match(elem)) {
auto split = unresolved_stack.back().split;
if (split) {
split_stack.push_back(elem);
}
// TODO why was this here?
// auto split = unresolved_stack.back().split;
// if (split) {
// split_stack.push_back(elem);
// }
unresolved_stack.pop_back();
} else {
bool multi_child = get_split_children(elem.parent_gif).size() > 1;
Expand Down Expand Up @@ -325,6 +326,8 @@ bool PathFinder::_build_path_stack_and_handle_splits(BFSPath &p) {
return true;
}

assert(!elem->up);

// handle split
data.not_complete = true;

Expand All @@ -342,7 +345,10 @@ bool PathFinder::_build_path_stack_and_handle_splits(BFSPath &p) {
assert(false);
return false;
}
p.hibernated = !split_state.waiting;
if (!split_state.waiting) {
p.hibernated = true;
split_state.wait_paths[elem->child_gif].push_back(p.shared_from_this());
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/faebryk/library/SignalElectrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self) -> None:
lambda path: LinkDirectConditionalFilterResult.FILTER_PASS
if all(self.test(dst.node) for dst in path)
else LinkDirectConditionalFilterResult.FILTER_FAIL_UNRECOVERABLE,
needs_only_first_in_path=False,
needs_only_first_in_path=True,
)

# ----------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion test/core/test_hierarchy_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ def test_specialize_link():
# test special link
class _Link(LinkDirectConditional):
def __init__(self):
super().__init__(lambda path: LinkDirectConditionalFilterResult.FILTER_PASS)
super().__init__(
lambda path: LinkDirectConditionalFilterResult.FILTER_PASS,
needs_only_first_in_path=True,
)

mifs = times(3, ModuleInterface)
mifs_special = times(3, Specialized)
Expand Down

0 comments on commit 55f1e39

Please sign in to comment.