code: def kogge_stone(a, b, cin=0):
      
      a, b = libutils.match_bitwidth(a, b)
  
      prop_orig = a ^ b
      prop_bits = [i for i in prop_orig]
      gen_bits = [i for i in a & b]
      prop_dist = 1
  
      # creation of the carry calculation
      while prop_dist < len(a):
          for i in reversed(range(prop_dist, len(a))):
              prop_old = prop_bits[i]
              gen_bits[i] = gen_bits[i] | (prop_old & gen_bits[i - prop_dist])
              if i >= prop_dist * 2:  # to prevent creating unnecessary nets and wires
                  prop_bits[i] = prop_old & prop_bits[i - prop_dist]
          prop_dist *= 2
  
      # assembling the result of the addition
      # preparing the cin (and conveniently shifting the gen bits)
      gen_bits.insert(0, pyrtl.as_wires(cin))
      return pyrtl.concat_list(gen_bits) ^ prop_orig
docs: Creates a Kogge-Stone adder given two inputs
  
      :param WireVector a, b: The two WireVectors to add up (bitwidths don't need to match)
      :param cin: An optimal carry in WireVector or value
      :return: a Wirevector representing the output of the adder
  
      The Kogge-Stone adder is a fast tree-based adder with O(log(n))
      propagation delay, useful for performance critical designs. However,
      it has O(n log(n)) area usage, and large fan out.