You are on page 1of 123

Chapter-5

Introduction to Microprocessors

Microprocessor:
A single chip that contains a whole CPU Has the ability to fetch and execute instructions stored in memory Has the ability to access external memory, external I/O and other peripherals Examples: Intel P4 or AMD Athlon in desktops/notebooks ARM processor in Apple iPod

Microprocessor:
The key element of all computers, providing the mathematical and decision making ability Current state-of-the-art uPs (Pentium, Athlon, SPARC, PowerPC) contain complex circuits consisting of tens of millions of transistors They operate at ultra-fast speeds doing over a billion operations very second Made up from a semiconductor, Silicon

Microprocessor Generations:
First generation: 1971-78
Behind the power curve (16-bit, <50k transistors)

Second Generation: 1979-85


Becoming real computers (32-bit , >50k transistors)

Third Generation: 1985-89


Challenging the establishment (Reduced Instruction Set Computer/RISC, >100k transistors)

Fourth Generation: 1990 Architectural and performance leadership (64-bit, > 1M transistors, Intel/AMD translate into RISC internally)

In the beginning (8-bit) Intel 4004:


First general-purpose, single-chip microprocessor Shipped in 1971 8-bit architecture, 4-bit implementation 2,300 transistors Performance < 0.1 MIPS (Million Instructions Per Sec) 8008: 8-bit implementation in 1972 3,500 transistors First microprocessor-based computer (Micral) Targeted at laboratory instrumentation Mostly sold in Europe

1st Generation (16-bit) Intel 8086:


Introduced in 1978 Performance < 0.5 MIPS New 16-bit architecture Assembly language compatible with 8080 29,000 transistors Includes memory protection, support for Floating Point coprocessor In 1981, IBM introduces PC Based on 8088--8-bit bus version of 8086

2nd Generation (32-bit) Motorola 68000:


Major architectural step in microprocessors: First 32-bit architecture initial 16-bit implementation First flat 32-bit address Support for paging General-purpose register architecture Loosely based on PDP-11 minicomputer First implementation in 1979 68,000 transistors < 1 MIPS (Million Instructions Per Second) Used in Apple Mac Sun , Silicon Graphics, & Apollo workstations

3rd Generation: MIPS R2000:


Several firsts: First (commercial) RISC microprocessor First microprocessor to provide integrated support for instruction & data cache First pipelined microprocessor (sustains 1 instruction/clock) Implemented in 1985 125,000 transistors 5-8 MIPS (Million Instructions per Second)

4th Generation (64 bit) MIPS R4000:


First 64-bit architecture Integrated caches On-chip Support for off-chip, secondary cache Integrated floating point Implemented in 1991: Deep pipeline 1.4M transistors Initially 100MHz > 50 MIPS Intel translates 80x86/ Pentium X instructions into RISC internally

History of Microprocessors:
1974 the first real useful 8-bit microprocessor is released by Intel the 8080 Motorola introduces the 6800 series Zilog has the Z80 1975 GM and Ford begin to put microcontrollers in cars Many cars today have over 100 microcontrollers TI gets into the microprocessor business with calculators and digital watches 1977 Apple II is released using MOS 6502 (similar to motorola 6800). Apple II dominated from 1977 to 1983 1978 Intel introduces the first 16-bit processor, the 8086 Motorola follows with the 68000 which is ultimately used in the first Apple Macintosh

History of Microprocessors:
1981 IBM enters the PC making market and uses the Intel 8088 proliferation of the home computer 1982-1985 Intel introduces the 32-bit 80286 and 80386 1989 80486 is being used in PCs, able to run Microsoft Windows 1992 Apple, IBM and Motorola begin to make PowerMac and PowerPCs using Motorola chips 1993 Pentium chip is released

Integrated Circuits:
Commonly known as an IC or a chip A tiny piece of Silicon that has several electronic parts on it Most of the size of an IC comes form the pins and packaging; the actual Silicon occupies a very small piece of the volume The smallest components on an IC are much smaller than the thickness of a human hair

Those components are


Devices Transistors Diodes Resistors Capacitors Wires And are made of the following materials Silicon - semiconductor Copper - conductor Silicon Dioxide - insulator

