Design a Mealy machine to add two integer(binary number).
I can not determine how to deal with the carry.And what to do with the last carry generated.
Design a Mealy machine to add two integer(binary number).
I can not determine how to deal with the carry.And what to do with the last carry generated.
Something like this:
Edit. The two numbers are written in inverse binary notation and you may need to add an extra zero in the front. For instance, suppose you want to add $22$ and $13$. In binary notation, $22$ is $10110$ and $13$ is $1101$. In inverse binary notation, $22$ is $01101$ and $13$ is $1011$. Add $0$ at the end of $01101$ and $00$ at the end of $1011$ and then write the two numbers as follows $$ \begin{matrix} 0&1&1&0&1&0 \\ 1&0&1&1&0&0 \end{matrix} $$ Starting from the initial state, you now have the following path $$ 0 \xrightarrow{(0,1)\mid 1} 0 \xrightarrow{(1,0)\mid 1} 0 \xrightarrow{(1,1)\mid 0} 1 \xrightarrow{(0,1)\mid 0} 1 \xrightarrow{(1,0)\mid 0} 1 \xrightarrow{(0,0)\mid 1} 0 $$ Giving the output $110001$ which is $35$ in reverse binary notation.