DLD 01 Introduction
DLD 01 Introduction
Introduction
Riasat Azim
United International University
Outline of this lecture
U • Base conversions
Decimal ↔ Binary
I
–
– Any base → Decimal
U – Octal ↔ Binary
– Hexadecimal ↔ Binary
• Binary Codes
• Binary Coded Decimal (BCD)
• Binary arithmetic
– Single Bit Addition with Carry
– Multiple Bit Addition
Aug 3, 2024 – BCD Addition
CSE 1325: Digital Logic Design 2
Binary Representation of Numbers
U • 231.45 =
• Here, 10 is called the radix or base of the number system
I •
•
In 10-base systems, there are 10 symbols (‘0’, ‘1’, … , ‘9’)
In n-base system, there are n symbols (‘0’, ‘1’, … , ‘n-1’)
3
Class Room Practice
4
Decimal to Binary
I
U • Hence, 14 = 1110
• For fractional part, we have to divide by ½ or
multiply by 2.
U
I To convert from one base to another:
U • Convert 46 to Base 2
I
U • Convert 0.6875 to Base 2:
I
U • 17.375 = 10001.011 (binary)
I Binary 2 0,1
U Octal
Decimal
8
10
0,1,2,3,4,5,6,7
0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
U 02
03
04
00010
00011
00100
02
03
04
02
03
04
05 00101 05 05
06 00110 06 06
07 00111 07 07
08 01000 10 08
09 01001 11 09
10 01010 12 0A
11 01011 13 0B
12 01100 14 0C
13 01101 15 0D
14 01110 16 0E
15 01111 17 0F
16 10000 20 10
Aug 3, 2024 CSE 1325: Digital Logic Design 15
Octal ↔ Binary
U •
•
8-base number system
8 symbols (0, 1, 2, 3, 4, 5, 6, 7)
I •
•
Base/radix is power of 2
One-to-one relation between octal and binary
U
U • Octal to Binary:
Restate the octal as three binary digits
–
I starting at the radix point and going both
ways.
U • Binary to Octal:
– Group the binary digits into three bit
groups starting at the radix point and
going both ways, padding with zeros as
needed in the fractional part.
– Convert each group of three bits to an
octal digit.
U
I
U
U •
•
16-base number system
16 symbols (0—9, A, B, C, D, E)
•
I
Again radix is power of 2
• 4 bits to represent a hexadecimal number
U
I
U
U • Flexibility of representation
–Within constraints below, can assign any
I binary combination (called a code word)
to any data as long as data is uniquely
U encoded.
• Information Types
– Numeric
• Must represent range of data needed
• Very desirable to represent data such that simple,
straightforward computation for common arithmetic
operations permitted
• Tight relation to binary numbers
– Non-numeric
• Greater
CSEflexibility since
1325: Digital Logic arithmetic
Design operations not 22
Aug 3, 2024
applied.
Non-numeric Binary Codes
I
relationships:
2n > M > 2(n – 1)
n = log2 M where x , called the ceiling
U function, is the integer greater than or equal
to x.
• Example: How many bits are required to represent decimal
digits with a binary code?
I are useful:
Decimal 8,4,2,1 Excess3 8,4,-2,-1 Gray
U 0
1
0000
0001
0011
0100
0000
0111
0000
0100
2 0010 0101 0110 0101
3 0011 0110 0101 0111
4 0100 0111 0100 0110
5 0101 1000 1011 0010
6 0110 1001 1010 0011
7 0111 1010 1001 0001
8 1000 1011 1000 1001
9 1001 1100 1111 1000
I Carry in (Z) of 0: Z
X
0
0
0
0
0
1
0
1
U +Y
CS
+0
00
+1
01
+0
01
+1
10
Carry in (Z) of 1: Z 1 1 1 1
X 0 0 1 1
+Y +0 +1 +0 +1
CS 01 10 10 11
U
I
U
I
0001 1000 1001 0111
U + 0010 1001 0000 0101