A microprocessor system?
uPs are powerful pieces of hardware, but not much useful on their own Just as the human brain needs hands, feet, eyes, ears, mouth to be useful; so does the uP A uP system is uP plus all the components it requires to do a certain task A microcomputer is 1 example of a uP system

What is a Microprocessor System:

uP Building Blocks

Microprocessor
Data Cache
Memory Bus
RAM

I/O

Bus Interface Unit


System Bus

Control Unit Instruction Decoder

Arithmetic & Logic Unit Registers Floating Point Unit Registers

Instruction Cache

Basic Microprocessor System

Bus Interface Unit:


Receives instructions & data from main memory Instructions are then sent to the instruction cache, data to the data cache Also receives the processed data and sends it to the main memory

Computer Buses:
Address bus: carries the address of a unique memory or input/output (I/O) device Data bus: carries data stored in memory (or an I/O device) to the CPU or from the CPU to the memory (or I/O device) Control bus: is a collection of control signals that coordinate and synchronize the whole system

The MPU communicates with Memory and I/O using the System Bus:
Address bus
Unidirectional Memory and I/O Addresses

Data bus
Bidirectional Transfers Binary Data and Instructions

Control bus
Read and Write timing signals

Instruction Decoder:
This unit receives the programming instructions and decodes them into a form that is understandable by the processing units, i.e. the ALU or FPU

Then, it passes on the decoded instruction to the ALU or FPU

Arithmetic & Logic Unit (ALU):


Also known as the Integer Unit It performs whole-number math calculations (subtract, multiply, divide, etc) comparisons (is greater than, is smaller than, etc.) and logical operations (NOT, OR, AND, etc) The new breed of popular uPs have not one but two almost identical ALUs that can do calculations simultaneously, doubling the capability

Floating-Point Unit (FPU):


Also known as the Numeric Unit It performs calculations that involve numbers represented in the scientific notation (also known as floating-point numbers). This notation can represent extremely small and extremely large numbers in a compact form Floating-point calculations are required for doing graphics, engineering and scientific work The ALU can do these calculations as well, but will do them very slowly

Registers:
Both ALU & FPU have a very small amount of superfast private memory placed right next to them for their exclusive use. These are called registers

The ALU & FPU store intermediate and final results from their calculations in these registers Processed data goes back to the data cache and then to main memory from these registers

Control Unit:
The brain of the uP Manages the whole uP Tasks include fetching instructions & data, storing data, managing input/output devices

Microcontroller:
Microcontroller is a single chip micro computer made through VLSI fabrication. A microcontroller also called an embedded controller because the microcontroller and its support circuits are often built into, or embedded in, the devices they control. A microcontroller is available in different word lengths.(4bit,8bit,16bit,32bit,64bit and 128 bit)

Any device that measures, stores, controls, calculates, or displays information must have a microcontroller chip inside. The largest single use for microcontrollers is in automobile industry (microcontrollers widely used for controlling engines and power controls in automobiles). You can also find microcontrollers inside keyboards, mouse, modems, printers, and other peripherals. In test equipments, microcontrollers make it easy to add features such as the ability to store measurements, to create and store user routines, and to display messages and waveforms. Consumer products that use microcontrollers include digital camcorders, optical players, LCD/LED display units, etc.

A microcontroller basically contains one or more following components:


Central processing unit(CPU) Random Access Memory)(RAM) Read Only Memory(ROM) Input/output ports Timers and Counters Interrupt Controls Analog to digital converters Digital analog converters Serial interfacing ports Oscillatory circuits

A microcontroller internally consists of all features required for a computing system and functions as a computer without adding any external digital parts in it. Most of the pins in the microcontroller chip can be made programmable by the user. A microcontroller has many bit handling instructions that can be easily understood by the programmer. A microcontroller is capable of handling Boolean functions. Higher speed and performance. On-chip ROM structure in a microcontroller provides better firmware security. Easy to design with low cost and small size.

Microcontroller structure:

