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

Accepts '?' in Case, maps to '-' #203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nmigen/hdl/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ def Case(self, *values):
.format(value, len(switch_data["test"])),
SyntaxWarning, stacklevel=3)
continue
if isinstance(value, str):
value = value.replace("?", "-")
new_values = (*new_values, value)
try:
_outer_case, self._statements = self._statements, []
Expand Down
3 changes: 3 additions & 0 deletions nmigen/test/test_hdl_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,15 @@ def test_Switch(self):
m.d.comb += self.c1.eq(1)
with m.Case("11--"):
m.d.comb += self.c2.eq(1)
with m.Case("10??"):
m.d.comb += self.c2.eq(1)
m._flush()
self.assertRepr(m._statements, """
(
(switch (sig w1)
(case 0011 (eq (sig c1) (const 1'd1)))
(case 11-- (eq (sig c2) (const 1'd1)))
(case 10-- (eq (sig c2) (const 1'd1)))
)
)
""")
Expand Down