Title: Binary-to-BCD Converter
1Binary-to-BCD Converter
- Lecture L6.2
- Section 6.5
- pp. 101-106
2Shift and Add-3 Algorithm
 S1. Shift the binary number left one bit. 22.
If 8 shifts have taken place, the BCD number is
in the Hundreds, Tens, and Units column. 33.
If the binary value in any of the BCD columns is
5 or greater, add 3 to that value in that BCD
column. 44. Go to 1. Â
3Steps to convert an 8-bit binary number to BCD
4Example of converting hex E to BCD
5Truth table for Add-3 Module
A3 A2 A1 A0
C
S3 S2 S1 S0
6K-Map for S3
A1 A0
00
01
11
10
A3 A2
00
01
1
1
1
11
X
X
X
X
10
1
1
X
X
S3 A3 A2 A0 A2 A1
7Binary-to-BCD Converter
8Binary-to-BCD Converter
9MODULE binbcd interface(B7..B0 -gt P9..P0)
TITLE 'binary-bcd converter' DECLARATIONS Cadd3
interface(A3..A0 -gt S3..S0) C1
FUNCTIONAL_BLOCK Cadd3 C2 FUNCTIONAL_BLOCK
Cadd3 C3 FUNCTIONAL_BLOCK Cadd3 C4
FUNCTIONAL_BLOCK Cadd3 C5 FUNCTIONAL_BLOCK
Cadd3 C6 FUNCTIONAL_BLOCK Cadd3 C7
FUNCTIONAL_BLOCK Cadd3
10" INPUT PINS " B7..B0 PIN B
B7..B0 " 8-bit binary input " OUTPUT PINS
" P9..P0 PIN ISTYPE 'com' P P9..P0
" 10-bit BCD output
11EQUATIONS C1.A3 0 C1.A2..A0
B7..B5 C2.A3..A1 C1.S2..S0 C2.A0
B4 C3.A3..A1 C2.S2..S0 C3.A0
___ C4.A3..A1 ___________ C4.A0
___ C5.A3..A1 ___________ C5.A0
___ C6.A3 ___ C6.A2 ______ C6.A1
______ C6.A0 ______ C7.A3..A1
___________ C7.A0 ______
12P9 C6.S3 P8..P5 ___________ P4..P1
___________ P0 ___ _at_radix 16 test_vectors
(B -gt P) 0FF -gt 255 35 -gt 53 0B9 -gt 185 0D5 -gt
213 0E7 -gt ____ 94 -gt ____ 51 -gt ____ END
binbcd
136-Bit Binary-to-BCD Converter
C1.A3 0 C1.A2..A0 B5..B3 C2.A3..A1
C1.S2..S0 C2.A0 B2 C3.A3..A1
C2.S2..S0 C3.A0 B1 P6 C1.S3 P5
C2.S3 P4..P1 C3.S3..S0 P0 B0