Chapter 7 Microprocessor
Chapter 7 Microprocessor
Microprocessor
Number Systems
Hexa-
Decimal Binary Octal decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
p. 33
Common Number Systems
Hexa-
Decimal Binary Octal decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Common Number Systems
Hexa-
Decimal Binary Octal decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17
Positional Notation: Base 10
43 = 4 x 101 + 3 x 100
10’s 1’s
place place
Value 10 1
Evalua 4 x 10 3 x1
te
Sum 40 3
Positional Notation: Octal
6248 = 40410
Place 82 81 80
Value 64 8 1
9
Converting Binary to Decimal
1 1 0 1 . 0 1 Bits
23 22 21 20 2-1 2-2 Weights (in base 10)
8 + 4 + 0 + 1 + 0 + 0.25 = 13.25
(1101.01)2 = (13.25)10
10
Converting Decimal to Binary
• To convert a decimal integer into binary, keep dividing by 2 until the quotient is
0. Collect the remainders in reverse order
• To convert a fraction, keep multiplying the fractional part by 2 until it becomes 0.
Collect the integer parts in forward order
• Example: 162.375:
• So, (162.375)10 = (10100010.011)2
12
Octal and Hexadecimal Numbers
• The octal number system: Base-8
• Eight digits: 0,1,2,3,4,5,6,7
13
Numbers with Different Bases
(673.12)8 = 6 7 3 . 1 2
= 110 111 011 . 001 010
= (110111011 .001010) 2
• Converting from binary to octal: Make groups of 3 bits, starting from the binary
point. Add 0s to the ends of the number if needed. Convert each bit group to its
corresponding octal digit.
1 1 Carry
5 5
+ 5 5
1 1 0
= Ten ≥ Base
Subtract a
Base
Binary Addition
• Column Addition
1 1 1 1 1 1
1 1 1 1 0 1 = 61
+ 1 0 1 1 1 = 23
1 0 1 0 1 0 0 = 84
≥ (2)10
Binary Subtraction
1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1 = 77
− 1 0 1 1 1 = 23
0 1 1 0 1 1 0 = 54
Binary Multiplication
• Bit by bit
1 0 1 1 1
x 1 0 1 0
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
1 1 1 0 0 1 1 0
Quick Exercise
Hexa-
Decim Binary Octal decimal
al
33 100001 41 21
117 1110101 165 75
451 1110000 703 1C3
11
431 1101011 657 1AF
11
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
29.8
101.1101
3.07
C.82
Don’t use a calculator!
Exercise – Convert …
Answer
Hexa-
Decimal Binary Octal decimal
29.8 11101.11001 35.63 1D.CC…
1… …
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.50781 1100.100000 14.40 C.82
25 10 4
Exercise
1110
10101 x 1011
21 1110
+ 11001 + 1110
25 0000
101110 1110
46 10011010
Boolean Algebra
• Rules that govern constants and variables that can take on 2 values
• Boolean logic
• 3 fundamental operations:
AND, OR and NOT
• Truth table:
• Represents relationship between a Boolean function and its binary variables.
• It enumerates all possible combinations of arguments and the corresponding
function values.
• Logic diagram: Composed of graphic symbols for logic gates. A simple circuit
sketch that represents inputs and outputs of Boolean functions.
Basic Logic Gates
• Logic gates are the basic building blocks for digital electronic circuits
• NOT, AND, and OR Gates
• NAND and NOR Gates
• Exclusive-OR (XOR) Gate
The AND gate
The OR gate
The NOT gate (or inverter)
The NAND gate
The NOR gate
The Exclusive OR gate
The Exclusive NOR gate
Boolean Algebra
• Boolean Constants
• these are ‘0’ (false) and ‘1’ (true)
• Boolean Variables
• variables that can only take the vales ‘0’ or ‘1’
• Boolean Functions
• each of the logic functions (such as AND, OR and NOT) are represented
by symbols as described above
• Boolean Theorems
• a set of identities and laws
Boolean identities
X A BC
Combinational Logic
Y AB CD
Combinational Logic
Example (continued)
– work progressively from the inputs to the output adding logic expressions to
the output of each gate in turn
Combinational Logic
X ( A B) ( AB )
Combinational Logic
Example (continued)
The logic function can then be implemented as before
X ( A B) ( AB )
Implementing a logic function from a truth
table
Example –
Implement the function of the following truth table
Example (continued)
The logic function
can then be implemented as before X A B C A B C A B C
Implementing a logic function from a truth
table
• In some cases it is possible to simplify logic expressions using the rules of
Boolean algebra
Example –
hence the following circuits are equivalent
X ABC A BC AC A C X BC A
Function Minimization using Boolean Algebra
• Examples:
(a) a + ab = a(1+b)=a
Show that;
1- ab + ab' = a
2- (a + b)(a + b') = a
• Show that;
(a) ab + ab'c = ab + ac
(b) (a + b)(a + b' + c) = a + bc
8. AD’+A’B’+C’D+A’C’+B’D = AD’+(BC)’
9. XY’+Z(X’+Y+W)=Z+XY’
10. X’Z’+YZ+XY’=Y’Z’+X’Y+XZ
11. X’Y’Z’+XYZ+
(WZ’)’+X’YZ’+W’XY+XY’Z’=W’XY+XYZ+X’Z’+Y’Z’
What are Karnaugh maps?
• The arrangement of 0's and 1's within the map helps you to visualize the logic
relationships between the variables and leads directly to a simplified Boolean
statement.
Karnaugh maps
A A A
0 1 0 1 0 1
B B B
0 AB A B 0
00 10 0 AB AB
0 2
01 11
1 AB A B 1
1 3
1
A B AB
Maxterm Minterm
Karnaugh maps
Cell = 23=8
AB
C 00 01 11 10
0 2 6 4
0 ABC A BC ABC AB C
1 3 7 5
1 A B C A BC ABC AB C
Karnaugh maps
AB
CD 00 01 11 10
0 4 12 8
00
1 5 13 9
01
3 7 15 11
11
2 6 14 10
10
Karnaugh maps
A
0 1
B
A
B
Y 0 1
A
1 1 1
A B Y
0 0 0
0 1 1
B
1 0 1
1 1 1
A+B
Example
AC
A B C Y
0 0 0 1 AB
0 0 1 1 C 00 01 11 10
0 1 0 0 0 1 1 1
0 1 1 0
1 0 0 1 1 1 1
1 0 1 1
1 1 0 1
1 1 1 0 B
B AC
Exercise
A B C Y
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
A circuit for two light switches
63
Thus, we get:
0 1 0
0 0 1
64
Application of Logic gates
• Digital Comparator
• Code converter
• Arithmetic
• Data Selection
• Storage
• Counting
Comparison
• Multiplexer (MUX)
• Switches digital data from several input lines on a single output line in a special
time sequence.
• Demultiplexer (DEMUX)
• Does the opposite.
Storage
• This function is required in most digital systems.
• It can memorize a bit of a group of bits and retain the information as
long as necessary.
• Flip-flops
• Registers
• etc
Counting
• Counting is one of the most important function in digital systems.
• Think about the loop in programming, you cannot accomplish unless you have
some sort of counter.
• To count, the counter must remember the present numbers it can go to
the next proper number in sequence.
Sequential Logic
• Simply computing functions usually not enough
• Want more time-varying behavior
• Common model: combinational logic with state-holding elements
Clock
Input
State-holding elements
State Machines
• Common use of state-holding elements
• Idea: machine may go to a new state in each cycle
• Output and next state dependent on present state
• E.g., a four-counter
C’ / 0 C’ / 1
C/1
C/2
C/0
C’ / 3 C/3 C’ / 2
Latches & Flip-Flops
• Two common types of state-holding elements
• Latch
• Level-sensitive
• Transparent when clock is high
• Holds last value when clock is low
• Cheap to implement
• Somewhat unwieldy to design with
• Flip-flop
• Edge-sensitive
• Always holds value
• New value sampled when clock transitions from 0 to 1
• More costly to implement
• Much easier to design with
Latches & Flip-Flops
• Timing diagrams for the two common types:
D Q
Latch
Clk
Clk
D Q
Flip-
Flop
RAMs
• Another type of state-holding element
• Addressable memory
• Good for storing data like a von Neumann program
Address
Read
Write
Setup & Hold Times
• Flip-flops and latches have two types of timing requirements:
• Setup time
• D input must be stable some time before the clock arrives
• Hold time
• D input must remain stable some time after the clock has arrived
Setup & Hold Times
• For a flip-flop (edge-sensitive)
Clk
Synchronous System Timing
Clock period
Clock
Clock
skew
skew Slowest logical
path
Clk to D delay Setup Time
What is a Microprocessor?
• The size (width) of bus determines how much data can be transmitted at
one time.
• E.g.:
• A 16-bit bus can transmit 16 bits of data at a time.
• 32-bit bus can transmit 32 bits at a time.
Address Bus
• A collection of wires used to identify particular location in main memory
is called Address Bus.
• Or in other words, the information used to describe the memory
locations travels along the address bus.
Cont’d
• The size of address bus determines how many unique memory locations
can be addressed.
• E.g.:
• A system with 4-bit address bus can address 24 = 16 Bytes of memory.
• A system with 16-bit address bus can address 216 = 64 KB of memory.
• A system with 20-bit address bus can address 220 = 1 MB of memory.
Control Bus
• The connections that carry control information between the CPU and
other devices within the computer is called Control Bus.
• The control bus carries signals that report the status of various devices.
• E.g.:
• This bus is used to indicate whether the CPU is reading from memory or
writing to memory.