Binary to BCD Conversion Algorithm
Purpose:
Conversion of a binary number into separate binary numbers representing digits of the decimal number. (this example is for 8-bits, other sizes follow the same pattern) |
Algorithm:
- If any column (100's, 10's, 1's, etc.) is 5 or greater, add 3 to that column.
- Shift all #'s to the left 1 position.
- If 8 shifts have been performed, it's done! Evaluate each column for the BCD values.
- Go to step 1.
Psuedo-Code:
Algorithm In Action:
BCD Conversion in Hardware:
Verilog: |
沒有留言:
張貼留言