Binary to BCD Converter
Some times we need to display the output in a seven-segment display. For that purpose we will convert binary to BCD.
To translate from binary to BCD, we can employ the shift-and-add-3 algorithm:
Left-shift the (n-bit) binary number one bit.
If n shifts have taken place, the number has been fully expanded, so exit the algorithm.
If the binary value of any of the BCD columns is greater than or equal to 5, add 3.
Return to (1).