Skip to content

Idiomatic way to handle top-level IO from within an Instance in a submodule #1528

Answered by whitequark
fischermoseley asked this question in Q&A
Discussion options

You must be logged in to vote

When you use platform.request(..., dir="-"), you get back a SingleEndedPort object (or possibly a DifferentialPort object, which works the same). Its .io attribute holds an IOValue that you can pass to an Instance like this:

led = platform.request("led", 0, dir="-")
m.submodules += Instance("led_driver_external",
    io_pin=led.io,
    i_value=Const(1),
)

There are a few ways in which you could structure this.

Ideally, I'd like to be able to assign the IOPort to some signal that's an attribute of Bar, and then use.eq to connect that to my top-level IO. However, the IOPort class has no .eq() method, so I'm not able to do this. If the signal didn't have to be bidirectional, I could pass a S…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by fischermoseley
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@whitequark
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #1524 on October 06, 2024 10:14.