File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ def on_Switch(self, stmt):
378
378
value = int ("" .join ("0" if b == "-" else b for b in pattern ), 2 )
379
379
gen_checks .append (f"{ value } == ({ mask } & { gen_test } )" )
380
380
else :
381
- value = int (pattern , 2 )
381
+ value = int (pattern or "0" , 2 )
382
382
gen_checks .append (f"{ value } == { gen_test } " )
383
383
if index == 0 :
384
384
self .emitter .append (f"if { ' or ' .join (gen_checks )} :" )
Original file line number Diff line number Diff line change @@ -1064,6 +1064,18 @@ def test_large_expr_parser_overflow(self):
1064
1064
m .d .comb += a .eq (op )
1065
1065
Simulator (m )
1066
1066
1067
+ def test_switch_zero (self ):
1068
+ m = Module ()
1069
+ a = Signal (0 )
1070
+ o = Signal ()
1071
+ with m .Switch (a ):
1072
+ with m .Case ("" ):
1073
+ m .d .comb += o .eq (1 )
1074
+ with self .assertSimulation (m ) as sim :
1075
+ def process ():
1076
+ self .assertEqual ((yield o ), 1 )
1077
+ sim .add_testbench (process )
1078
+
1067
1079
1068
1080
class SimulatorRegressionTestCase (FHDLTestCase ):
1069
1081
def test_bug_325 (self ):
You can’t perform that action at this time.
0 commit comments