-----------------
Gray code counter
-----------------

Taken from the book "Clause and Effect" Chapter 8
