Turing Trains

 

computational train track layouts

menu

Hamming Weight

The Hamming Weight of a binary number is simply a count of the number of 1's it contains. So the Hamming Weight of 100001 is 2 and 1101 is 3. It is named after Richard Hamming and is used in several logic disciplines including cryptography. Read more at Wikipedia.

The circuit comprises a central Latch register with linked Clear and a lower Count Up function.

Linked Functions

Note that the Latch and the Clear functions are linked together. Linking points in different functions allows more than one function to act on a single register. In this circuit, the Latch and Counter are cleared by the train before computation begins.

Operation

  1. Set upper n register to test number (0 to 127).
  2. Start train from the station.
  3. The Latch and Sum registers are cleared before calculation begins.
  4. When the train returns to platform 1 and halts, the Hamming Weight is shown in lower Sum register.
  5. If the train returns to platform 0, then an overflow error has occoured.

This layout illustrates how registers can be automatically cleared by the train before commencing a calculation. This technique can be applied to any computational layout and is important for accurate and repeatable calculations. However, it does take up time and web page space, so some layouts have to be cleared by clicking the train in its start position.

The Latch register allows the train to 'pick up where it left off' and return to the last 1 that was read out to the Counter.

Layout to calculate Hamming Weight
Hamming number function
Click grass to pause/run train Click points to switch 0/1 Click start to reset train/points

Turing Trains | cr31.co.uk | 2017

 

use your browsers 'zoom' option to enlarge layouts