Skip to content

Accessing signals defined inside elaborate() without prepending with self. in simulation #1584

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

You must be logged in to vote

No, that's not what I'm talking about. It should be like:

class C(Component):
    o: Out(1)

    def __init__(self):
        self.s = Signal()
        super().__init__()

    def elaborate(self, platform):
        m = Module()
        m.d.sync += self.o.eq(self.s)
        return m

The code you wrote will break if you instantiate the component multiple times, so you shouldn't use it.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@goekce
Comment options

@whitequark
Comment options

Answer selected by goekce
@goekce
Comment options

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