Professional Documents
Culture Documents
Binary-to-BCD Converter: Basic Idea
Binary-to-BCD Converter: Basic Idea
Basic Idea
Y X 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
X 1 0 1 1 1 0 1 1 1 0 1 1
U*2+X[3]
1 0 1 1 1 0 1 1
Out of range U=U+6; if (U > 4) then U will be Out of range after shift left
8 bits
Binary
F 1 1 1 1
F 1 1 1 1
3
Binary-to-BCD Converter
1 1 1 0 2
1 0 0 0
1 1 1 0 0 0 1 0 1 1 0 5
1 1 1 0 1 0 0 1
1 0 1 0 0 0 0 1 0
1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 1 1 0 1 1 0 5
1 1 1 0 1 0 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1
F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1
F 1 1 1 1 1 1 1 1 1 1 1
Binary-to-BCD Converter
1 1
1 1 1 1 1 1 0 1 1 0 1 0 4
1 1 1 0 0 0
E 1 1 1 0 1 1 0 1 0 0
Binary-to-BCD Converter
Binary
5 4 3 2 1 0 F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
6
7 13 4 3 10 9
3
0 6 5 0
How to implement?
Binary-to-BCD Converter
Operation B HEX Start Shift 1 Shift 2 Shift 3 Add 3 Shift 4 Add 3 Shift 5 Shift 6 BCD P z
Tens
Units
3 1 1 1 1 1 1 1 0 1 0 1 1 0 1 0 1 1 0 0 0 0 0 0 1 0 0 1 1
Binary
5 4 3 2 1 0 F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 B5 B4 B3 B2 B1 B0
1 1 1 1 1
C1
1 0 1 0
C2
1 0 0 0
0
1 1 0
C3
0 0 1 1
1 1 1 1 0
6
7 13 4 3 10 9
3
0 6 5 0
P7 P6 P5 P4 P3 P2 P1 P0
tens units
6 BCD output
Binary-to-BCD Converter
Add-3
S3 S2 S1 S0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 0 0 0 0 1 1 1 1 1 x x x x x x
0 0 0 0 1 0 0 0 0 1 x x x x x x
0 0 1 1 0 0 0 1 1 0 x x x x x x
0 1 0 1 0 0 1 0 1 0 x x x x x x
Binary-to-BCD Converter
K-Map for S3
A3 A2 A1 A0 S3 S2 S1 S0
A1 A0 A3 A2
00
01
11
10
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 0 0 0 0 1 1 1 1 1 x x x x x x
0 0 0 0 1 0 0 0 0 1 x x x x x x
0 0 1 1 0 0 0 1 1 0 x x x x x x
0 1 0 1 0 0 1 0 1 0 x x x x x x
00 01 11 10 x 1 1 x 1 1 x x 1 x x
Binary-to-BCD Converter
exercise
Design a Verilog module to convert an 8-bit binary number to the BCD form.
module Binary_to_BCD_8(P,B); output [9:0] P; //BCD form of B input [7:0] B; . . . endmodule
Binary-to-BCD Converter
10