# inputs and outputs
pass
+ def popcount(self, sig):
+ result = 0
+ for i in range(sig.width):
+ result = result + sig[i]
+ return result
+
def elaborate(self, platform):
m = Module()
comb = m.d.comb
b = dut.i.b
carry_in = dut.i.carry_in
so_in = dut.i.so
- carry_out = dut.o.carry_out
o = dut.o.o
# setup random inputs
with m.Case(InternalOp.OP_XOR):
comb += Assert(dut.o.o == a ^ b)
+ with m.Case(InternalOp.OP_POPCNT):
+ #comb += Assume(a < ((1<<64)-1))
+ with m.If(rec.data_len == 8):
+ comb += Assert(dut.o.o == self.popcount(a))
+
+
return m
# creating arrays big enough to store the sum, each time
pc = [a]
# QTY32 2-bit (to take 2x 1-bit sums) etc.
- work = [(32, 2), (16, 3), (8, 4), (4, 5), (2, 6), (1, 6)]
+ work = [(32, 2), (16, 3), (8, 4), (4, 5), (2, 6), (1, 7)]
for l, b in work:
pc.append(array_of(l, b))
pc8 = pc[3] # array of 8 8-bit counts (popcntb)