class Adder(AdderNDecl): io = AdderNDecl.io adders = [mantle.FullAdder() for _ in range(N)] adders = m.fold(adders, foldargs={"CIN": "COUT"}) COUT, O = adders(I0=io.I0, I1=io.I1, CIN=io.CIN) m.wire(O, io.O) m.wire(COUT, io.COUT)
def definition(io): counter_1 = BitCounter8() counter_2 = BitCounter8() wire(io.I[:8], counter_1.I) wire(io.I[8:], counter_2.I) adders = [mantle.HalfAdder()] + [mantle.FullAdder() for _ in range(3)] for i in range(4): wire(counter_1.O[i], adders[i].I0) wire(counter_2.O[i], adders[i].I1) if i > 0: wire(adders[i - 1].COUT, adders[i].CIN) wire(adders[i].O, io.O[i]) wire(adders[-1].COUT, io.O[-1])
def definition(io): adders = [mantle.FullAdder() for _ in range(N)] adders = m.fold(adders, foldargs={"CIN": "COUT"}) COUT, O = adders(I0=io.I0, I1=io.I1, CIN=io.CIN) m.wire(O, io.O) m.wire(COUT, io.COUT)