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

Child Reactor outside Modal Mode is not accessible #2419

Open
OmerMajNition opened this issue Oct 2, 2024 · 0 comments
Open

Child Reactor outside Modal Mode is not accessible #2419

OmerMajNition opened this issue Oct 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@OmerMajNition
Copy link
Collaborator

target C;

reactor Destination (bank_index:int = 0, name:string = "DST") {
    input req:int;
    output rsp:int;

    reaction (req) -> rsp {=
        printf ("(%lld, %u) physical_time:%lld "
                "%s [%d] Sending back response:%d\n",
                lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                self->name, self->bank_index, req->value
        );
        lf_set (rsp, req->value);
    =}
}

reactor Source (bank_index:int = 0, name:string = "Source") {
    output req:int;
    input rsp:int;

    state msg:int = 0;

    reaction (startup) -> req {=
        printf ("(%lld, %u) physical_time:%lld "
                "%s [%d] Scheduling request:%d\n",
                lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                self->name, self->bank_index, self->msg
        );
        lf_set (req, self->msg);
    =}

    reaction (rsp) {=
        printf ("(%lld, %u) physical_time:%lld "
                "%s [%d] Receiving response:%d\n",
                lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                self->name, self->bank_index, rsp->value
        );
    =}
}

reactor pass_through (bank_index:int = 0, name:string = "PassThrough") {
    input in_req:int;
    output out_rsp:int;

    reaction (in_req) -> out_rsp {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Sending back response:%d\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index, in_req->value
        );
        lf_set (out_rsp, in_req->value);
    =}

}

reactor Selector (bank_index:int = 0, name:string = "Selector") {
    input in_req:int;
    output out_rsp:int;

    pt = new pass_through();

    initial mode Init {
        reaction (startup) -> history (DST_1), history (DST_2) {=
            printf ("(%lld, %u) physical_time:%lld "
                    "%s POP startup",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name
            );
            lf_set_mode(DST_1);
        =}
    }

    mode DST_1 {
        dst1 = new Destination(name = "DST_1");

        in_req -> pt.in_req;
        pt.out_rsp -> dst1.req;
        dst1.rsp -> out_rsp;
    }

    mode DST_2 {
        dst2 = new Destination(name = "DST_2");

        in_req -> pt.in_req;
        pt.out_rsp -> dst2.req;
        dst2.rsp -> out_rsp;
    }
}

main reactor {
    src = new Source();
    sel = new Selector();

    src.req -> sel.in_req;
    sel.out_rsp -> src.rsp;
}

Passthrough reactor sitting inside Selector reactor is not accessible inside Modes. If we move pass through reactor inside each mode it works fine.

target C;

reactor Destination (bank_index:int = 0, name:string = "DST") {
    input req:int;
    output rsp:int;

    reaction (req) -> rsp {=
        printf ("(%lld, %u) physical_time:%lld "
                "%s [%d] Sending back response:%d\n",
                lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                self->name, self->bank_index, req->value
        );
        lf_set (rsp, req->value);
    =}
}

reactor Source (bank_index:int = 0, name:string = "Source") {
    output req:int;
    input rsp:int;

    state msg:int = 0;

    reaction (startup) -> req {=
        printf ("(%lld, %u) physical_time:%lld "
                "%s [%d] Scheduling request:%d\n",
                lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                self->name, self->bank_index, self->msg
        );
        lf_set (req, self->msg);
    =}

    reaction (rsp) {=
        printf ("(%lld, %u) physical_time:%lld "
                "%s [%d] Receiving response:%d\n",
                lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                self->name, self->bank_index, rsp->value
        );
    =}
}

reactor pass_through (bank_index:int = 0, name:string = "PassThrough") {
    input in_req:int;
    output out_rsp:int;

    reaction (in_req) -> out_rsp {=
        fprintf (   stderr, "(%lld, %u) physical_time:%lld "
                    "%s [%d] Sending back response:%d\n",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name, self->bank_index, in_req->value
        );
        lf_set (out_rsp, in_req->value);
    =}

}

reactor Selector (bank_index:int = 0, name:string = "Selector") {
    input in_req:int;
    output out_rsp:int;

    initial mode Init {
        reaction (startup) -> history (DST_1), history (DST_2) {=
            printf ("(%lld, %u) physical_time:%lld "
                    "%s POP startup",
                    lf_time_logical_elapsed(), lf_tag().microstep, lf_time_physical_elapsed(),
                    self->name
            );
            lf_set_mode(DST_1);
        =}
    }

    mode DST_1 {
        dst1 = new Destination(name = "DST_1");
        pt1 = new pass_through();

        in_req -> pt1.in_req;
        pt1.out_rsp -> dst1.req;
        dst1.rsp -> out_rsp;
    }

    mode DST_2 {
        dst2 = new Destination(name = "DST_2");
        pt2 = new pass_through();

        in_req -> pt2.in_req;
        pt2.out_rsp -> dst2.req;
        dst2.rsp -> out_rsp;
    }
}

main reactor {
    src = new Source();
    sel = new Selector();

    src.req -> sel.in_req;
    sel.out_rsp -> src.rsp;
}
@OmerMajNition OmerMajNition added the bug Something isn't working label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant