Download Chapter 1 Binary Systems

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Mathematics of radio engineering wikipedia , lookup

Electronic engineering wikipedia , lookup

Manchester Mark 1 wikipedia , lookup

Transcript
EEA051 - Digital Logic
數位邏輯
Chapter 1
Binary Systems
吳俊興
高雄大學 資訊工程學系
September 2005
Chapter 1. Binary Systems
1-1
1-2
1-3
1-4
1-5
1-6
1-7
1-8
1-9
Digital Systems
Binary Numbers
Number Base Conversions
Octal and Hexadecimal Numbers
Complements
Signed Binary Numbers
Binary Codes
Binary Storage and Registers
Binary Logic
2
Chapter 1. Binary Systems
• Presents the various binary systems
suitable for representing information in
digital systems
• The binary number system is explained
and binary codes are illustrated
• Examples are given for addition and
subtraction of signed binary numbers and
decimal numbers in BCD
3
1-1 Digital Systems
• Analog vs. digital
– analog – continuous
– digital – discrete
– the real world is mainly analog
• Why digital?
–
–
–
–
–
–
digital systems are easier to design
information storage is easy
accuracy and precision is better
operation can be programmed
digital circuits are less affected by noise
Example: digital camera
4
Digital Systems
• Digital age
• Digital systems
– telephone switching exchanges
– digital camera
– electronic calculators, PDA's
– digital TV, digital broadcast
• Digital computers
– many scientific, industrial and commercial applications
– Generality
• Discrete information-processing systems
5
Typical Control System
(ADC)
(DAC)
6
Representing Binary Quantities
7
Digital Signals and Timing Diagrams
Signals: physical quantities, e.g. voltages and currents, to
represent discrete elements of information in a digital system
• predominately implemented by transistors
• most use just two discrete values, said to be binary
A binary digit, called a bit, has two values: 0 and 1
Binary codes: groups of bits
Why binary?
reliability: a transistor circuit is either on or off (two stable states)
8
1-2 Binary Numbers
• Numbers system: an…a3a2a1a0.a-1a-2a-3 …a-m
– Decimal number (base or radix = 10) (10 digits)
• 7,392 = 7*103 + 3*102 + 9*101 + 2*100
– Binary number (base = 2)
• (11010.11)2 = (26.75)10
9
Base-r System
• Base-r system (coefficients multiplied by powers of r)
– (4021.2)5, (127.4)8, (B65F)16
• Base-r → Decimal
– (4021.2)5 = (511.4)10
– Octal (127.4)8 = (87.5)10
– Hexadecimal (B65F)16=(46,687)10
– Binary (110101)2=(53)10
10
Binary Numbers
• Powers of Two
• K(kilo)=210, M(mega)=220, G(giga)=230, T(tera)=240
20, 21, 22, 23, 24, 25, 26, 27, 28, …
110101, 100111
11
Binary Arithmetic Operations
Arithmetic operations with numbers in base r follow
the same rules as for decimal numbers
(discussed later)
12
1-3 Number Base Conversions
Decimal → Base-r: converting a decimal number
to a number in base r (four examples)
1. Convert decimal 41 to binary: (101001)2
2. Convert decimal 153 to octal: (231)8
3. Convert (0.6875)10 to binary: (0.1011)2
4. Convert (0.513)10 to octal: (0.406517…)8
Combining:
(41.6875)10 = (101001.1011)2
(153.513)10 = (231.406517)8
13
1-4 Octal and Hexadecimal Numbers
• Binary to octal: 23=8
• Binary to hexadecimal: 24=16
• Octal to binary
• Hexadecimal to binary
Octal or hexadecimal representation is more
desirable
14
Binary
↔ Octal
↔ Hexadecimal
15
1-5 Complements
•Used for simplifying the subtraction operation
and for logical manipulation
•Two types of complement
–diminished radix complement: (r-1)’s complement
(rn-1)-N
–radix complement: r’s complement
rn-N
•Decimal number
–10’s complement and 9’s complement
•Binary number
–2’s complement and 1’s complement
16
Examples
Diminished Radix Complement
The 9’s complement of 546700 is 999999 – 546700 = 453299
The 9’s complement of 012398 is 999999 – 012398 = 987601
The 1’s complement of 1011000 is 0100111
The 1’s complement of 0101101 is 1010010
Radix Complement
The 10’s complement of 546700 is 453300
The 10’s complement of 012398 is 987602
The 2’s complement of 1101100 is 0010100
The 2’s complement of 0110111 is 1001001
17
Subtraction with r’s Complements
Subtraction of two n-digit unsigned numbers M-N in
base r:
1. Add M to the r’s complement of the subtrahend, N:
M + (rn – N) = sum
2. If M ≥ N, the sum will produce an end carry, rn,
which can be discarded
M + (rn – N) = sum = (M – N) + rn,
so M-N = sum - rn
3. If M < N, the sum is the r’s complement of (N-M)
M + (rn – N) = sum = rn – (N-M),
so M-N = -(rn-sum)
18
Subtraction with (r-1)’s Complements
Subtraction of two n-digit unsigned numbers M-N in
base r:
• Add M to the (r-1)’s complement of subtrahend N:
M + ((rn-1) – N) = sum
• If M ≥ N, the sum will produce an end carry, rn,
which can be discarded
M + ((rn-1) – N) = sum = (M – N) + (rn-1),
so M-N = sum – rn + 1 (end-around carry)
• If M < N, the sum is the r’s complement of (N-M)
M + ((rn-1) – N) = sum = (rn-1) – (N-M),
so M-N = -((rn -1) - sum)
19
Examples
20
21
1-6 Signed Binary Numbers
Table 1-3
22
• Arithmetic Addition
• Arithmetic Subtraction
(±A) – (+B) = (±A) + (–B)
(±A) – (–B) = (±A) + (+B)
23
1.7 Binary Codes
• n-bit binary code
2n distinct combinations
• BCD – Binary Coded Decimal (4-bit)
(185)10 = (0001 1000 0101)BCD = (10111001)2
(396)10 = (0011 1011 0110)BCD
• BCD addition
• Get the binary sum
• If the sum > 9, add 6 to the sum
• Obtain the correct BCD digit sum and a carry
24
Number Systems and BCD Code
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Binary
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
Octal
0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
0001 0000
0001 0001
0001 0010
0001 0011
0001 0100
0001 0101
25
BCD Addition
184 + 576 = 760
26
Other Decimal Codes
27
Gray Code
• only one bit change
between two consecutive
numbers
• useful in Analog-to-Digital
Converter
28
ASCII
Character
Code
29
Error-Detecting Code
Parity bit: an extra bit included with a message to
make the total number of 1’s either even or odd
30
1.8 Binary Storage and Registers
• A binary cell
– two stable state
– store one bit of information
– examples: flip-flop circuits, ferrite cores,
capacitor
• A register
– a group of binary cells
– e.g. AX in x86 CPU
• Register Transfer
– a transfer of the information stored in one
register to another
– one of the major operations in digital system
– an example
31
Transfer of information
32
• The other major component of a digital system
– circuit elements to manipulate individual bits of information
33
1.9 Binary Logic
• Binary Logic
– Boolean algebra
– consists of binary variables and logical operations
• Binary variables
– two discrete values (true/false; yes/no; 1/0)
• Logical operations
– Three basic operations: AND, OR, NOT
34
Logic Gates
•Binary signals
– Electrical signals: voltages or
currents
– two separate voltage levels: logic-1
and logic-0
– the intermediate region is crossed
only during state transition
•Logic circuits
– circuits = logical manipulation paths
•Computation and control
– combinations of logic circuits
•Logic gates
– electronic circuits that operate on
one or more input signals to produce
an output signal
35
36
37
Summary
Chapter 1. Binary Systems
1-1
1-2
1-3
1-4
1-5
1-6
1-7
1-8
1-9
Digital Systems
Binary Numbers
Number Base Conversions
Octal and Hexadecimal Numbers
Complements
Signed Binary Numbers
Binary Codes
Binary Storage and Registers
Binary Logic
38