@@ -444,48 +444,7 @@ def pack_valid(self, lvalid, rvalid):
444
444
def pack_ready (self , lready , rready ):
445
445
return lready + rready
446
446
447
- def pack (self , left , right ):
448
- rstage , rdata , rvalid , rready = self .visit (right )
449
- lstage , ldata , lvalid , lready = self .visit (left )
450
-
451
- data = [ ldata , rdata ]
452
- valid = self .pack_valid (lvalid , rvalid )
453
- ready = self .pack_ready (lready , rready )
454
-
455
- if rstage is None and lstage is None :
456
- return (None , data , valid , ready )
457
- if rstage is None :
458
- return (lstage , data , valid , ready )
459
- if lstage is None :
460
- return (rstage , data , valid , ready )
461
-
462
- if lstage > rstage :
463
- diff = lstage - rstage
464
- p = right
465
- for i in range (diff ):
466
- width = rdata .bit_length ()
467
- p = self .pipe .stage (p , width = width )
468
- data = [ ldata , p .data ]
469
- valid = self .pack_valid (lvalid , p .valid )
470
- rready = [] if p .ready is None else [ p .ready ]
471
- ready = self .pack_ready (lready , rready )
472
- return (max (lstage , rstage ), data , valid , ready )
473
-
474
- if lstage < rstage :
475
- diff = rstage - lstage
476
- p = left
477
- for i in range (diff ):
478
- width = ldata .bit_length ()
479
- p = self .pipe .stage (p , width = width )
480
- data = [ p .data , rdata ]
481
- valid = self .pack_valid (p .valid , rvalid )
482
- lready = [] if p .ready is None else [ p .ready ]
483
- ready = self .pack_ready (lready , rready )
484
- return (max (lstage , rstage ), data , valid , ready )
485
-
486
- return (max (lstage , rstage ), data , valid , ready )
487
-
488
- def pack_multi (self , * args ):
447
+ def pack (self , * args ):
489
448
rslts = [ self .visit (arg ) for arg in args ]
490
449
all_stage_none = reduce (lambda t ,x :t and x is None , [ rslt [0 ] for rslt in rslts ], True )
491
450
@@ -549,36 +508,35 @@ def visit__Constant(self, node):
549
508
return (None , node , None , [])
550
509
551
510
def visit__BinaryOperator (self , node ):
552
- stage , data , valid , ready = self .pack_multi (node .left , node .right )
511
+ stage , data , valid , ready = self .pack (node .left , node .right )
553
512
cls = type (node )
554
513
return stage , cls (* data ), valid , ready
555
514
556
515
def visit__UnaryOperator (self , node ):
557
516
return self .visit (node .right )
558
517
559
518
def visit_Pointer (self , node ):
560
- stage , data , valid , ready = self .pack_multi (node .var , node .pos )
519
+ stage , data , valid , ready = self .pack (node .var , node .pos )
561
520
cls = type (node )
562
521
return stage , cls (* data ), valid , ready
563
522
564
523
def visit_Slice (self , node ):
565
- stage , data , valid , ready = self .pack_multi (node .var , node .msb , node .lsb )
524
+ stage , data , valid , ready = self .pack (node .var , node .msb , node .lsb )
566
525
cls = type (node )
567
526
return stage , cls (* data ), valid , ready
568
527
569
528
def visit_Cat (self , node ):
570
- stage , data , valid , ready = self .pack_multi (* node .vars )
529
+ stage , data , valid , ready = self .pack (* node .vars )
571
530
cls = type (node )
572
531
return stage , cls (* data ), valid , ready
573
532
574
533
def visit_Repeat (self , node ):
575
- stage , data , valid , ready = self .pack_multi (node .var , node .times )
534
+ stage , data , valid , ready = self .pack (node .var , node .times )
576
535
cls = type (node )
577
536
return stage , cls (* data ), valid , ready
578
537
579
538
def visit_Cond (self , node ):
580
- stage , data , valid , ready = self .pack_multi (node .condition ,
581
- node .true_value , node .false_value )
539
+ stage , data , valid , ready = self .pack (node .condition , node .true_value , node .false_value )
582
540
cls = type (node )
583
541
return stage , cls (* data ), valid , ready
584
542
0 commit comments