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

Elif without If not recognized in nested If #500

Closed
tpwrules opened this issue Sep 18, 2020 · 1 comment
Closed

Elif without If not recognized in nested If #500

tpwrules opened this issue Sep 18, 2020 · 1 comment
Labels
Milestone

Comments

@tpwrules
Copy link
Contributor

tpwrules commented Sep 18, 2020

The following code snippet does not produce a syntax error and in fact generates without any complaints at all (not sure what the effect is):

s = Signal()
with m.If(1):
    with m.Elif(2):
        m.d.comb += s.eq(3)

I would expect it to raise nmigen.hdl.dsl.SyntaxError: Elif without preceding If like the following snippet does:

s = Signal()
with m.Elif(4):
    m.d.comb += s.eq(5)
@whitequark whitequark added the bug label Sep 21, 2020
@whitequark whitequark added this to the 0.3 milestone Sep 21, 2020
@whitequark
Copy link
Member

whitequark commented Oct 22, 2020

The effect is this:

(switch
  (cat (sig b) (sig a))
   (case -1 (eq (sig s) (const 1'd1)))
   (case 1- ))

so basically (converting back to the notation in your example):

with m.If(2):
    m.d.comb += s.eq(3)

which is pretty weird indeed, and most certainly not remotely what you intended. Great catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants