code: def kogge_stone_add(A, B, cin=0):
      
      if len(A) != len(B):
          raise ValueError("expected A and B to be equal length")
      N = len(A)
      # generate/propagate logic
      gs = [A[i] & B[i] for i in range(N)]
      ps = [A[i] ^ B[i] for i in range(N)]
      for i in range(clog2(N)):
          start = 1 << i
          for j in range(start, N):
              gs[j] = gs[j] | ps[j] & gs[j-start]
              ps[j] = ps[j] & ps[j-start]
      # sum logic
      ss = [A[0] ^ B[0] ^ cin]
      ss += [A[i] ^ B[i] ^ gs[i-1] for i in range(1, N)]
      return farray(ss), farray(gs)
docs: Return symbolic logic for an N-bit Kogge-Stone adder.