CPU:
CPU is the brain of a microcontroller . CPU is responsible for fetching the instruction, decodes it, then finally executed. CPU connects every part of a microcontroller into a single system. The primary function of CPU is fetching and decoding instructions. Instruction fetched from program memory must be decoded by the CPU.

Memory:

The function of memory in a microcontroller is same as microprocessor. It is used to store data and program. A microcontroller usually has a certain amount of RAM and ROM (EEPROM, EPROM, etc) or flash memories for storing program source codes.

Parallel input/output ports:


Parallel input/output ports are mainly used to drive/interface various devices such as LCDS, LEDS, printers, memories, etc to a microcontroller.

Serial ports:

Serial ports provide various serial interfaces between microcontroller and other peripherals like parallel ports.

Timers/counters:

This is the one of the useful function of a microcontroller. A microcontroller may have more than one timer and counters. The timers and counters provide all timing and counting functions inside the microcontroller. The major operations of this section are perform clock functions, modulations, pulse generations, frequency measuring, making oscillations, etc. This also can be used for counting external pulses.

Analog to Digital Converter (ADC):


ADC converters are used for converting the analog signal to digital form. The input signal in this converter should be in analog form (e.g. sensor output) and the output from this unit is in digital form. The digital output can be use for various digital applications (e.g. measurement devices).

Digital to Analog Converter (DAC):

DAC perform reversal operation of ADC conversion. DAC convert the digital signal into analog format. It usually used for controlling analog devices like DC motors, various drives, etc.

Interrupt control:
The interrupt control used for providing interrupt (delay) for a working program. The interrupt may be external (activated by using interrupt pin) or internal (by using interrupt instruction during programming).

Special functioning block:


Some microcontrollers used only for some special applications (e.g. space systems and robotics) these controllers containing additional ports to perform such special operations. This considered as special functioning block.

Advantages of Microcontrollers:
a) Microcontrollers act as a microcomputer without any digital parts. b) As the higher integration inside microcontroller reduce cost and size of the system. c) Usage of microcontroller is simple, easy for troubleshoot and system maintaining. d) Most of the pins are programmable by the user for performing different functions. e) Easily interface additional RAM, ROM,I/O ports. f) Low time required for performing operations.

Disadvantages of Microcontrollers: a) Microcontrollers have got more complex architecture than that of microprocessors. b)Only perform limited number of executions simultaneously. c) Mostly used in micro-equipments. d) Cannot interface high power devices directly.

Applications:
Microcontrollers are widely used in modern electronics equipments. Some basic applications of microcontroller is given below. a) Used in biomedical instruments. b) Widely used in communication systems. c) Used as peripheral controller in PC. d) Used in robotics. e) Used in automobile fields.

Microprocessor Vs Microcontroller

Microprocessor Vs Microcontroller

MICROCONTROLLER VERSUS MICROPROCESSOR:


MICROPROCESSOR MICROCONTROLLER
It contains ALU, control unit, different It contains microprocessor memory(ROM & registers and interrupt circuit. RAM), I/O interfacing circuit, serial 1/O, timer etc.

It has many instructions to move data It has one or two instructions to move data between memory and CPU. between memory and CPU.
It has one or two bit handling instructions. It has many bit handling instructions.

Access times for memory and I/O devices are Less access time for built in memory and I/O more. devices. The system requires more hardware It is more flexible in design point of view Has single memory map for data and code Less number of pins are malfunctioned Less hardware reducing increasing the reliability Less flexible Has a separate memory map for data and code More pins are malfunctioned PCB size and

Microprocessors
1 2 3 4 5 6 7 8 It is only a general purpose computer CPU

Microcontrollers
It is a micro computer itself inside the

Memory, I/O ports, timers, interrupts are not All are integrated available inside the chip microcontroller chip

This must have many additional digital Can function as a micro computer components to perform its operation without any additional components. Systems become bulkier and expensive. Not capable for handling Boolean functions Higher accessing time required Very few pins are programmable Very few number of bit handling instructions Make the system simple, economic and compact Handling Boolean functions Low accessing time Most of the pins are programmable Many bit handling instructions

Instruction Set:
The set of machine instructions that a uP recognizes and can execute the only language uP knows An instruction set includes low-level, a single step-ata-time instructions, such as add, subtract, multiply, and divide Each uP family has its unique instruction set

