Вы находитесь на странице: 1из 65

DIGITAL ELECTRONICS & MICROPROCESSORS

I • INTRODUCTION – DIGITAL SYSTEM


N
T
• NUMBER SYSTEM
R
O
D • CODES
U
C
T
• REGISTERS
I
O • BINARY LOGIC – BOOLEAN ALGEBRA
N
DIGITAL ELECTRONICS & MICROPROCESSORS

DIGITAL ELECTRONICS

I
N
T
R
O
D
U
C
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Applications of Digital System

I • Conventional computer design


N – CPUs, busses, peripherals
T
• Networking and communications
R
O – Phones, modems, routers
D • Embedded products
U
– Cars, toys, appliances, entertainment devices
C
T • Scientific equipment
I – Testing, sensing, reporting
O
• World of computing much bigger than just PCs!
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Applications of Digital System

I • Digital age
N • Digital computers
T – many scientific, industrial and commercial applications
R – space program
O • Digital systems
D – telephone switching exchanges
U
– digital camera
C
– electronic calculators, PDA's
T
I – digital TV
O • Discrete information-processing systems
N • Why binary?
– reliability: a transistor circuit is either on or off (two stable states)
DIGITAL ELECTRONICS & MICROPROCESSORS

DEFINATION
•Discrete System - a system with a finite number of sizes or
measures
I
N –Shoes, Dresses, Pants, Bolts, Pencils
T • Digital System - a Discrete System with only two values of
R system variables: 1 and 0
O
–True/False; Yes/No; Male/Female; On/Off
D
U •Let’s compare digital and continuous (analog) systems
C –Digital signals are binary; analog signals are real-valued
T numbers
I
–Digital is less susceptible to noise
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Why digital systems?

I • Greater system complexities


N
T - hierarchical design
R - Computer Aided-Design (CAD) tools
O • Higher reliability
D
U
Higher resistance to
C - noise and intereference
T - ambient temperature changes
I
- aging
O
N • Easier programmability
DIGITAL ELECTRONICS & MICROPROCESSORS

What is logic design?

• What is design?
I – Given a specification of a problem, come up with a way of solving it
N choosing appropriately from a collection of available components
T – While meeting some criteria for size, cost, power, beauty, elegance, etc.
R
O • What is logic design?
D – Determining the collection of digital logic components to perform a
U specified control and/or data manipulation and/or communication
C function and the interconnections between them
T – Which logic components to choose? – there are many implementation
I technologies (e.g., off-the-shelf fixed-function components,
O programmable devices, transistors on a chip, etc.)
N – The design may need to be optimized and/or transformed to meet design
constraints
DIGITAL ELECTRONICS & MICROPROCESSORS

Representation of Digital Designs

I • Physical devices (transistors, relays)


N
• Switches
T
R • Truth tables
O • Boolean algebra
D • Gates
U
C • Waveforms
T • Finite state behavior
I • Register-transfer behavior
O
N • Concurrent abstract specifications
DIGITAL ELECTRONICS & MICROPROCESSORS

Digital System

• Takes a set of discrete information inputs and discrete


I internal information (system state) and generates a set of
N discrete information outputs.
T
R
O
Discrete Discrete
D
U Inputs Information
Processing Discrete
C Outputs
T System
I
O
N
System State
DIGITAL ELECTRONICS & MICROPROCESSORS

Types of Digital Systems

I • No state present
N – Combinational Logic System
T
– Output = Function(Input)
R
O • State present
D – State updated at discrete times
U => Synchronous Sequential System
C – State updated at any time
T
I =>Asynchronous Sequential System
O – State = Function (State, Input)
N – Output = Function (State)
or Function (State, Input)
DIGITAL ELECTRONICS & MICROPROCESSORS

Digital System Example:

I A Digital Counter (e. g., odometer):


N
T
R Count Up
O 0 0 1 3 5 6 4
Reset
D
U
C Inputs: Count Up, Reset
T
I
Outputs: Visual Display
O State: "Value" of stored digits
N
DIGITAL ELECTRONICS & MICROPROCESSORS

A Digital Computer Example

I
N Memory
T
R
O
D Control
CPU unit Datapath
U
C
T Inputs:
Outputs: CRT,
I Keyboard,
LCD, modem,
O mouse, modem, Input/Output
N
speakers
microphone
DIGITAL ELECTRONICS & MICROPROCESSORS

A digital computer

I
N
T
R
O
D
U
C
T
I
O
N
- stored program
- control unit
- arithmetic computations and logical operations
DIGITAL ELECTRONICS & MICROPROCESSORS

Signal
• An information variable represented by physical quantity.
I
N • For digital systems, the variable takes on discrete values.
T • Two level, or binary values are the most prevalent values in
R digital systems.
O • Binary values are represented abstractly by:
D – digits 0 and 1
U
– words (symbols) False (F) and True (T)
C
T – words (symbols) Low (L) and High (H)
I – and words On and Off.
O • Binary values are represented by values or ranges of values
N of physical quantities
DIGITAL ELECTRONICS & MICROPROCESSORS

Signal Examples Over Time

I
N
T Time
R Continuous
O
in value &
D Analog
U
time
C
T Digital Discrete in
I value &
O Asynchronous continuous
N in time
Discrete in
Synchronous
value &
time
DIGITAL ELECTRONICS & MICROPROCESSORS

Signal Example – Physical Quantity: Voltage

I
N
T OUTPUT INPUT
R 5.0
O
D
HIGH HIGH
4.0
U
C 3.0
T Threshold
I 2.0 Region
O
N 1.0
LOW LOW
0.0
Volts
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary Values: Other Physical Quantities

I
N • What are other physical quantities represent 0 and 1?
T
R
– CPU Voltage
O – Disk Magnetic Field Direction
D – CD Surface Pits/Light
U – Dynamic RAM Electrical Charge
C
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Mapping from physical world to binary world

I
N Technology State 0 State 1
T
Relay logic Circuit Open Circuit Closed
R CMOS logic 0.0-1.0 volts 2.0-3.0 volts
O Transistor transistor logic (TTL) 0.0-0.8 volts 2.0-5.0 volts
D Fiber Optics Light off Light on
U Dynamic RAM Discharged capacitor Charged capacitor
Nonvolatile memory (erasable) Trapped electrons No trapped electrons
C
Programmable ROM Fuse blown Fuse intact
T Bubble memory No magnetic bubble Bubble present
I Magnetic disk No flux reversal Flux reversal
O Compact disc No pit Pit
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Digital Design Process

I
N • Computer Aided Design Tools
T
– Design entry
R
O – Synthesis
D – Verification and simulation
U – Physical design
C
T – Fabrication
I – Testing
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Digital vs. analog


I
N • It is convenient to think of digital systems as having only
T discrete, digital, input/output values
R
O
• In reality, real electronic components exhibit continuous,
D analog, behavior
U • Discrete elements of information are represented in a digital
C system are called SIGNALS.
T • Discrete quantities of information emerges from nature of
I
process
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

5 Analog Waveform
I
N
Voltage (V)

T
R
O
Time
D 0
U
C Digital Waveform
5
T 1 1
Voltage (V)

I
O
N
0 Time
0
DIGITAL ELECTRONICS & MICROPROCESSORS

I
N
T
R
O
D
NUMBER SYSTEM
U
C 9x10
T 9 1x10
I
O 123
N
1×102 + 2×101
+ or3×100
1 hundred, 2 tens
and 3 units
DIGITAL ELECTRONICS & MICROPROCESSORS

Positional Number System

I • A number is represented by a string of digits where each


N digit position has an associated weight.
T • The weight is based on the radix of the number system.
R
O • Some common radices:
D – Decimal.
U – Binary.
C
T – Octal.
I – Hexadecimal.
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Bases
I
• When counting upwards in base-10, we increase
N the units digit until we get to 10 when we reset the
T units to zero and increase the tens digit.
R • So, in base-n, we increase the units until we get to
O
D
n when we reset the units to zero and increase the
U n-s digit.
C • Consider hours-minutes-seconds as an example of
T a base-60 number system:
I
O Eg. 12:58:43 + 00:03:20 = 13:02:03
N
NB. The base of a number is often indicated by a
subscript. E.g. (123)10 indicates the base-10 number
123.
DIGITAL ELECTRONICS & MICROPROCESSORS

Base-10 (decimal) arithmetic

I
N • Uses the ten numbers from 0 to 9
T
R • Each column represents a power of 10
O
D
U Thousands (103 ) column
C Hundreds (102 ) column
T Tens (101 ) column
I Ones (100 ) column
O
N
199910 = 1x103 + 9x102 + 9x101 + 9x100
DIGITAL ELECTRONICS & MICROPROCESSORS

Base-10 (decimal) arithmetic

I • Base 10
N – Ten digits, 0-9
T – Columns represent (from right to left) units, tens,
R
hundreds etc.
O
D
U
C
T
123
I
O
N 1×102 + 2×101 + 3×
10
or
0

1 hundred, 2 tens and 3


units
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary Numbers Terminology


I
N
T
• Each digit in a binary number is known as a “bit”.
R • A group of eight bits makes a binary number
O known as a “byte”.
D
U • A group of more than eight bits is known as a
C “word”.
T
I • Typical word lengths – 12, 16, 32, 64.
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Base-2 (binary) arithmetic


I
N
T • Uses the two numbers from 0 to 1
R
O
• Every column represents a power of 2
D
U 3
Eights (2 ) column
C 2
Fours (2 ) column
T 1
Twos (2 ) column
I 0
Ones (2 ) column
O
N

1001 2
= 1x2 3 + 0x2 2 + 0x2 1 + 1x2 0
DIGITAL ELECTRONICS & MICROPROCESSORS

Base-2 (binary) arithmetic


I • Base 2
N
T – Two digits, 0 & 1
R – Columns represent (from right to left) units, twos, fours,
O eights etc.
D
U
C
T
1111011
I
O
N 1×26 + 1×25 + 1×24 + 1×23 + 0×22 + 1×21 + 1
×20
= 1×64 + 1×32 + 1×16 + 1×8 + 0×4 + 1×2 + 1×
1
DIGITAL ELECTRONICS & MICROPROCESSORS

Why Don’t Computers Use Base 10?

I • Base 10 Number Representation


N – That’s why fingers are known as “digits”
T – Natural representation for financial transactions
R • Floating point number cannot exactly represent $1.20
O – Even carries through in scientific notation
D • 1.5213 X 104
U • Implementing Electronically
C – Hard to store
T
• ENIAC (First electronic computer) used 10 vacuum tubes / digit
I
– Hard to transmit
O
• Need high precision to encode 10 signal levels on single wire
N
– Messy to implement digital logic functions
• Addition, multiplication, etc.
DIGITAL ELECTRONICS & MICROPROCESSORS

Why Don’t Computers Use Base 10? Contd..

I • Everything in digital world is based on binary system.


N • Numerically it involves only two symbols
T 0 or 1.
R – 0 = False = No
O
– 1 = True = Yes
D
U • Binary Number System : Easy to design stable electronic
C circuits.
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Decimal to Binary Conversion

I
N
T Example – Converting (123)10 into
R binary
123 ÷ 2= 61 remainder 1 Least significant bit (rightmost)
O
D
61 ÷ 2 = 30 remainder 1
U 30 ÷ 2 = 15 remainder 0
C 15 ÷ 2 = 7 remainder 1
T 7 ÷ 2 = 3 remainder 1
I 3 ÷ 2 = 1 remainder 1
O 1 ÷ 2 = 0 remainder 1 Most significant bit (leftmost)
N

Answer : (123)10 = (1111011)2


DIGITAL ELECTRONICS & MICROPROCESSORS

Two’s Complement

• One byte (eight bits) can be used to represent the


I
N decimal number range
T – 0 to 255 (unsigned)
R – -128 to 127 (signed)
O
D • Negative binary numbers are formed by
U subtracting from a number one greater than the
C maximum possible (i.e. 2n or 256 for a byte)
T
I • For example,
O (123)10 = (01111011)2
N
(-123)10 = (10000101)2 = (133)10 = (256-123)10
DIGITAL ELECTRONICS & MICROPROCESSORS

• So how can you tell the difference between:


I
N (-123)10 = (10000101)2
T
R and
O
D (133)10 = (10000101)2
U  You can’t unless you know whether you’re
C using signed or unsigned arithmetic:
T
I Unsigned ⇒ 0 ≤ x ≤ 255
O
N Signed ⇒ −128 ≤ x ≤ 127
DIGITAL ELECTRONICS & MICROPROCESSORS

Hexadecimal

I • Base 16
N
T – Sixteen digits, 0-9 and A-F (ten to fifteen)
R – Columns represent (from right to left) units, 16s, 256s,
O 4096s etc.
D
U 7B
C
T
I 7×161 + 11×160 =
O 123
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Decimal to Hex Conversion

I
N
T Converting (123)10 into hex
R
O123 ÷ 16 = 7 remainder 11 (or B)
D 7 ÷ 16 = 0 remainder 7
U
C
T
Answer : (123)10 = (7B)16
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary to Hex / Hex to Binary

Each group of four binary bits maps on to a single hex


I
digit.
N
T 0111 1011
R
O
D 7B
U
• Even very long numbers can be converted easily, treating
C
each hex digit independently.
T
I 1011 1001 0110 1111 1010
O E.g.
N
B96FA
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary Arithmetic - Addition

I
N
T • Binary long addition works just like
R
O
decimal long addition.
D
U 1 0 0 1 1 1
C
+ 0 0 1 1 1 0
T
I 0 1 1 1 0 0 Carried digits
O 1 1 0 1 0 1 Result
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Multiplication
I
N
T • Performed just like you would performed it in
R decimal, except the additions are in binary.
O • Ex:
D • 11 X 13= 143
U
C • Signed (2’s comp.) multiplication can be
T performed by the addition of shifted
I multiplicands, except for the last multiplicand
O which should be negated then shifted.
N
• Ex:
• -3 X –5 = 15
DIGITAL ELECTRONICS & MICROPROCESSORS

Division

• Use the shift and subtract method you learned in


I
N grammar school.
T • Ex:
R • 217 / 11 = 19 with 8 remaining
O
• 217 = 110110012
D
U • Signed division can be performed by dividing the
C numbers as unsigned numbers then given them a “+”
T sign if the operands have the same sign and “–” if the
I operands have different signs.
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Number of Elements Represented

I • Given n digits in radix r, there are rn distinct elements that


N can be represented.
T • But, you can represent m elements, m < rn
R • Examples:
O
– You can represent 4 elements in radix r = 2 with n = 2
D digits: (00, 01, 10, 11).
U
– You can represent 4 elements in radix r = 2 with n = 4
C
digits: (0001, 0010, 0100, 1000).
T
I
– This second code is called a "one hot" code.
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary Codes for Decimal Digits

I  There are over 8,000 ways that you can chose 10 elements
N from the 16 binary numbers of 4 bits. A few are useful:
T
R
O Decimal 8,4,2,1 Excess3 8,4,-2,-1 Gray
D 0 0000 0011 0000 0000
U 1 0001 0100 0111 0100
C 2 0010 0101 0110 0101
3 0011 0110 0101 0111
T
4 0100 0111 0100 0110
I 5 0101 1000 1011 0010
O 6 0110 1001 1010 0011
N 7 0111 1010 1001 0001
8 1000 1011 1000 1001
9 1001 1100 1111 1000
DIGITAL ELECTRONICS & MICROPROCESSORS

I
N
T
R
O
D CODES
U
C
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary Coded Decimal (BCD)

I • The BCD code is the 8,4,2,1 code.


N
T • This code is the simplest, most intuitive binary
R code for decimal digits and uses the same powers
O of 2 as a binary number, but only encodes the first
D ten values from 0 to 9.
U
C
• Example: 1001 (9) = 1000 (8) + 0001 (1)
T • How many “invalid” code words are there?
I • What are the “invalid” code words?
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Excess 3 Code and 8, 4, –2, –1 Code

Decimal Excess 3 8, 4, –2, –1


I
0 0011 0000
N
T 1 0100 0111
R 2 0101 0110
O 3 0110 0101
D 4 0111 0100
U
5 1000 1011
C
T 6 1001 1010
I 7 1010 1001
O 8 1011 1000
N 9 1100 1111
DIGITAL ELECTRONICS & MICROPROCESSORS

Gray Code

I Decimal 8,4,2,1 Gray


N 0 0000 0000
T 1 0001 0100
R 2 0010 0101
O 3 0011 0111
D 4 0100 0110
U 5 0101 0010
6 0110 0011
C
7 0111 0001
T 8 1000 1001
I 9 1001 1000
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Gray Code (Continued)


• Does this special Gray code property
I have any value?
N
T • An Example: Optical Shaft Encoder
R
O 111 000 100 000
D B0
U B1
001 101 001
C 110
B2
T
I G1
G2
O 010 111 G0
011
101
N

100 011 110 010


(a) Binary Code for Positions 0 through 7(b) Gray Code for Positions 0 through 7
DIGITAL ELECTRONICS & MICROPROCESSORS

Gray Code (Continued)

I
N
T • How does the shaft encoder work?
R
O
D
U
C
• For the binary code, what codes may be
T produced if the shaft position lies
I between codes for 3 and 4 (011 and 100)?
O
N
• Is this a problem?
DIGITAL ELECTRONICS & MICROPROCESSORS

Warning: Conversion or Coding?

I
N • Do NOT mix up conversion of a decimal
T number to a binary number with coding a
R
O decimal number with a BINARY CODE.
D
U
• 1310 = 11012 (This is conversion)
C • 13 ⇔ 0001|0011 (This is coding)
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Code Representations With More Than 4 Bits


I
N
• Biquinary.
T
R – XXYYYYY
O • XX
D – 01 = Numbers 0-4
U – 10 = Numbers 5-9
C
• YYYYY
T
I – Indicates which of the five numbers from the
O above ranges is represented.
N • Advantages.
– Easier to detect errors.
DIGITAL ELECTRONICS & MICROPROCESSORS

Error-Detection Codes

I
• Redundancy (e.g. extra information), in the form
N of extra bits, can be incorporated into binary code
T words to detect and correct errors.
R • A simple form of redundancy is parity, an extra bit
O
D
appended onto the code word to make the number
U of 1’s odd or even. Parity can detect all single-bit
C errors and some multiple-bit errors.
T • A code word has even parity if the number of 1’s
I in the code word is even.
O
N • A code word has odd parity if the number of 1’s in
the code word is odd.
DIGITAL ELECTRONICS & MICROPROCESSORS

4-Bit Parity Code Example


• Fill in the even and odd parity bits:
I Even Parity
N
Odd Parity
T
Message - Parity Message - Parity
R 000 - 000 -
O 001 - 001 -
D 010 - 010 -
U 011 - 011 -
C 100 - 100 -
T 101 - 101 -
I 110 - 110 -
O 111 - 111 -
N • The codeword "1111" has even parity and the
codeword "1110" has odd parity. Both can be
used to represent 3-bit data.
DIGITAL ELECTRONICS & MICROPROCESSORS

