Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixed instructions for setting parameters from a table #274

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 4 additions & 5 deletions docs/assets/code/c/src/BankIndex.lf
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
target C;
preamble {=
int table[] = {4, 3, 2, 1};
=}
reactor A(bank_index:int = 0, value:int = 0) {
reaction (startup) {=
printf("bank_index: %d, value: %d\n", self->bank_index, self->value);
=}
}
main reactor {
a = new[4] A(value = {= table[bank_index] =});
main reactor(
table: int[] = {4, 3, 2, 1}
) {
a = new[4] A(value = {= self->table[bank_index] =});
}
9 changes: 4 additions & 5 deletions docs/assets/code/py/src/BankIndex.lf
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
target Python;
preamble {=
table = [4, 3, 2, 1]
=}
reactor A(bank_index = 0, value = 0) {
reaction (startup) {=
print("bank_index: {:d}, value: {:d}".format(self.bank_index, self.value))
=}
}
main reactor {
a = new[4] A(value = {= table[bank_index] =})
main reactor(
table = [4, 3, 2, 1]
) {
a = new[4] A(value = {= self.table[bank_index] =})
}
2 changes: 1 addition & 1 deletion docs/writing-reactors/multiports-and-banks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ import Py_BankIndex from '../assets/code/py/src/BankIndex.lf';

<NoSelectorTargetCodeBlock c={C_BankIndex} py={Py_BankIndex} lf />

The global `table` defined in the `preamble` is used to initialize the `value` parameter of each bank member. The result of running this is something like:
The parameter `table` defined in the `main reactor` is used to initialize the `value` parameter of each bank member. The result of running this is something like:

```
bank_index: 0, value: 4
Expand Down
9 changes: 4 additions & 5 deletions versioned_docs/version-0.8.0/assets/code/c/src/BankIndex.lf
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
target C;
preamble {=
int table[] = {4, 3, 2, 1};
=}
reactor A(bank_index:int = 0, value:int = 0) {
reaction (startup) {=
printf("bank_index: %d, value: %d\n", self->bank_index, self->value);
=}
}
main reactor {
a = new[4] A(value = {= table[bank_index] =});
main reactor(
table: int[] = {4, 3, 2, 1}
) {
a = new[4] A(value = {= self->table[bank_index] =});
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ import Py_BankIndex from '../assets/code/py/src/BankIndex.lf';

<NoSelectorTargetCodeBlock c={C_BankIndex} py={Py_BankIndex} lf />

<ShowOnly py>
The global `table` defined in the `preamble` is used to initialize the `value` parameter of each bank member. The result of running this is something like:
</ShowOnly>
<ShowOnly c>
The parameter `table` defined in the `main reactor` is used to initialize the `value` parameter of each bank member. The result of running this is something like:
</ShowOnly>

```
bank_index: 0, value: 4
Expand Down
Loading