@@ -253,7 +253,6 @@ def test_wire_net_removal_1(self):
253
253
outwire = pyrtl .Output ()
254
254
tempwire <<= inwire
255
255
outwire <<= tempwire
256
-
257
256
pyrtl .synthesize ()
258
257
pyrtl .optimize ()
259
258
block = pyrtl .working_block ()
@@ -276,6 +275,49 @@ def test_wire_net_removal_2(self):
276
275
self .assert_num_net (5 , block )
277
276
self .assert_num_wires (6 , block )
278
277
278
+ def test_slice_net_removal_1 (self ):
279
+ constwire = pyrtl .Const (1 , 1 )
280
+ inwire = pyrtl .Input (bitwidth = 1 )
281
+ outwire = pyrtl .Output ()
282
+ outwire <<= constwire ^ inwire
283
+ pyrtl .optimize ()
284
+ block = pyrtl .working_block ()
285
+ self .num_net_of_type ('s' , 0 , block )
286
+ self .num_net_of_type ('~' , 1 , block )
287
+
288
+ def test_slice_net_removal_2 (self ):
289
+ inwire = pyrtl .Input (bitwidth = 3 )
290
+ outwire = pyrtl .Output ()
291
+ tempwire = inwire [0 :3 ]
292
+ outwire <<= tempwire [0 :3 ]
293
+ pyrtl .optimize ()
294
+ block = pyrtl .working_block ()
295
+ self .num_net_of_type ('s' , 0 , block )
296
+ self .num_net_of_type ('w' , 1 , block )
297
+
298
+ def test_slice_net_removal_3 (self ):
299
+ inwire = pyrtl .Input (bitwidth = 3 )
300
+ outwire = pyrtl .Output ()
301
+ tempwire = inwire [0 :2 ]
302
+ outwire <<= tempwire [0 :2 ]
303
+ pyrtl .optimize ()
304
+ # Removes one of the slices, which does nothing.
305
+ block = pyrtl .working_block ()
306
+ self .num_net_of_type ('s' , 1 , block )
307
+ self .num_net_of_type ('w' , 1 , block )
308
+
309
+ def test_slice_net_removal_4 (self ):
310
+ inwire = pyrtl .Input (bitwidth = 4 )
311
+ outwire1 = pyrtl .Output ()
312
+ outwire2 = pyrtl .Output ()
313
+ outwire1 <<= inwire [0 :4 ]
314
+ outwire2 <<= inwire [0 :3 ]
315
+ pyrtl .optimize ()
316
+ # Removes just the outwire1 slice, which does nothing.
317
+ block = pyrtl .working_block ()
318
+ self .num_net_of_type ('s' , 1 , block )
319
+ self .num_net_of_type ('w' , 2 , block )
320
+
279
321
280
322
class TestConstFolding (NetWireNumTestCases ):
281
323
def setUp (self ):
@@ -343,8 +385,8 @@ def test_adv_one_var_op_2(self):
343
385
# Note: the current implementation still sticks a wire net between
344
386
# a register 'nextsetter' wire and the output wire
345
387
self .num_net_of_type ('w' , 1 , block )
346
- self .assert_num_net (4 , block )
347
- self .assert_num_wires (5 , block )
388
+ self .assert_num_net (3 , block )
389
+ self .assert_num_wires (4 , block )
348
390
self .num_wire_of_type (Const , 0 , block )
349
391
self .num_wire_of_type (Output , 1 , block )
350
392
@@ -412,9 +454,9 @@ def test_two_var_op_produce_not(self):
412
454
block = pyrtl .working_block (None )
413
455
self .num_net_of_type ('~' , 1 , block )
414
456
self .num_net_of_type ('w' , 1 , block )
415
- self .num_net_of_type ('s' , 1 , block ) # due to synthesis
416
- self .assert_num_net (3 , block )
417
- self .assert_num_wires (4 , block )
457
+ self .num_net_of_type ('s' , 0 , block )
458
+ self .assert_num_net (2 , block )
459
+ self .assert_num_wires (3 , block )
418
460
self .num_wire_of_type (Const , 0 , block )
419
461
420
462
def test_two_var_op_correct_wire_prop (self ):
@@ -703,7 +745,7 @@ def test_wirevector_1(self):
703
745
outwire <<= ~ tempwire2
704
746
self .everything_t_procedure (48.5 , 48.5 )
705
747
block = pyrtl .working_block ()
706
- self .assert_num_net (3 , block )
748
+ self .assert_num_net (2 , block )
707
749
708
750
def test_combo_1 (self ):
709
751
inwire , inwire2 = pyrtl .Input (bitwidth = 1 ), pyrtl .Input (bitwidth = 1 )
0 commit comments