Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

BCD to binary conversion

Hello, I have implemented 32-bit to BCD converter, simple algorithm was easy to find on the internet, doing conversion with single shifting pass through data register. Can you please suggest backward conversion - BCD to 32-bit (e.g. without multiplications)? Thanks!

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Finally found it here http://forums.terraria.org/index.php?threads/project-bcd-to-binary-converter.30458/

    "The double-dabble mechanism is a well known algorithm to convert binary-to-BCD, so reversing the algorithm allows for the reverse conversion. In the reverse algorithm, the information stored in the bits is right shifted, and then any number greater than 7 stored in any of the BCD units is reduced by 3". Simple and clear.

    Was worth of an hour of searching as there were some more sources which are badly explained or just seem to be wrong!