参考二进制转BCD码
数字逻辑电路中经常遇到二级制转换为BCD码的要求,比如显示数码管什么的,这是为了方便人们的固有计数模式。这里学习一个移位加3法
举个例子(一下直接贴原文了,加上小白的翻译)
2.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)
目的:
二进制数分别用十进制来转换代替
(这个例子是用于8位二进制数,其他位数的二进制数的转换也是按照相同的规则)
3.Algorithm: 算法
If any column (100's, 10's, 1's, etc.) is 5 or greater, add 3 to that column.
如果一个纵列(比如百位,十位,个位,等等)等于5或者大于5,就在这个纵列加3
Shift all #'s to the left 1 position.
向左移所有的位置一个位
If 8 shifts have been performed, it's done! Evaluate each column for the BCD values.
如果8次左移已经完成,核查下在每一个纵列对应的BCD码是否正确
Go to step 1.
如果没有达到8次,则回到步骤1
4.Algorithm In Action: 算法行为图
5.BCD Conversion in Hardware: BCD码转换的硬件语言描述
6 9.1版本波形结果