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

Consider adding Default to Module in dsl.py #197

Closed
RobertBaruch opened this issue Sep 8, 2019 · 5 comments
Closed

Consider adding Default to Module in dsl.py #197

RobertBaruch opened this issue Sep 8, 2019 · 5 comments
Labels
Milestone

Comments

@RobertBaruch
Copy link

It seems to be more consistent with most other commonly-known languages to have the syntax for a default case look like this:

with m.Switch(thing):
  with m.Case(1):
    ...
  with m.Case(2):
    ...
  with m.Default():
    ...

than this:

with m.Switch(thing):
  with m.Case(1):
    ...
  with m.Case(2):
    ...
  with m.Case("default"):
    ...
@whitequark
Copy link
Contributor

Hm, makes sense.

@whitequark
Copy link
Contributor

Actually, hang on.

with m.Case("default"): is not valid in nMigen (this seems to be a mix of syntax from oMigen and nMigen), what you can do is with m.Case():.

@programmerjake
Copy link
Contributor

if with m.Case(): is going to be the way to get a default case, that needs to be documented somewhere, I was not aware that nmigen supported default cases at all.

I personally prefer having a separate Default function, since that is more explicit.

@whitequark
Copy link
Contributor

I think having a Default() function as an alias for Case() is fine.

@whitequark whitequark added this to the 0.1 milestone Sep 8, 2019
@RobertBaruch
Copy link
Author

Ah, ok. I had a suspicion that default wasn't actually supported in nMigen (since I couldn't find "default" in the source) so I fell back to the Migen docs. So now you fixed two issues :D

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

No branches or pull requests

3 participants