Decimal fraction

advertisement
DIGITAL CIRCUIT
DESIGN
EEE122 A
Ref. Morris MANO & Michael D. CILETTI
DIGITAL DESIGN 4th edition
Fatih University- Faculty of Engineering- Electric and Electronic Dept.
WHAT IS DIGITAL CIRCUIT
Engineers generally classify electronic
circuits as being either analog or digital.
Analog circuit works with sinusoidal
signals
Digital circuit works with discrete signals
Today Most electronic devices are
composed of digital circuits
Advantages of Digital over Analog Circuit
Easier to design using integrated
circuit
Have very effective information
storage
Can be programmed to suite the
required situation
More accurate and of less affected by
electromagnetic noises
APPLICATION OF DIGITAL CIRCUIT
Digital Calculators
Computer systems
Robot system
Measurement devices
Telecommunication systems
Control circuits
Controllers
Number Systems
Decimal Numbers (Base 10)
A decimal number with point is represented by a series of
coefficients as:
... a4 a3 a2 a1 a0.a-1 a-2 a-3...
• The coeffients are any of the digits (0,1,2,3... 9)
• The value of a digit is determined by its position in the
number. Thus the above number can be represented as:
a4104+a3103+a2102+a1101+a0100+a-110-1 +a-210-2+a-310-3
Thus the number 4259.143 can be expressed as:
4x103+2x102+5x101+9x100+1x10-1 +4x10-2+3x10-3
Where 10 is the base or “radix” of the decimal nmbers
Binary Numbers
Decimal
It is composed as
combination of two
digits (0 and 1). The
first few counting in
binary is shown in
the table besides
decimal numbers for
comparison.
Binary
0
0
1
1
2
10
3
11
4
100
5
101
6
110
7
111
8
1000
9
1001
10
1010
11
1011
The weighting structure of binary numbers
... a4 a3 a2 a1 a0.a-1 a-2 a-3...
Positive power of two
(whole number)
Negative power of two
(fractional number)
25
24
23
22
21
20
2-1
32
16
8
4
2
1
1/2 1/4 1/8 1/1 1/3 1/6
6
2
4
0.5
2-2
0.25
2-3
0.125
2-4
0.0625
2-5
0.03125
2-6
0.01562
5
Binary-to-Decimal Conversion
Add the weights of all 1s in a binary
number to get the decimal value.
ex: convert 10101002 to decimal
Weight
26
25
24
23
22
21
20
bin
1
1
0
1
1
0
1
10101002
= 26 + 0 + 24 +0+ 22 +0+0
= 64 + 16 + 4
= 84
Binary-to-Decimal Conversion
Fractional binary example
ex: convert 0.1101 to decimal
Weight
2-1
2-2
2-3
24
bin
1
0
1
1
0.1101
= 2-1 + 2-2 + 2-4
= 0.5 + 0.25 + 0.0625
= 0.8125
Decimal-to-Binary Conversion
(two methods)
1: Sum-of-weights method
• To get the binary number for a given
decimal number, find the binary weights
that add up to the decimal number.
ex: convert 1210 , 2510 , 5810 , 8210 to binary
12
25
58
82
=
=
=
=
8+4 = 23+22 = 1100
16+8+1 = 24+23+20 = 11001
32+16+8+2 = 25+24+23+21 = 111010
64+16+2 = 26+24+21 = 1010010
Decimal-to-Binary Conversion
2: Repeated
division-by-2
method
• To get the binary
number for a given
decimal number,
divide the decimal
number by 2 until
the quotient is 0.
Remainders form
the binary number.
4110 = 1010012
remainder
41/2 = 20
1
20/2 = 10
0
10/2 = 5
0
5/2
= 2
1
2/2
= 1
0
1/2
= 0
1
LSB
MSB
Decimal-to-Binary Conversion
Converting decimal fractions to binary
• Sum-of-weights
This method can be applied to fractional
decimal numbers, as shown in the following
example:
0.625 = 0.5+0.125 = 2-1+2-3 = 0.101
• Repeated multiplication by 2
Decimal fraction can be converted to binary
by repeated multiplication by 2
Repeated Multiplication by 2
ex: convert the decimal fraction 0.3125 to binary
carry
MSB
0.3125 x 2 =
0.625
0
0.625 x 2 =
1.25
1
0.25 x 2 =
0.50
0
LSB
0.50 x 2 =
Continue to the desired number of
decimal places or stop when the
fractional part is all zero
1.00
1
0.312510 = 0.01012
Hexadecimal and Octal
Numbers
Hexadecimal (hex) Numbers
It composed of 16 characters. Digits 0-9
and letters A, B, C, D, E, & F representing
the numbers from 10 -to- 15.
It used as a compact method to express or
display binary numbers.
Hexadecimal is commonly used in
microprocessor impeded systems.
Hexadecimal Numbers
Decimal
Binary
Hexadecimal
0
0000
0
1
0001
1
2
0010
2
3
0011
3
4
0100
4
5
0101
5
6
0110
6
7
0111
7
8
1000
8
9
1001
9
10
1010
A
11
1011
B
12
1100
C
13
1101
D
14
1110
E
15
1111
F
Hexadecimal Numbers
The notation ‘h’ is commonly used in
computer impeded system to stand
for hexadecimal numbers.
example
16h =(16)16 = 000101102
0Dh =(AD)16 = 101011012
Hexadecimal Numbers
Bin-to-Hex Conversion
• Simply break the binary number into 4-bit groups, starting
at the right-most bit and replace each 4-bit group with the
equivalent hex symbol.
(a) 1100101001010111
1100101001010111
C
A
5
= CA5716
7
(b) 111111000101101001
00111111000101101001
3
F
1
= 3F16916
6
9
Hexadecimal Numbers
Hex-to-Bin Conversion
• Reverse the process (of bin-to-hex) and
replace each hex symbol with its
equivalent four bits.
ex: Determine the binary numbers for the following hex
numbers:
(a) 10A4h
1
0
A
4
0001000010100100
(b) CF8Eh
C
F
8
E
1100111110001110
(c) 9742h
9
7
4
2
1001011101000010
Hexadecimal Numbers
Hex-to-Dec Conversion
• 2 methods:
Hex-to-Bin first and then Bin-to-Dec.
Multiply the decimal values of each hex
digits by its weight and then take the sum
of these products.
Hexadecimal Numbers
Hex-to-Dec Conversion
• Hex-to-Bin first and then Bin-to-Dec
ex: Convert the following hex numbers to decimal:
(a) 1Ch
1Ch = 00011100 = 16+8+4 = 2810
(b) A85h
A85h = 101010000101 = 2048+512+128+4+1 = 269310
Hexadecimal Numbers
Hex-to-Dec Conversion
• Multiply the decimal values of each hex digits by its
weight and then take the sum of these products.
ex: Convert the following hex numbers to decimal:
(a) E5h
E5h = (Ex16)+(5x1) = (14x16)+5 = 224+5 = 22910
(b) B2F8h
B2F8h = (Bx4096)+(2x256)+(Fx16)+(8x1)
= (11x4096)+(2x256)+(15x16)+(8x1)
= 45,056+512+240+8 = 45,81610
Hexadecimal Numbers
Dec-to-Hex conversion
• Repeated division of a dec number by
16
ex: Convert the dec number 650 to hex
650/16 = 40.625
40/16 = 2.5
2/16 = 0.125
Stop when whole number
quotient is ZERO.
0.625x16 = 10 = A
0.5x16
=8
0.125x16 = 2
=8
=2
LSD
Hence 65010 = 28A h
MSD
Octal Numbers
Like the hex, the “oct”
provides a convenient
way to express binary
numbers and codes,
but not commonly
used.
It uses 8 digits: 0-7 as
in the table:
Octal Numbers
The conversion to/from other bases follow the same rules
as the hexadecimal ones, examples:
Bin-to-Oct Conversion
(a) 101110101
(b) 1011011001
Grouped into 3 digits and write the equivalent octal number
(a) 101110101
(b) 1011011001
(565)8
(1331)8
Oct-to-Bin Conversion
(a) 138
(b) 258
(c) 75268
(a) 011011 (b) 010101 (c) 111101010110
Oct-to-Dec Conversion
(a) 23748 = 2x83 +3x82 +7x81 + 4x80
=1024+192+56+4=(1276)10
Dec-to-Oct Conversion
(a) 35910 =(447)8
Remainder
359/8
44
7 LSB
44/8
5
4
4/8
0
4
MSB
Binary Arithmetical Operation
• addition
• subtraction
• multiplication
• division
Binary Addition
The four basic rules for adding binary
digits are as follows:
• 0+0=0
• 0+1=1
• 1+0=1
• 1+1=10
11
+11
110
3
+3
6
sum of 0 with a carry of 0
sum of 1 with a carry of 0
sum of 1 with a carry of 0
sum of 0 with a carry of 1
111
+ 11
1010
7
+3
10
110
+100
1010
6
+4
10
Binary Subtraction
The four basic rules for subtracting
binary digits are as follows:
• 0-0
• 1-1
• 1-0
• 10-1
11
-01
10
=
=
=
=
3
-1
2
0
0
1
1 ; 0-1 with a borrow of 1
11
-10
01
3
-2
1
101
-011
010
5
-3
2
Binary Multiplication
The four basic rules for multiplying digits are as
follows:
• 0x0 = 0
0x1 = 0
1x0 = 0 1x1 = 1
Multiplication is performed with binary numbers
in the same manner as with decimal numbers.
• It involves forming partial products, shifting
each successive partial product left one place,
and then adding all the partial products.
11
x11
11
+11
1001
101
x111
101
101
+101
100011
Binary Division
Division in binary follows the same
procedure as division in decimal.
10
11 110
11
000
11
10 110
10
10
10
00
1’s and 2’s Complements
Negative numbers are normally presented in 1’s or 2’s
complement.
The method of 2’s complement arithmetic is commonly
used in computer systems to handle negative numbers
more than 1’s complement.
Diminished Radix complement
1’s
Given a number N in base r having n digits , the (r-1)’s
complement of N is defined as (rn-1)-N.
Radix Complement:
2’s
The r’s complement of an n-digit number N in base r is defined as
(rn-N) for N≠0 and as 0 for N=0
To find the 1’s complement for a given binary number:
Complement every bit in the number the
result is 1’s complement
ex: find 1’s complement of 111001012
Binary
1 1 1 0 0 1 0 1
1’s complement
0 0 0 1 1 0 1 0
To find the 2’s complement for a given binary number:
Add 1 to the 1’s complement to get the 2’s complement.
ex: 10110010 01001101 01001110
Download