hdl.dsl: accept (but warn on) cases wider than switch test value.

Fixes #13.
This commit is contained in:
whitequark 2019-01-13 08:46:28 +00:00
parent cbf7bd6e31
commit 3083c1d6dd
3 changed files with 26 additions and 3 deletions

View file

@ -287,6 +287,18 @@ class DSLTestCase(FHDLTestCase):
msg="Case value '--' must have the same width as test (which is 4)"):
with m.Case("--"):
pass
with self.assertWarns(SyntaxWarning,
msg="Case value '10110' is wider than test (which has width 4); comparison "
"will be made against truncated value"):
with m.Case(0b10110):
pass
self.assertRepr(m._statements, """
(
(switch (sig w1)
(case 0110 )
)
)
""")
def test_Case_outside_Switch_wrong(self):
m = Module()