File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -383,7 +383,7 @@ def on_Switch(self, stmt):
383
383
value = int ("" .join ("0" if b == "-" else b for b in pattern ), 2 )
384
384
gen_checks .append (f"{ value } == ({ mask } & { gen_test } )" )
385
385
else :
386
- value = int (pattern , 2 )
386
+ value = int (pattern or "0" , 2 )
387
387
gen_checks .append (f"{ value } == { gen_test } " )
388
388
if index == 0 :
389
389
self .emitter .append (f"if { ' or ' .join (gen_checks )} :" )
Original file line number Diff line number Diff line change @@ -1014,6 +1014,19 @@ def test_large_expr_parser_overflow(self):
1014
1014
m .d .comb += a .eq (op )
1015
1015
Simulator (m )
1016
1016
1017
+ def test_switch_zero (self ):
1018
+ m = Module ()
1019
+ a = Signal (0 )
1020
+ o = Signal ()
1021
+ with m .Switch (a ):
1022
+ with m .Case ("" ):
1023
+ m .d .comb += o .eq (1 )
1024
+ with self .assertSimulation (m ) as sim :
1025
+ def process ():
1026
+ yield Settle ()
1027
+ self .assertEqual ((yield o ), 1 )
1028
+ sim .add_process (process )
1029
+
1017
1030
1018
1031
class SimulatorRegressionTestCase (FHDLTestCase ):
1019
1032
def test_bug_325 (self ):
You can’t perform that action at this time.
0 commit comments