Logic implementation using a reversible gate