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):
378378 value = int ("" .join ("0" if b == "-" else b for b in pattern ), 2 )
379379 gen_checks .append (f"{ value } == ({ mask } & { gen_test } )" )
380380 else :
381- value = int (pattern , 2 )
381+ value = int (pattern or "0" , 2 )
382382 gen_checks .append (f"{ value } == { gen_test } " )
383383 if index == 0 :
384384 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):
10641064 m .d .comb += a .eq (op )
10651065 Simulator (m )
10661066
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+
10671079
10681080class SimulatorRegressionTestCase (FHDLTestCase ):
10691081 def test_bug_325 (self ):
You can’t perform that action at this time.
0 commit comments