-
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 #1953 from lf-lang/1952-unconnected-multiport-outp…
…ut-and-nested-bank-reactor-bug Fix for unconnected multiport and bank reactor bug
- Loading branch information
Showing
3 changed files
with
100 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
target C { | ||
workers: 1 | ||
} | ||
|
||
reactor echo<entry_T>(bank_index: int = 0) { | ||
input request: entry_T | ||
output response: entry_T | ||
|
||
output unconnected: entry_T | ||
|
||
reaction(request) -> response {= | ||
int req = request->value; | ||
lf_set (response, request->value); | ||
=} | ||
} | ||
|
||
reactor testing_echo(bank_index: int = 0) { | ||
output req: int | ||
input resp: int | ||
|
||
state seed: uint32_t = 0 | ||
|
||
reaction(startup) -> req {= | ||
lf_set (req, 42 + self->bank_index); | ||
=} | ||
|
||
reaction(resp) {= | ||
int sum = self->bank_index + 42; | ||
int received = resp->value; | ||
printf("Bank index: %d, received: %d\n", self->bank_index, received); | ||
if (received != sum) { | ||
printf("Wrong value. Should have been %d.\n", sum); | ||
exit(1); | ||
} | ||
=} | ||
} | ||
|
||
main reactor MultiBank_UnconnectedOutput_Test { | ||
test = new[2] testing_echo() | ||
e = new[2] echo<int>() | ||
|
||
test.req -> e.request | ||
e.response -> test.resp | ||
} |
52 changes: 52 additions & 0 deletions
52
test/C/src/multiport/MultiPort_MultiBankTest_UnconnectedOutput_Test.lf
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,52 @@ | ||
target C { | ||
workers: 1 | ||
} | ||
|
||
reactor adder<entry_T>(n_ports: int = 1) { | ||
input[n_ports] add_request: entry_T | ||
output add_response: entry_T | ||
|
||
output[n_ports] unconnected: entry_T | ||
|
||
state sum: entry_T = 0 | ||
|
||
reaction(add_request) -> add_response {= | ||
for (int i = 0; i < add_request_width; ++i) { | ||
if (add_request[i]->is_present) { | ||
self->sum += add_request[i]->value; | ||
} | ||
} | ||
lf_set (add_response, self->sum); | ||
self->sum = 0; | ||
=} | ||
} | ||
|
||
reactor testing_adder(bank_index: int = 0, bank_width: int = 1) { | ||
output add_req: int | ||
output result_req: int | ||
|
||
input add_resp: int | ||
input unconnected: int | ||
|
||
reaction(startup) -> add_req {= | ||
lf_set (add_req, 42); | ||
=} | ||
|
||
reaction(add_resp) {= | ||
int sum = self->bank_width * 42; | ||
int received = add_resp->value; | ||
printf("Bank index: %d, received: %d\n", self->bank_index, received); | ||
if (received != sum) { | ||
printf("Wrong value. Should have been %d.\n", sum); | ||
exit(1); | ||
} | ||
=} | ||
} | ||
|
||
main reactor MultiPort_MultiBankTest_UnconnectedOutput_Test { | ||
test = new[2] testing_adder(bank_width=2) | ||
a = new adder<int>(n_ports=2) | ||
|
||
test.add_req -> a.add_request | ||
(a.add_response)+ -> test.add_resp | ||
} |