怎样将八位二进制转换为bcd码?

来源:百度知道 编辑:UC知道 时间:2024/05/25 10:21:57
如题,电路设计,vhdl程序也可以。

用shift-add-3算法。

Step1: shift the binary number left one bit to BCD number (LSB).

Step2: every four bits of BCD number from the LSB present one bit of decimal number, if the binary value in any of 4-bit BCD columns is greater than 4, add 3 to the value in that BCD column.

Step3: if the last step is add-3, the current step is shift even if binary value of BCD column is greater than 4.

Step4: shift takes place N times. (N = the size of binary number)