-
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 #420 from icyphy/width-given-by-code
Allow width to be specified in target code
- Loading branch information
Showing
4 changed files
with
48 additions
and
5 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
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,37 @@ | ||
target Cpp | ||
|
||
reactor Foo(a: size_t{8}, b: size_t{2}) { | ||
input[{=a*b=}] in: size_t; | ||
output[{=a/b=}] out: size_t; | ||
|
||
reaction (startup) in -> out {= | ||
if (in.size() != a*b){ | ||
std::cerr << "ERROR: expected in to have a width of " << a*b << '\n'; | ||
exit(1); | ||
} | ||
if (out.size() != a/b){ | ||
std::cerr << "ERROR: expected out to have a width of " << a/b << '\n'; | ||
exit(2); | ||
} | ||
=} | ||
} | ||
|
||
main reactor { | ||
foo1 = new Foo(); | ||
foo2 = new Foo(a=10, b=3); | ||
foo3 = new Foo(a=9, b=9); | ||
foo_bank = new[{=42=}] Foo(); | ||
|
||
reaction (startup) foo_bank.out {= | ||
if (foo_bank.size() != 42) { | ||
std::cerr << "ERROR: expected foo_bank to have a width of " << 42 << '\n'; | ||
exit(3); | ||
} | ||
for (auto& foo : foo_bank) { | ||
if (foo.out.size() != 4) { | ||
std::cerr << "ERROR: expected foo_bank.out to have a width of " << 4 << '\n'; | ||
exit(4); | ||
} | ||
} | ||
=} | ||
} |