fyse410 digital electronics - jyväskylän...
TRANSCRIPT
FYSE410 DIGITAL ELECTRONICS
Litterature:
DIGITAL DESIGN
M. Morris Mano
Michael D. Ciletti
[2]
DIGITAL LOGIC CIRCUIT ANALYSIS
& DESIGN
Victor P. Nelson, H. Troy Nagle
J. David Irwin, Bill D. Carroll
[1]
ISBN 0-13-463894-8
LECTURE 1
©Loberg
Digital Logic Design
A. P. Godse
D. A. Godse
[4]
ISBN 0-13-198924-3
Introduction ToDigital Techniques
Dan I. Porat
Arpad Barna
[3]
ISBN 0-471-02924-6
Digital DesignPrinciples and Practices
John F. Wakerly
[5]
ISBN 0-13-186389-4
LECTURE 1
1
NUMBER SYSTEMS AND CODES Number Systems
A number system consists of an ordered set of symbols (digits).
Positional Notation
(((( ))))rm21012n1n aaa.aaaaN −−−−−−−−−−−−−−−−−−−− ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅====
n integer digits m fractional digits[1]
The total number of digits allowed in the number system is called
base or radix (r)
Addition
Subraction
Multiplication
Division ÷÷÷÷××××−−−−++++
1na −−−−
ma−−−−
Most significant digit
Least significant digit
©Loberg
2
NUMBER SYSTEMS AND CODES
(((( ))))21012
10
105103103102101
01.051.0313102100135.123N
−−−−−−−− ××××++++××××++++××××++++××××++++××××====
××××++++××××++++××××++++××××++++××××========
Number Systems
Polynomial Notation
For desimal number : {{{{ }}}}9,8,7,6,5,4,3,2,1,0aand10r i ========
∑∑∑∑−−−−
−−−−========
1n
mi
i
iraN
[1]
©Loberg
3
NUMBER SYSTEMS AND CODES
Commonly Used Number Systems
Desimal number : {{{{ }}}}9,8,7,6,5,4,3,2,1,0aand10r i ========
Number Systems
Binary number : {{{{ }}}}1,0aand2r i ========
Octal number : {{{{ }}}}7,6,5,4,3,2,1,0aand8r i ========
Hexadecimal number : {{{{ }}}}F,E,D,C,B,A,9,8,7,6,5,4,3,2,1,0aand16r i ========
[1]
©Loberg
4
NUMBER SYSTEMS AND CODES
LSBMSB
023272
18128
Byte
bit8Byte1 ====
Unsigned positive numbers
0123456
01
1011
100101110
0123456
0123456
Decimal Binary Octal Hexadecimal
Bit
1or0bitOne
Number Systems
Commonly Used Number Systems
6789
10111213141516
110111
10001001101010111100110111101111
10000
67
101112131415161720
6789ABCDEF
10
First seventeen positive integers[1]
Word
LSBMSB
0272152
1281024
122
409632768
Kb32
bits102432 ××××
bitsK1
1
bit16Byte2Word1 ========
Kb4
For example the size of memory : the number of
one bit memory locations.
©Loberg
5
NUMBER SYSTEMS AND CODES Arithmetic
Binary Arithmetic Addition
0 0
1
0
10
1
1
1
+
Binary addition table
1Carry011
101
110
000
========++++====++++====++++====++++
Unsigned positive numbers
111010
101111
0010101
111111
+
Carry
Augend
Addend
Sum
Example (((( )))) (((( )))) 10101022 84236110111111101 ====++++====++++
(((( ))))(((( )))) (((( )))) (((( ))))222 110110
111111
====++++++++++++====++++++++
[1]
©Loberg
6
NUMBER SYSTEMS AND CODES
Example
(((( )))) (((( )))) (((( )))) (((( )))) 10101010102222 12817135345010001001101110101101101 ====++++++++++++====++++++++++++
101011
101101
1
The computation is easily performed by adding the numbers in pairs.
Unsigned positive numbers
Arithmetic
Binary Arithmetic Addition
100010
101100
101011
+101011
101101
0100011
1111
+ 100010
101100
011110
1
+
Sum
0111100
0100011
00000001
+
111111
[1]
©Loberg
7
NUMBER SYSTEMS AND CODES
Example(((( )))) (((( )))) (((( )))) (((( ))))2222 010001001101110101101101 ++++++++++++
We can also perform the addition directly to avoid the intermediate steps.
Unsigned positive numbers
Arithmetic
Binary Arithmetic Addition
(((( )))) (((( )))) (((( )))) (((( )))) (((( ))))222 100101011111111 ====++++====++++++++++++====++++++++++++100010
101100
101011
101101
+
10110101010
00000001
(((( ))))210000010 ====++++++++++++++++(((( )))) (((( )))) (((( )))) (((( )))) (((( ))))222 10001010111101111 ====++++++++====++++++++++++====++++++++++++++++
(((( )))) (((( )))) (((( )))) (((( )))) (((( )))) (((( ))))2222 1001010010110010110 ====++++====++++++++++++++++====++++++++++++++++
(((( )))) (((( )))) (((( )))) (((( )))) (((( )))) (((( ))))2222 1001010101010101010 ====++++====++++++++++++++++====++++++++++++++++
(((( )))) (((( )))) (((( )))) (((( )))) (((( )))) (((( ))))2222 1001010001110001110 ====++++====++++++++++++++++====++++++++++++++++
[1]
©Loberg
8
NUMBER SYSTEMS AND CODES
Subtraction
Unsigned positive numbers
Example(((( )))) (((( )))) 10101022 542377101111001101 ====−−−−====−−−−
0124 356
1 10 Borrows
Column
Arithmetic
Binary Arithmetic
1110or1ofborrowawith110
000
011
101
====−−−−====−−−−====−−−−====−−−−====−−−−
1011001
11101
0
0
1
1000
10
10 10
11 Difference
Subtrahend
Minuend
Borrows
[1]
©Loberg
9
NUMBER SYSTEMS AND CODES
Multiplication
Unsigned positive numbers
0 0
1
0
1
1
0
0
x
Example
(((( )))) (((( )))) 10101022 2301023101010111 ====++++====××××
0101
11101
x 0101
11101
x
Arithmetic
Binary Arithmetic
[1]
1 10
Binary Multiplication table
0101
00000
x
11101
0000011101
000 1 1111
0101x
111011
11101000 1 1111
1 1
We don't need to list an all-zero partial
product for a multiplier bit of 0.
(((( )))) 1010 230243264128 ====++++++++++++++++
©Loberg
10
NUMBER SYSTEMS AND CODES
Division
Unsigned positive numbers
Example : Divide
(((( )))) 102 1191110111 ==== (((( )))) 102 91001 ====by
Example : Divide
(((( )))) 102 651000001 ==== (((( )))) 102 131101 ====by
1011
DivisorQuotient 13====
1011 1000001
1010 105====
Arithmetic
Binary Arithmetic
01
1101
1001 11101111011
1001
1001
10011101
Dividend
Reminder 2====0
1
00001
1011 10000010000
1011
1011
0110000000011000
100====
[1]
©Loberg
11
NUMBER SYSTEMS AND CODES
Octal Arithmetic Addition
Unsigned positive numbers
Example (((( )))) (((( ))))88 75204163 ++++
10
0123
8
216313866415124
838681844163
====××××++++××××++++××××++++××××====××××++++××××++++××××++++××××====
0123
8 808285877520 ××××++++××××++++××××++++××××====
Arithmetic
Octal addition table 10392010826455127 ====××××++++××××++++××××++++××××====
Carries
Augend
Addend
Sum
3614
1+ 7 5 2 0
3 7 0 3
1 1
[1]
©Loberg
12
NUMBER SYSTEMS AND CODES
Subtraction
Example (((( )))) (((( ))))88 51736204 −−−−
10
0123
8
320414806425126
848082866204
====××××++++××××++++××××++++××××====××××++++××××++++××××++++××××====
Borrows
Minuend
Subtrahend
4026+ 5 1 7 3
101
Arithmetic
Octal Arithmetic
Unsigned positive numbers
10
0123
8
268313876415125
838781855173
====××××++++××××++++××××++++××××====××××++++××××++++××××++++××××====
Subtrahend
Difference
+ 5 1 7 3
1 0 1 1
[1]
©Loberg
13
NUMBER SYSTEMS AND CODES
Multiplication
10
0123
8
216717866415124
878681844167
====××××++++××××++++××××++++××××====××××++++××××++++××××++++××××====
10
0123
8
134713806455122
838085822503
====××××++++××××++++××××++++××××====××××++++××××++++××××++++××××====
Example (((( )))) (((( ))))88 25034167 ××××7614
+
51 5
32 0
15
402
4
54
0
0 0 02 3
x
13 50530 51 6
1
Multiplicand
Multiplier
Partial products
Product
Arithmetic
Octal Arithmetic
Unsigned positive numbers
[1]
Octal multiplication table
10134713806455122 ====××××++++××××++++××××++++××××====
10
0234567
8 2918949858480858081838113105045 ====××××++++××××++++××××++++××××++++××××++++××××++++××××++++××××====
©Loberg
14
NUMBER SYSTEMS AND CODES
Division
Example : Divide (((( )))) 108 21634163 ==== (((( )))) 108 2125 ====by
52 3614
741Dividend
Quotient012
8 878481147 ××××++++××××++++××××====
Arithmetic
Octal Arithmetic
Unsigned positive numbers
[1]
641
852 8361452
421322
000322
Reminder
Dividend
10
8
1031784641
878481147
====××××++++××××++++××××====××××++++××××++++××××====
©Loberg
15
NUMBER SYSTEMS AND CODES
Hexadecimal Arithmetic Addition
Example (((( )))) (((( ))))1616 0D7158A2 ++++
Arithmetic
Unsigned positive numbers
[1]
Carries
Augend
Addend
Sum
85A2+7 1 D09C 2 8
1
Hexadecimal addition table
©Loberg
16
NUMBER SYSTEMS AND CODES
Borrows
Minuend
Subtrahend
B1F9- 4 A 3 6
11E
Unsigned positive numbers
Subtraction
Example (((( )))) (((( ))))1616 36A4B1F9 ++++
Arithmetic
Hexadecimal Arithmetic
Difference
-5 4 E5
[1]
©Loberg
17
NUMBER SYSTEMS AND CODES
Multiplication
A2C51 07 Dx
Multiplicand
Multiplier
Example (((( )))) (((( ))))1616 0D71A2C5 ××××
Arithmetic
Hexadecimal Arithmetic
Unsigned positive numbers
Hexadecimal Multiplication table
+
1
2
07 D
C5E0
2
2
A4
9
0 0 0
A
F8 0C658 22 6
2
Partial
products
Product
2
[1]
©Loberg
18
NUMBER SYSTEMS AND CODES
Division
C31
16E3 16ACF72
15A
C62
631
Dividend
Quotient
Example : Divide (((( ))))16FCA27 (((( ))))16E3by
Arithmetic
Hexadecimal Arithmetic
Unsigned positive numbers
[1]
C31631A6
C2E3
Reminder
©Loberg
19
NUMBER SYSTEMS AND CODES Base Conversion
We have numbers NA and NBAssumption: {{{{ }}}},...3,2,1k,AB k ========
Group the digits of N in groups of k digits in both directions from the radix point
and then replace each group with the equivalent digit in base B.
82ABand2A 33 ================Examples : Binary to Octal
0110110011011011 →→→→ 1331011011 →→→→
Conversion :BA NN →→→→BA <<<<
[1]
01101100110110112 →→→→
81 83 8382 1331011011 →→→→
85
100011101.011011001101011100.1011011 2 →→→→81 83 83 83 84
82 534.133101011100.1011011 ====
©Loberg
20
NUMBER SYSTEMS AND CODES
Assumption: {{{{ }}}},...3,2,1k,AB k ========
Replace each base B digit in N with equivalent k digits in base A.
44 2A16Band2A ================Example : Hexadecimal to Binary 4k ====
BA NN ←←←←
Base Conversion
Conversion :
BA <<<<
216 110001100001.11111010C16.AF →→→→ Replace each base 16 digit in N 16 withequivalent 4 digits in base 2 .
4k ====
33 2A8Band2A ================Example : Octal to Binary 3k ====
28 100101101000.1111010100554.257 ==== Replace each base 8 digit in N 8 withequivalent 3 digits in base 2 .
[1]
©Loberg
21
NUMBER SYSTEMS AND CODES
Assumption:34 2Aand2B ========Hexadecimal to Octal
000001011011.10101111110001100001.11111010C16.AF ====→→→→
Example : Convert16C16.AF to base 8
Base Conversion
BA NN ←←←←Conversion :
[1]
2216 000001011011.10101111110001100001.11111010C16.AF ====→→→→A C1 6F
8
2
0554.257
100101101000.111101010
====
©Loberg
22
NUMBER SYSTEMS AND CODES
Conversion : Radix Divide MethodBA NN →→→→
For integers
(((( )))) 0
0
1n
1nAI Bb...BbN ++++++++==== −−−−−−−−
Integer in base AThe bi 's represent the digits of (NI)B in base A
Example : Convert10234 to base 8
Base Conversion
[1]
(((( ))))(((( ))))
0
0
1
2n
1n
0
0
1
1
1n
1n
A
AI
bBb...Bb
B
BbBb...Bb
B
N
++++++++++++====
++++++++====
−−−−−−−−
−−−−−−−−
Quotient Q1 Reminder R0
Quotient Q2Reminder R1
Quotient Q3 Reminder R2
Stop when Quotient is zero
(((( ))))A1 BQ====
(((( ))))A2 BQ====
102341029
108167472
0b2 ====
1029103
10824
1b5 ====
103100
1080
2b3 ====
810 352234 ====
©Loberg
23
NUMBER SYSTEMS AND CODES
Example : Convert10234 to base 16
102341014
101616
1014100
10160
Base Conversion
Conversion : Radix Divide Method
For integers
[1]
102341016167464
(((( )))) 01610 bA10 ========
101410160
(((( )))) 116 bE14 ========
1610 EA234 ====
©Loberg
24
NUMBER SYSTEMS AND CODES
For fractoins
(((( )))) m
m
2
2
1
1AF Bb...BbBbN −−−−−−−−
−−−−−−−−
−−−−−−−− ++++++++====
The fraction can be written in series form.
The bi 's represent the digits of (NF)B in base AFraction in base A
Base Conversion
Conversion : Radix Multiply Method
[1]
Fraction in base A
(((( )))) (((( ))))(((( ))))1m
m
1
21
m
m
2
2
1
1AAFA
Bb...Bbb
Bb...BbBbBNB
−−−−−−−−−−−−
−−−−−−−−−−−−
−−−−−−−−
−−−−−−−−
−−−−−−−−
++++++++====
++++++++××××====××××
©Loberg
25
NUMBER SYSTEMS AND CODES
Example : Convert101285.0 to base 8
100280.0
108
102240.0
101285.0
108
100280.1×××× ××××
102240.0
108
107920.1××××
107920.0
108
103360.6××××
103360.0
108
106880.2××××
106880.0
108
105040.5××××
105040.0
108
100320.4××××
100320.0
108
102560.0××××
Base Conversion
Conversion : Radix Multiply Method
For fractoins
[1]
1b−−−− 2b−−−− 3b−−−− 4b−−−− 5b−−−− 6b−−−− 7b−−−− 8b−−−−
(((( ))))810 ...10162540.01285.0 ====
©Loberg
26
NUMBER SYSTEMS AND CODES
Example : Convert10828125.0 to base 2
10
10
312500.02625000.0
656250.02312500.1
828125.02656250.1
××××====××××====××××====MSD
Base Conversion
Conversion : Radix Multiply Method
For fractoins
10
10
10
10
500000.02000000.1
250000.02500000.0
625000.02250000.1
312500.02625000.0
××××====××××====××××====××××====
LSD
210 110101.0828125.0 ====
[1]
©Loberg
27
NUMBER SYSTEMS AND CODES Signed Number Representation
Sign and Magnitude
(((( ))))rsmm101n aa.aasN −−−−−−−−−−−− ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅====
negativeNif1rs
positiveNif0swhere
====−−−−============
(((( )))) (((( )))) (((( )))) sm2210 1101,1110113N ====−−−−====−−−−====
(((( )))) (((( )))) sm1010 13,913N ====−−−−====
Sign = r-1
Examples :
[1]
©Loberg
28
NUMBER SYSTEMS AND CODES
[[[[ ]]]] (((( ))))rnr NrN −−−−====
Radix Complement [[[[ ]]]] rN
(((( ))))rNindigitsofnumbern ====
Largest positive number is 1r 1n −−−−−−−−
Most negative number is 1nr −−−−−−−−5n ====
Complements are used in digital computers to simplify the
subtraction operation. (simpler and less expensive circuits)
In general, for base-r system : ( r's complement )
Signed Number Representation
Most negative number is r−−−−
[1], [2]
[[[[ ]]]] [[[[ ]]]] (((( ))))(((( )))) (((( ))))(((( ))))
2
22
2
8
22
10011011
01100101100000000
01100101201100101N
====−−−−====
−−−−========
Example of Two's Complement :
"Invert bits and add one"
Two's Complement : [[[[ ]]]] (((( ))))2n2 N2N −−−−====2r ====
©Loberg
29
NUMBER SYSTEMS AND CODES
Diminished Radix Complement
[[[[ ]]]] (((( )))) 1NrN r
n1r −−−−−−−−====−−−− (((( ))))rNindigitsofnumbern ====
Ones's Complement :
[[[[ ]]]] (((( )))) 1NrN n −−−−−−−−====2r ====
In general, diminished radix complement [N]r-1 of number (N)r is: ( (r-1)'s complement )
Signed Number Representation
"Invert bits"
Example of One's Complement :
[[[[ ]]]] [[[[ ]]]] (((( ))))(((( )))) (((( )))) (((( )))) (((( ))))
2222
2
8
1212
100110100000000101100101100000000
101100101201100101N
====−−−−−−−−====
−−−−−−−−======== −−−−−−−−
[1]
[[[[ ]]]] (((( )))) 1NrN 2
n12 −−−−−−−−====−−−−2r ====
©Loberg
30
(((( )))) (((( )))) (((( )))) [[[[ ]]]] (((( )))) (((( )))) n
rrrrrr rNMNMNM ++++−−−−====++++====−−−−
NUMBER SYSTEMS AND CODES
Subtraction with Radix Complement
(((( )))) (((( ))))rr NM ≥≥≥≥If The sum will generate an end carry nr Discard the end carry The result is M-N
(((( )))) (((( ))))rr NM ≤≤≤≤If The sum does not produce an end carry The result is [[[[ ]]]] rMN −−−−
( r's complement of (N-M) )
Signed Number Representation
( r's complement of (N-M) )
Examples of 10's Complement :
(((( )))) (((( )))) 325072532NM 1010 −−−−====−−−−
10's complement of N is : 96750
725329675016928210000069282
+
-Discard end carry 105
(((( )))) (((( )))) 725323250NM 1010 −−−−====−−−−
10's complement of N is : 27468
032502746830718
+
10's complement of
30718 is : [[[[ ]]]] 6928230718 10 −−−−====−−−−
©Loberg
31
NUMBER SYSTEMS AND CODES Computer Codes
Numeric Codes Fixed-point Numbers
Excess or Biased Representations
32Excess −−−−
1n−−−− 2n−−−− 3n−−−− 01⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
1n−−−−2n−−−−3n−−−−0 1 ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
Sign bit
Implied binary
point
Implied binary point
Magnitude
representation
Fixed-point integer
Fixed-point fraction
[1]
32Excess −−−−
Excess-K representation of a code C is C+K.
Excess-2n numbers are two's complement numbers
with the sign bit reversed.
EXCESS-8 code
©Loberg
32
NUMBER SYSTEMS AND CODES
Floating-point Numbers
ErMN ××××====exponent
mantissa
========
E
Mwhere
Computer Codes
Numeric Codes
(((( ))))rsmm1nM aa.SM −−−−−−−− ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅==== numberpositive0SM ====
Mantissa M is often coded
in sign magnitude, usually
as a fraction.
[1]
©Loberg
33
NUMBER SYSTEMS AND CODES
Exponent E is most often coded in excess-K two's complement. Bias K is added to the 2's complement
integer value of the exponent.
For binary floating-point numbers, K is usually selected to be1e2 −−−− where e is the number of
bits in the exponent.
(((( ))))(((( )))) 1EE
1EE rrMrMN
−−−−
++++
××××××××====××××====××××÷÷÷÷====××××====
Computer Codes
Numeric Codes Floating-point Numbers
(((( )))) 1EE rrMrMN −−−−××××××××====××××====
(((( ))))(((( ))))(((( ))))(((( )))) 6
2
5
2
4
2
2
20011010101.0
2011010101.0
211010101.0
0101.1101M
××××====
××××====
××××====
++++====
Example :
[1]
©Loberg
34
NUMBER SYSTEMS AND CODES
Character and Other Codes Binary Coded Decimal (BCD)
0: 00001: 00012: 00103: 0011
The BCD code is weighted code: Each bit position in
the code has a fixed weight associated with it.
(8421-code)
Computer Codes
[1]
3: 00114: 01005: 01016: 01107: 01118: 10009: 1001
BDC Codes
Example
(((( )))) (((( ))))BCD10 00000101011110019750N ========
©Loberg
35
NUMBER SYSTEMS AND CODES
Gray Code (unit distance code)
Computer Codes
Character and Other Codes
[1]
©Loberg
36
NUMBER SYSTEMS AND CODES
ASCII
(American Standard Code for Information Interchange)
Computer Codes
Character and Other Codes
[1]
©Loberg
37
NUMBER SYSTEMS AND CODES
Error Detection - and Correction Codes Parity Codes
Even Parity P=1 Information bits : the number of 1 is odd
P Information bits
Parity Bit
Computer Codes
[1]
Odd Parity
P=0 Information bits : the number of 1 is even
P=0 Information bits : the number of 1 is odd
P=1 Information bits : the number of 1 is even
[2]
©Loberg
38
NUMBER SYSTEMS AND CODES
Classification of Binary Codes
Weighted Non-weighted Reflective Sequential Alphanumeric Error Detecting
and Correcting
Binary
BCD
Excess-3 Gray 2421 ASCII5211 Excess-3 8421
Excess-3 Hollerith
EBCDIC
Parity Hamming
[4]
Odd
Computer Codes
[3]
Even
©Loberg
39
The End
40
The End