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

Override parameter during elaborate, second time default parameter is used #166

Closed
Risto97 opened this issue Apr 9, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@Risto97
Copy link

Risto97 commented Apr 9, 2023

Take a look at this example:

test.rdl

addrmap test #(
    longint unsigned N = 5
    ){
    reg {name = "dummy"; field {sw = r; hw = w;} dummy[1] = 0;} dummy;
};

In test code I first override parameter N with 2, then I override for another instance with 3.
I expect print to be:
N 2
N 3

from systemrdl import RDLCompiler

rdlc = RDLCompiler()
rdlc.compile_file("test.rdl")

node = rdlc.elaborate(
        top_def_name="test",
        inst_name="new_inst",
        parameters={'N' : 2}
        ).find_by_path("new_inst")
[print(p.name, p.get_value()) for p in node.inst.parameters]

node2 = rdlc.elaborate(
        top_def_name="test",
        inst_name="new_inst2",
        parameters={'N' : 3}
        ).find_by_path("new_inst2")
[print(p.name, p.get_value()) for p in node2.inst.parameters]

What I get is:
N 2
N 5

If I remove default parameter value it works correctly and I get:
N 2
N 3

Seems like a bug?

@amykyta3
Copy link
Member

amykyta3 commented Apr 9, 2023

Interesting. Yeah agree that doesn't look right.
I suspect this was missed since in nearly all the cases I use this, I only ever run the elaborate() step once. What you are doing should be supported though! Something must be leaking between elaborations.

Thanks for reporting this!

@amykyta3 amykyta3 self-assigned this Apr 9, 2023
@amykyta3 amykyta3 added the bug Something isn't working label Apr 9, 2023
@Risto97
Copy link
Author

Risto97 commented Apr 9, 2023

I am doing weird things with the compiler honestly. But some corner cases are popping up, which is good.

I feel like the problem is the _copy_for_inst() method in component.py

amykyta3 added a commit that referenced this issue Apr 20, 2023
@amykyta3
Copy link
Member

Found and fixed the issue. Fix will be in the next release.

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

2 participants