Bigger instruction-sets mean more complex chips (higher costs, reduced efficiency), but shorter programs

An instruction generally specifies:


a. The task to be carried out. b. The addresses in the memory where the operands are available. c. The address in the memory where result has to be stored. d. The address in the memory where next instruction an be found.

Programming Software:
Machine Language: Binary Instructions Difficult to decipher and write Error-prone All programs converted into machine language for execution
Instruction 10000000 00101000 00011011 Hex 80 28 1B Mnemonic ADD B ADD A, R0 ABA Description Add reg B to Acc Add Reg R0 to Acc Add Acc A and B Processor Intel 8085 Intel 8051 Motorola 6811

A word length of 8bit can have 256 combinations of 8 bit thus a language of 256 words.

It is difficult to write program in sets of 0 and 1. Manufacturers have devised English-like language words to represent binary instruction. Programmers can write programs called assembly language programs.

Assembly Language:

Machine instructions represented mnemonics One-to-one correspondence Efficient execution and use of memory Machine-specific

in

Assembly languages are machine dependent. Cannot be ported to another machine. Difficulty was overcome by using higher level

languages.

High-Level Languages: BASIC, C, and C++ Written in statements of spoken languages Machine independent Easy to write and troubleshoot Larger memory and less efficient execution

Complex Instruction set computer (CISC):


In the 1970s & 80s memory was both slow and expensive. High cost and poor performance facilitated the need for compact and efficient code. Code written in a high level language took much longer to translate into assembler, which lead to bloated code and slower program execution. bigger program->more storage->more money Hence needed to reduce the number of instructions per program

Complex Instruction set computer (CISC):


Number of instructions are reduced by having multiple operations within a single instruction Multiple operations lead to many different kinds of instructions that access memory In turn making instruction length variable and fetchdecode execute time unpredictable making it more complex The CISC philosophy was to shift some of the programming burden to the hardware level. Thus hardware handles the complexity

Complex Instruction set computer (CISC):


Features: Large No. of instructions. Single instruction will perform a complex operation. Number of instructions per program is minimised. Execution time for each instruction is different. Execution time for an instruction may take several clock cycles. Efficient use of memory space. Works faster for complex instructions but may be slow for simple tasks. Emphasis on complex hardware to store a large instruction set

Most common examples of CISC


Intel 8080,80286,80386,Pentium. Motorola 68000 Zilog Z80

Pros and Cons of CISC:


Pro:
Complex instructions operate directly on main memory. Programmer is no longer required to do a direct call to LOAD and STORE operations as they are now handled by hardware. Compiler has less work to translate statements in a high level language to assembly language.

Con:
Microcode became more difficult to test and debug as systems became more complex requiring numerous patches to fix bugs. Programmers werent using the more complex instructions sets in favor of smaller instructions that accomplished the same result. The use of memory operands caused structural hazards preventing concurrent execution of instructions. (pipelining)

Observations leading to RISC methodology: Only 20% of the available instructions were being used. Transistors currently allocated to these complex instruction sets could be better utilized elsewhere to gain performance.

Reduced Instruction Set Computer (RISC):


Original idea to reduce the ISA( Instruction Set Architecture) Provide minimal set of instructions that could carry out all essential operations Instruction complexity is reduced by: 1. Having few simple instructions that are the same length 2. Allowed memory access only with explicit load and store instructions Hence each instruction performs less work but instruction execution time among different instructions is consistent The complexity that is removed from ISA is moved into the domain of the assembly programmer/compiler

RISC Methodology:
Reduce the instruction set by eliminating all but the most necessary instructions Replace the complex instructions with groups of smaller ones

Reduced Instruction Set Computer (RISC):


One cycle execution time. Pipelining: Different parts of an instruction are executed simultaneously. Reduced complexity in hardware. Less hardware space for transistors in the silicon for each instruction. Large register set: Variables and intermediate results are stored in the registers. Complex operations are performed as a series of simple RISC instructions. Instructions are of fixed length and format. Emphasis on software for each task. Program consists of large code size. Only load and store instructions refer to the memory and may take more than one clock cycle.