ASCII Character Codes

I • American Standard Code for Information Interchange


N • This code is a popular code used to represent information
T sent as character-based data. It uses 7-bits to represent:
R – 94 Graphic printing characters.
O
– 34 Non-printing characters
D
U • Some non-printing characters are used for text format
C (e.g. BS = Backspace, CR = carriage return)
T • Other non-printing characters are used for record
I marking and flow control (e.g. STX and ETX start and end
O text areas).
N
DIGITAL ELECTRONICS & MICROPROCESSORS

ASCII Properties
I
N
ASCII has some interesting properties:
T
R  Digits 0 to 9 span Hexadecimal values 3016 to 3916 .
O  Upper case A-Z span 4116 to 5A16 .
D  Lower case a-z span 6116 to 7A16 .
U
C
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Binary Storage and Registers


• A binary cell
I – two stable state
N – store one bit of information
T
– examples: flip-flop circuits, ferrite cores, capacitor
R
O • A register
D – a group of binary cells
U
– AX in x86 CPU
C
T • Register Transfer
I – a transfer of the information stored in one register to
O another
N
– one of the major operations in digital system
– an example
DIGITAL ELECTRONICS & MICROPROCESSORS

Transfer of information

I
N
T
R
O
D
U
C
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Boolean algebra

I
N
T
• George Boole (1815-1864)
R • Boolean values
O
D • Boolean operations
U
C • Boolean functions
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

What is an algebra?
I
N • Term from Hisab al-jabr w'al-muqabala by
T
R al-Khwarizmi (~780-850, Baghdad)
O • Consists of
D
U – a set of values
C (e.g., the integers)
T
I – a set of functions
O • multiplication
N • addition
DIGITAL ELECTRONICS & MICROPROCESSORS

Boolean Algebra
I • Digital circuits need to be as simple as
N
T possible.
R
O
• Complex logical expressions should be
D reduced to simpler expressions,
U
C
however, produce same results under
T all conditions.
I
O
• Benefit: Simpler expressions can be
N implemented with simpler circuits,
which are cost effective.
DIGITAL ELECTRONICS & MICROPROCESSORS

Boolean Algebra
I
N • Mathematics of logical expression is the
T tool to reduce the complicated expressions.
R
O • Introduced by George Boole in 1854 and
D
U
known today as Boolean Algebra.
C • The rules of Boolean Algebra is simple and
T
I straightforward, can be applied to any
O logical expression.
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Digital Circuits
I • Combinatorial logic
N
T – Results of an operation depend only on the present
R inputs to the operation
O – Uses: perform arithmetic, control data movement,
D compare values for decision making
U
C • Sequential logic
T – Results depend on both the inputs to the operation and
I the result of the previous operation
O
– Uses: counter
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Computer Implementation
I • Gates or logical gates
N
– Integrated circuits constructed from transistor
T
R switches and other electronic components
O – VLSI: very large-scale integration
D
U
C
T
I
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Boolean Operators

I • AND A B C
N
T – Result TRUE if and only if both input 0 0 0
R operands are true 0 1 0
O – C=AB 1 0 0
D 1 1 1
U
C • INCLUSIVE-OR
T – Result TRUE if any input operands are A B C
I 0 0 0
true
O 0 1 1
N – C=A+B
1 0 1
1 1 1
DIGITAL ELECTRONICS & MICROPROCESSORS

Boolean Operators
I • NOT
N
T – Result TRUE if single input value is FALSE
R – C=A
O
D
U
C A C
T 0 1
I 1 0
O
N
DIGITAL ELECTRONICS & MICROPROCESSORS

Boolean Algebra Implementation


I • Single type of gate appropriately combined
N
T
• 2 possibilities
– NAND gate: AND operation followed by a NOT operation
R
– NOR gate: INCLUSIVE-OR followed by a NOT operation
O
D
U
C
T
I
O
N

Note:  indicates a NOT operation

Вам также может понравиться