-
Notifications
You must be signed in to change notification settings - Fork 175
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
lib.wiring: Add path argument to Component constructor #1517
Conversation
This is clearly new functionality that would normally require an RFC. What's the use case? |
Ah okay, I was expecting RFC being only used for bigger features. My motivation is mainly nicer naming for the "ports" of programmatically created #!/usr/bin/env python3
from amaranth import Module
from amaranth.lib import wiring, stream
from amaranth.back.verilog import convert
class A(wiring.Component):
stream: wiring.In(stream.Signature(1))
def __init__(self, name):
super().__init__(path=[name])
def elaborate(self, _):
return Module()
m = Module()
ports = []
for dir in ["north", "south"]:
a = m.submodules[f"{dir}_a"] = A(name=dir)
ports.append(a.stream.ready)
ports.append(a.stream.valid)
ports.append(a.stream.p)
print(convert(m, ports=ports)) generates
And without this it creates
|
I would suggest grabbing the signatures of the components, adding them to the toplevel, and then connecting them in the toplevel elaborate. The reason a component doesn't have a |
A change to the signature of a class every Amaranth program uses is a pretty big change! |
Sorry, maybe my example was a bit confusing because of the But maybe this is just me misusing this somehow. |
Sorry, now I'm a lot more confused. Don't you have the components themselves in the hierarchy too? |
I think this is definitely the wrong thing to expose in the surface-level API; we should probably improve the namer instead. |
ill wait for improvements in the namer then |
No description provided.