Skip to content
New issue

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

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

Already on GitHub? # to your account

Adjustment of code generator to address #1368 #1370

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ private static String deferredFillTriggerTable(
}
var cumulativePortWidth = 0;
for (PortInstance port : Iterables.filter(reaction.effects, PortInstance.class)) {
// If this port does not have any destinations, do not generate code for it.
if (port.eventualDestinations().isEmpty()) continue;

code.pr("for (int i = 0; i < "+reaction.getParent().getTotalWidth()+"; i++) triggers_index[i] = "+cumulativePortWidth+";");
for (SendRange srcRange : port.eventualDestinations()) {
if (currentFederate.contains(port.getParent())) {
Expand Down
22 changes: 22 additions & 0 deletions test/C/src/MultipleOutputs.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This test checks for one of the issues arised in the solution of EECS149 Lab Chapter 7.
// In this case, a reactor has two output ports, the first one of which is dangling.
// The generated code should not have any segmentation faults.
target C {
timeout: 1 sec,
fast: true
};
reactor C {
output x:int;
output z:int;
timer t(0, 100 msec);
reaction(t) -> x, z {=
lf_set(x, 42);
lf_set(z, 44);
=}
}
main reactor {
c = new C();
reaction(c.z) {=
lf_print("c.z = %d", c.z->value);
=}
}
lsk567 marked this conversation as resolved.
Show resolved Hide resolved