示例#1
0
 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)
示例#2
0
 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])
示例#3
0
 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)