Advantages of RISC:
RISC uses only register to register operations Only LOAD and STORE operations have access to memory Separation of LOAD and STORE instructions allows the compiler to shift these operations around for maximum efficiency during execution. Simple instructions require fewer transistors which make the chips easier to design and cheaper to produce

The difference between CISC and RISC becomes evident through the basic computer performance equation: CPU TIME = time/program = [ (instructions/program) x (cycles/instruction) x (time/cycle) ]

RISC systems shorten execution time by reducing the clock cycles per instruction (i.e. simple instructions take less time to interpret)
CISC systems shorten execution time by reducing the number of instructions per program

RISC:
To multiply two numbers, first load each operand from a location in main memory (locations 1:1 through 6:4) into one of the six registers (A, B, C, D, E, or F). Once loaded, they can be multiplied by the execution unit (or ALU).

1. 2. 3. 4.

LOAD [A, 2:3] LOAD [B, 5:2] MULT [A, B] STORE [2:3, A]

CISC:
CISC rolls up this instruction set into one compact instruction to be handled by the decoder. MULT [2:3, 5:2] Microcode engine within the CPU decodes the complex instructions and executes microcode programs to carry out the task

CISC versus RISC


CISC Emphasis on hardware
Includes multi-clock complex instructions Variable length instructions Memory-to-memory: "LOAD" and "STORE" incorporated in instructions Small code sizes, high cycles per second Transistors used for storing complex instructions Many addressing modes

RISC Emphasis on software


Single-clock, reduced instruction only Fixed length instructions Register to register: "LOAD" and "STORE" are independent instructions Low cycles per second, large code sizes Spends more transistors on memory registers Few addressing modes Complexity in compiler

Complexity in microcode

Binary & Decimal Numbers:

BINARY (BASE 2) numbers

DECIMAL (BASE 10) numbers

Decimal (base 10) number system consists of 10 symbols or digits

0 1 2 3 4 5 6 7 8 9

Binary (base 2) number system consists of just two

Other popular number systems:


Octal
base = 8 8 symbols (0,1,2,3,4,5,6,7)

Hexadecimal
base = 16 16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

Decimal (base 10) numbers are expressed in the positional notation

The right-most is the least significant digit

4202 = 2x100 + 0x101 + 2x102 + 4x103


The left-most is the most significant digit

Decimal (base 10) numbers are expressed in the positional notation 1

4202 = 2x100 + 0x101 + 2x102 + 4x103


1s multiplier

Decimal (base 10) numbers are expressed in the positional notation 10

4202 = 2x100 + 0x101 + 2x102 + 4x103


10s multiplier

Decimal (base 10) numbers are expressed in the positional notation 100

4202 = 2x100 + 0x101 + 2x102 + 4x103


100s multiplier

Decimal (base 10) numbers are expressed in the positional notation 1000

4202 = 2x100 + 0x101 + 2x102 + 4x103


1000s multiplier

Binary (base 2) numbers are also expressed in the positional notation

The right-most is the least significant digit

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24


The left-most is the most significant digit

Binary (base 2) numbers are also expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24


1s multiplier

Binary (base 2) numbers are also expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24


2s multiplier

Binary (base 2) numbers are also expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24


4s multiplier

Binary (base 2) numbers are also expressed in the positional notation 8

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24


8s multiplier

Binary (base 2) numbers are also expressed in the positional notation 16

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24


16s multiplier

Why binary ?
Because this system is natural for digital computers The fundamental building block of a digital computer the switch possesses two natural states, ON & OFF. It is natural to represent those states in a number system that has only two symbols, 1 and 0, i.e. the binary number system

Decimal Binary conversion

Convert 75 to Binary
2 2 2 2 2 2 2 75 37 18 9 4 2 1 0
remainder

1 1 0 1 0 0 1

1001011

Check
1001011 = 1x20 + 1x21 + 0x22 + 1x23 + 0x24 + 0x25 + 1x26 = 1 + 2 + 0 + 8 + 0 + 0 + 64 = 75

Convert 100 to Binary


