Skip to content
New issue

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

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

Already on GitHub? # to your account

Reactions do not consistently trigger banks #1278

Closed
a-sr opened this issue Jul 6, 2022 · 3 comments
Closed

Reactions do not consistently trigger banks #1278

a-sr opened this issue Jul 6, 2022 · 3 comments
Labels
bug Something isn't working c Related to C target

Comments

@a-sr
Copy link
Collaborator

a-sr commented Jul 6, 2022

If two reactor banks are triggered by the same reaction, the bank that is listed as first effect, will only get a single bank member triggered.

This is an example:

target C;

reactor Hello {
    input I:int;
    
    reaction(I) {=
        printf("Hello\n");
    =}
}
reactor World {
    input I:int;
    
    reaction(I) {=
        printf("World\n");
    =}
}

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);
        }
    =}
}

The output is:

World
World
World
Hello

Swapping the order of the effects will output 3 x Hello, 1 x World.
Splitting the reaction into two, one for each bank, yields the correct behavior.

@a-sr a-sr added bug Something isn't working c Related to C target labels Jul 6, 2022
@a-sr a-sr changed the title Reactions do not consitently trigger banks Reactions do not consistently trigger banks Jul 6, 2022
@edwardalee
Copy link
Collaborator

PR #1289 fixes this. The problem was a simple indexing issue that failed to take into account the width of the first bank.

@edwardalee
Copy link
Collaborator

Unfortunately, my fix does not work. Reopening this issue and converting the PR #1289 to a draft.

@edwardalee edwardalee reopened this Jul 12, 2022
@edwardalee
Copy link
Collaborator

Closed via #1289.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working c Related to C target
Projects
None yet
Development

No branches or pull requests

2 participants