BinarytoBCD Converter Lecture L 6 2 Section 6

Binary-to-BCD Converter Lecture L 6. 2 Section 6. 5 pp. 101 -106

Shift and Add-3 Algorithm S 1. 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.

Steps to convert an 8 -bit binary number to BCD

Example of converting hex E to BCD

Truth table for Add-3 Module A 3 A 2 A 1 A 0 C S 3 S 2 S 1 S 0

K-Map for S 3 A 1 A 0 A 3 A 2 00 01 11 10 1 1 1 00 01 11 X X 10 1 1 X X S 3 = A 3 # A 2 & A 0 # A 2 & A 1

Binary-to-BCD Converter

Binary-to-BCD Converter
![MODULE binbcd interface([B 7. . B 0] -> [P 9. . P 0]); TITLE MODULE binbcd interface([B 7. . B 0] -> [P 9. . P 0]); TITLE](http://slidetodoc.com/presentation_image_h/28ed68141b72819057be0ac8a065a7e3/image-9.jpg)
MODULE binbcd interface([B 7. . B 0] -> [P 9. . P 0]); TITLE 'binary-bcd converter' DECLARATIONS Cadd 3 interface([A 3. . A 0] -> [S 3. . S 0]); C 1 FUNCTIONAL_BLOCK Cadd 3; C 2 FUNCTIONAL_BLOCK Cadd 3; C 3 FUNCTIONAL_BLOCK Cadd 3; C 4 FUNCTIONAL_BLOCK Cadd 3; C 5 FUNCTIONAL_BLOCK Cadd 3; C 6 FUNCTIONAL_BLOCK Cadd 3; C 7 FUNCTIONAL_BLOCK Cadd 3;

" INPUT PINS " B 7. . B 0 PIN; B = [B 7. . B 0]; " 8 -bit binary input " OUTPUT PINS " P 9. . P 0 PIN ISTYPE 'com'; P = [P 9. . P 0]; " 10 -bit BCD output

![P 9 = C 6. S 3; [P 8. . P 5] [P 4. P 9 = C 6. S 3; [P 8. . P 5] [P 4.](http://slidetodoc.com/presentation_image_h/28ed68141b72819057be0ac8a065a7e3/image-12.jpg)
P 9 = C 6. S 3; [P 8. . P 5] [P 4. . P 1] P 0 = ___; = ___________; @radix 16; test_vectors (B -> P) 0 FF -> 255; 35 -> 53; 0 B 9 -> 185; 0 D 5 -> 213; 0 E 7 -> ____; 94 -> ____; 51 -> ____; END binbcd

6 -Bit Binary-to-BCD Converter C 1. A 3 = 0; C 1. [A 2. . A 0] = [B 5. . B 3]; C 2. [A 3. . A 1] = C 1. [S 2. . S 0]; C 2. A 0 = B 2; C 3. [A 3. . A 1] = C 2. [S 2. . S 0]; C 3. A 0 = B 1; P 6 = C 1. S 3; P 5 = C 2. S 3; [P 4. . P 1] = C 3. [S 3. . S 0]; P 0 = B 0;
- Slides: 13