2 2 2 2 2 2 2 100 50 25 12 6 3 1 0
remainder

0 0 1 0 0 1 1

1100100

Logic Gates

Let x, y, z be Boolean variables. Boolean variables can only have binary values i.e., they can have values which are either 0 or 1

For example, if we represent the state of a light switch with a Boolean variable x, we will assign a value of 0 to x when the switch is OFF, and 1 when it is ON

A few other names for the states of these Boolean variables


0 Off Low False 1 On High True

Well define these operations with the help of truth tables


what is the truth table of a logic function ? A truth table defines the output of a logic function for all possible inputs

Boolean Algebra to Logic Gates:


Logic circuits are built from components called logic gates. The logic gates correspond to Boolean operations +, *,

OR +

AND *

NOT

Binary operations have two inputs, unary has one

AND Gate

Truth Table for the AND Operation (z true when both x & y true)

x
0

y
0

z=xy

0 1
1

1 0
1

Truth Table for the AND Operation

x
0

y
0

z=xy
0

0 1
1

1 0
1

0 0
1

AND Gate:
Logic Gate:
x y x*y = z

Truth Table:
x 0
x y

y 0

z 0

Series Circuit:

0 1 1

1 0 1

0 0 1

x*y = z

AND Gate Timing Diagram:


A high output is obtained when both inputs are high. For all other conditions output is low. AND is boolean multiplication so that a*b denotes a AND b.
x y

xy

OR Gate

Truth Table for the OR Operation (z true when x or y or both true)

x
0

y
0

z=x+y

0 1
1

1 0
1

Truth Table for the OR Operation

x
0

y
0

z=x+y
0

0 1
1

1 0
1

1 1
1

OR Gate:
Logic Gate:
X X+Y = Z

Truth Table:
X

X 0

Y 0

Z 0

Parallel Circuit:

0 1 1
Z

1 0 1

1 1 1

OR Gate Timing Diagram:


When any one input voltage is high we get an high output voltage. When both the inputs are low output is low. OR is boolean addition so that a + b denotes a OR b.

y
xy

NOT Gate

Truth Table for the NOT Operation (y true whenever x is false)

x
0

y = x

Truth Table for the NOT Operation

x
0

y = x
1

NOT Gate:
Logic Gate: (also called an inverter) x Y or x
Truth Table:

x 0

y 1

1
Single-throw Double-pole Switch: x Y or x

The not gate is often called an "Inverter". It has one input and one output. The little circle attached to any gate indicates that the output is logically negated or inverted
x y

NAND and NOR Gates:


NAND and NOR gates can greatly simplify circuit diagrams. As we will see, can you use these gates wherever you could use AND, OR, and NOT.

NAND

NOR

NAND Gate

NAND Gate (NAND = Not AND) :


It is a combination of AND gate followed by a NOT Gate

A 0

B 0

Y=AB 1

1
0 1

1
1 0

NAND

1 1

NAND Gate Timing Diagram:


NAND Gate is an AND Gate with output inverted.

NOR Gate

NOR Gate (NOR = Not OR):


It is a combination of OR gate followed by a NOT Gate

A 0

B 0

Y= AB 1

1
0 1

0
0 0

NOR

1 1

NOR Gate Timing Diagram:


NOR Gate is an OR Gate with output inverted
A B Y

XOR Gate

XOR Gate (Exclusive OR Gate):


It is an OR Gate with a NOT gate applied to one of its inputs It can also be a AND gate with a NOT gate as an input to it. _ A
B A+B=Y

XOR

Truth Table for the XOR Operation (z true when x or y true, but not both)

x
0

y
0

z=xy

0 1
1

1 0
1

Truth Table for the XOR Operation

x
0

y
0

z=xy
0

0 1
1

1 0
1

1 1
0

XOR Gate Timing Diagram:


When one input is high and other low there will be an output. When both the inputs are high/low there will be no output.

Combining Logic Gates:

Find the output of the following circuit

x y
Answer: (x+y)y
__
122

x+y

(x+y)y
y

Find the output of the following circuit

x y
Answer: xy
___ __

x y

xy

xy

You might also like