Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of ganged connections #1037

Merged
merged 7 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion org.lflang/src/org/lflang/generator/ReactorInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,14 @@ private List<RuntimeRange<PortInstance>> listPortInstances(
if (count < references.size() - 1) {
int portWidth = portInstance.width;
int portParentWidth = portInstance.parent.width;
// If the port is being connected on the inside and there is
// more than one port in the list, then we can only connect one
// bank member at a time.
if (reactor == this && references.size() > 1) {
portParentWidth = 1;
}
int widthBound = portWidth * portParentWidth;

// If either of these widths cannot be determined, assume infinite.
if (portWidth < 0) widthBound = Integer.MAX_VALUE;
if (portParentWidth < 0) widthBound = Integer.MAX_VALUE;
Expand Down
24 changes: 24 additions & 0 deletions test/C/src/multiport/BankGangedConnections.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
target C {
timeout: 0 sec
}
import Count from "../lib/Count.lf"
import TestCount from "../lib/TestCount.lf"
reactor Through {
input in:int;
output out:int;
reaction(in) -> out {=
SET(out, in->value);
=}
}
reactor Bank {
input in:int;
output out:int;
t = new Through();
in, t.out -> t.in, out;
}
main reactor {
b = new[2] Bank();
s = new Count();
t = new TestCount();
s.out, b.out -> b.in, t.in;
}