Circuit implementation of the k-winner machine