-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support banks with multiports in modes
- Loading branch information
1 parent
9614b9d
commit 11b4ff5
Showing
3 changed files
with
118 additions
and
15 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,67 @@ | ||
target C { | ||
timeout: 1 ms | ||
} | ||
|
||
reactor Destination(n_inputs: int = 2) { | ||
input[n_inputs] req: int | ||
output[n_inputs] rsp: int | ||
|
||
reaction(req) -> rsp {= | ||
for (int i = 0; i < self->n_inputs; ++i) { | ||
if (req[i]->is_present) { | ||
lf_set (rsp[i], req[i]->value); | ||
} | ||
} | ||
=} | ||
} | ||
|
||
reactor Source(n_ports: int = 4) { | ||
output[n_ports] req: int | ||
input[n_ports] rsp: int | ||
timer t(0, 1 ms) | ||
|
||
reaction(t) -> req {= | ||
for (int i = 0; i < self->n_ports; ++i) { | ||
lf_set (req[i], i); | ||
} | ||
=} | ||
|
||
reaction(rsp) {= | ||
for (int i = 0; i < self->n_ports; ++i) { | ||
lf_print("Received response:%d", rsp[i]->value); | ||
if (rsp[i]->value != i) { | ||
lf_print_error_and_exit("Expected %d", i); | ||
} | ||
} | ||
=} | ||
} | ||
|
||
reactor Selector(n_ports: int = 4) { | ||
input[n_ports] in_req: int | ||
output[n_ports] out_rsp: int | ||
|
||
initial mode DST_1 { | ||
dst1 = new[2] Destination() | ||
|
||
in_req -> dst1.req | ||
dst1.rsp -> out_rsp | ||
reaction(startup) -> reset(DST_2) {= | ||
lf_set_mode(DST_2); | ||
=} | ||
} | ||
|
||
mode DST_2 { | ||
dst2 = new[2] Destination() | ||
|
||
in_req -> dst2.req | ||
dst2.rsp -> out_rsp | ||
} | ||
} | ||
|
||
main reactor { | ||
src = new Source() | ||
sel = new Selector() | ||
|
||
src.req -> sel.in_req | ||
sel.out_rsp -> src.rsp | ||
} |