File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,8 @@ def Case(self, *patterns):
331331 "expression, not {!r}"
332332 .format (pattern )) from e
333333 pattern_len = bits_for (pattern .value )
334+ if pattern .value == 0 :
335+ pattern_len = 0
334336 if pattern_len > len (switch_data ["test" ]):
335337 warnings .warn ("Case pattern '{!r}' ({}'{:b}) is wider than switch value "
336338 "(which has width {}); comparison will never be true"
Original file line number Diff line number Diff line change @@ -494,6 +494,21 @@ class Color(Enum):
494494 )
495495 """ )
496496
497+ def test_Switch_zero_width (self ):
498+ m = Module ()
499+ s = Signal (0 )
500+ with m .Switch (s ):
501+ with m .Case (0 ):
502+ m .d .comb += self .c1 .eq (1 )
503+ m ._flush ()
504+ self .assertRepr (m ._statements , """
505+ (
506+ (switch (sig s)
507+ (case (eq (sig c1) (const 1'd1)))
508+ )
509+ )
510+ """ )
511+
497512 def test_Case_bits_wrong (self ):
498513 m = Module ()
499514 with m .Switch (self .w1 ):
You can’t perform that action at this time.
0 commit comments