The Binary Adder:
Andy Long
Spring, 2020 - Year of Covid-19
Having constructed a
working example of a finite state machine (FSM), from Gersting's 7th edition (p. 730, Example 29), I decided to create a more useful one -- a binary adder (p. 732). It works!
Subject to these rules:
- Your two binary numbers should start off the same length -- pad with zeros if necessary. Call this length L.
- Now pad your two binary numbers with three extra 0s at the end; this lets the binary-to-decimal conversion execute.
- numbers are entered from ones place (left to right).
- In Settings, choose "simulation start" as 1, your "simulation length" as L+2 -- two more than the length of your initial input number vectors. (I wish that the Settings issues could be set without having to explicitly change it each time -- maybe it can, but I don't know how.)
Be attentive to order -- start with 1s place, 2s place, 4s, place, etc., and your output answer will be read in the same order.
To understand why we need three additional inputs of 0s:
- For the useless first piece of output -- so n -> n+1
- For the possibility of adding two binary numbers and ending up with an additional place we need to force out: 111 + 111 = 0 1 1 1
- For the delay in computing the decimal number: it reads the preceding output to compute the decimal value.