140 likes | 161 Views
Binary-to-BCD Converter. Lecture L6.2 Section 6.5 pp. 101-106. Shift 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.
E N D
Binary-to-BCD Converter Lecture L6.2 Section 6.5 pp. 101-106
Shift 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.
Truth table for Add-3 Module A3 A2 A1 A0 C S3 S2 S1 S0
K-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
Binary-to-BCD Converter
Binary-to-BCD Converter
MODULE binbcd interface([B7..B0] -> [P9..P0]); TITLE 'binary-bcd converter' DECLARATIONS Cadd3 interface([A3..A0] -> [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;
" INPUT PINS " B7..B0 PIN; B = [B7..B0]; " 8-bit binary input " OUTPUT PINS " P9..P0 PINISTYPE 'com'; P = [P9..P0]; " 10-bit BCD output
EQUATIONS 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 = ______;
P9 = C6.S3; [P8..P5] = ___________; [P4..P1] = ___________; P0 = ___; @radix 16; test_vectors (B -> P) 0FF -> 255; 35 -> 53; 0B9 -> 185; 0D5 -> 213; 0E7 -> ____; 94 -> ____; 51 -> ____; END binbcd
6-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;