-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1289 from lf-lang/dual-bank-bugfix
Dual bank bugfix
- Loading branch information
Showing
4 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
target C; | ||
|
||
reactor Base(bank_index:int(0)) { | ||
input I:int; | ||
state received:bool(false); | ||
|
||
reaction(shutdown) {= | ||
if(!self->received) { | ||
lf_print_error_and_exit("Bank member %d received no input.", | ||
self->bank_index | ||
); | ||
} | ||
=} | ||
} | ||
|
||
reactor Hello extends Base { | ||
reaction(I) {= | ||
printf("Hello %d\n", self->bank_index); | ||
self->received = true; | ||
=} | ||
} | ||
reactor World extends Base { | ||
reaction(I) {= | ||
printf("World %d\n", self->bank_index); | ||
self->received = true; | ||
=} | ||
} | ||
|
||
main reactor { | ||
hellos = new[3] Hello() | ||
worlds = new[3] World() | ||
|
||
reaction(startup) -> hellos.I, worlds.I {= | ||
for(int i = 0; i < hellos_width; i++) { | ||
lf_set(hellos[i].I, true); | ||
} | ||
for(int i = 0; i < worlds_width; i++) { | ||
lf_set(worlds[i].I, true); | ||
} | ||
=} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
target C; | ||
|
||
reactor Base(bank_index:int(0)) { | ||
input[2] I:int; | ||
state received:bool(false); | ||
|
||
reaction(shutdown) {= | ||
if(!self->received) { | ||
lf_print_error_and_exit("Bank member %d did not receive all inputs.", | ||
self->bank_index | ||
); | ||
} | ||
=} | ||
} | ||
|
||
reactor Hello extends Base { | ||
reaction(I) {= | ||
if (I[0]->is_present && I[1]->is_present) { | ||
printf("Hello %d\n", self->bank_index); | ||
self->received = true; | ||
} | ||
=} | ||
} | ||
reactor World extends Base { | ||
reaction(I) {= | ||
if (I[0]->is_present && I[1]->is_present) { | ||
printf("World %d\n", self->bank_index); | ||
self->received = true; | ||
} | ||
=} | ||
} | ||
|
||
main reactor { | ||
hellos = new[3] Hello() | ||
worlds = new[3] World() | ||
|
||
reaction(startup) -> hellos.I, worlds.I {= | ||
for(int i = 0; i < hellos_width; i++) { | ||
lf_set(hellos[i].I[0], true); | ||
lf_set(hellos[i].I[1], true); | ||
} | ||
for(int i = 0; i < worlds_width; i++) { | ||
lf_set(worlds[i].I[0], true); | ||
lf_set(worlds[i].I[1], true); | ||
} | ||
=} | ||
} |