Skip to content

Commit b767fbf

Browse files
committed
pack_multi() is renamed as pack(). Old pack() is removed.
1 parent 4086835 commit b767fbf

File tree

1 file changed

+7
-49
lines changed

1 file changed

+7
-49
lines changed

veriloggen/lib/pipeline.py

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -444,48 +444,7 @@ def pack_valid(self, lvalid, rvalid):
444444
def pack_ready(self, lready, rready):
445445
return lready + rready
446446

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):
489448
rslts = [ self.visit(arg) for arg in args ]
490449
all_stage_none = reduce(lambda t,x:t and x is None, [ rslt[0] for rslt in rslts ], True)
491450

@@ -549,36 +508,35 @@ def visit__Constant(self, node):
549508
return (None, node, None, [])
550509

551510
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)
553512
cls = type(node)
554513
return stage, cls(*data), valid, ready
555514

556515
def visit__UnaryOperator(self, node):
557516
return self.visit(node.right)
558517

559518
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)
561520
cls = type(node)
562521
return stage, cls(*data), valid, ready
563522

564523
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)
566525
cls = type(node)
567526
return stage, cls(*data), valid, ready
568527

569528
def visit_Cat(self, node):
570-
stage, data, valid, ready = self.pack_multi(*node.vars)
529+
stage, data, valid, ready = self.pack(*node.vars)
571530
cls = type(node)
572531
return stage, cls(*data), valid, ready
573532

574533
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)
576535
cls = type(node)
577536
return stage, cls(*data), valid, ready
578537

579538
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)
582540
cls = type(node)
583541
return stage, cls(*data), valid, ready
584542

0 commit comments

Comments
 (0)