Lecture Introduction
-
Upload
khurram-abbas -
Category
Documents
-
view
18 -
download
0
Transcript of Lecture Introduction
Lecture no. 18Microprocessors & Microcontrollers
7
Stored Program Concept
8
Stored Program Concept• There are three major parts
– The CPU (Central Processing Unit) which acts as the brain coordinating all activities within the computer
– The memory unit where the program instructions and data are temporarily stored– The I/O (Input/Output) devices which allow the computer to input information for
processing and then output the result• Today the CPU circuitry has been reduced to ICs called the microprocessor,
the entire computer with the three parts is called a microcomputer• Several registers (e.g., flip-flops wired in series with each other)
– Some are general purpose, the accumulator for example is reserved for performing complex mathematical operations like multiply and divide, and all I/O data has to go thru the accumulator
• The basic timing of the computer is controlled by a square wave oscillator or a clock generator circuit.
– Synchronization– Determines how fast the program can be fetched from memory and executed
• Memory Read or Fetch Cycle– IP: Instruction Pointer
9
Stored Program Concept• Memory unit consists of a large number of storage locations each
with its own address– RAM (Random Access Memory) and its volatility
• Typically each memory location is 8 bits wide (byte accessible memory)– ROM (Read Only Memory)
• The memory unit’s address selector/decoder circuit examines the binary number on the address line and selects the proper memory location to be accessed.– In this example, CPU is reading from memory, it activates its MEMORY
READ control signal– This causes the selected data byte in memory to be placed onto the
data lines and routed to the instruction register in the CPU• Once in the CPU, the instruction is decoded and executed
– In this example, instruction has the decimal code 64 which for a 8086 microprocessor is decoded to be INC AX
– The ALU (Arithmetic Logic Unit) is instructed to add 1 to the contents of the AX
• The cycle repeats itself
21
Internal Working Of Computers
1- the CPU program counter can have any value between 0000 FFFF H. This one is set to start with 1400
2- the CPU puts out 1400. The memory circuitry finds the location. Activates the read signal, indicating the memory location 1400. B0 is put on the bus and brought to the CPU
3- B0 is decoded internally it now knows it needs to fetch the next byte!. It brings 21h from 1401. The program counter automatically increments itself to the next location to fetch the next data/instruction.
MEM
CPUPC=1400
Read
B0Inst Decoder
B0 decode
22
General Purpose Microprocessors
CPU General Purpose
MicroprocessorRAM
Serial COM Port
TimerI/OROM
These general microprocessors contain no RAM, ROM, or I/O ports on the chip itselfEx. Intel’s x86 family (8088, 8086, 80386, 80386, 80486, Pentium)Motorola’s 680x0 family (68000, 68010, 68020, etc)
Data bus
Address bus
Microprocessors lead to versatile products
23
Microcontrollers
CPU RAM ROM
I/O TIMER Serial Com Port
Microcontroller
A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports on one single chip; this makes them ideal for applications in which cost and space are criticalExample: a TV remote control does not need the computing power of a 486
47
Computer Operating Systems• What happens when the computer is first turned on?• MS-DOS
– A startup program in the BIOS is executed– This program in turn accesses the master boot record on the floppy or
hard disk drive– A loader then transfers the system files IO.SYS and MSDOS.SYS from
the disk drive to the main memory– Finally, the command interpreter COMMAND.COM is loaded into
memory which puts the DOS prompt on the screen that gives the user access to DOS’s built-in commands like DIR, COPY, VER.
• The 640 K Barrier– DOS was designed to run on the original IBM PC– 8088 microprocessor, 1Mbyte of main memory– IBM divided this 1Mb address space into specific blocks
• 640 K of RAM (user RAM)• 384 K reserved for ROM functions (control programs for the video system,
hard drive controller, and the basic input/output system)
48
Memory Map
49
MS-DOS Functions and BIOS Services
• Program Support• BIOS: usually stored in ROM these routines provide access to the
hardware of the PC• Access to the BIOS is done through the software interrupt instruction
Int n• For example, the BIOS keyboard services are accessed using the
instruction INT 16h• In addition to BIOS services DOS also provides higher level
functions– INT 21h– More details later
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
1
Microprocessors
An Intel Pentium II
Heart of a computer — “Central Processing Unit”Small integrated circuit with many transistorsProgrammableBe able to compute (arithmetic, logic, etc.)Work with I/O peripherals & memory
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
2
Early history
1969 - 70 Intel 4004, the first microprocessor, 4-bitIntel 4040, faster then 4004
1971 Intel 8008, a 8-bit version of 4004
1973 Intel 8080, 10 times faster than 8008(Similar products: Motorola MC6800, Zilog Z80)
1974 MITS Altair 8800, the first microcomputerprogrammed with BASIC developed by Bill Gates and Paul Allen
1977 Apple II, the first popular home computerIntel 8085, the last 8-bit microprocessor
1978 Intel 8086, 16-bit microprocessor, much faster
1979 Intel 8088
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
3
1980s1980 Motorola 68000
1981 IBM PC with Intel 8088, running at 4.77 MHz with a 160K floppydisk drive & MS-DOS 1.0/1.1
1982 Intel 80286
1984 Apple Macintosh, with Motorola 68000
1985 Intel 80386
1987 Macintosh II
1989 Intel 80486 at 25 MHz or higher speed
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
4
More recently
1990 Microsoft Windows 3.0 releasedMotorola 68040 developed
1991 Apple and IBM formed a partnership to investigate RISC
1992 Microsoft Windows 3.1 became the standard for PCs.
1993 Intel Pentium (80586) released, MMX technology provided later
1995 Microsoft Windows 95
1995 Intel Pentium Pro (P6)
1997 Intel Pentium II
1998 Intel Pentium II Xeon
1999 Intel Pentium III
2001 Intel Pentium IV
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
5
Growth of capability: the Intel family No. of
transistorsAddressable
MemoryClock Speed
(MHz)MIPs
4004 2,300 640 Bytes 0.108 0.06 8008 3,500 16 KBytes 0.2 0.06 8080 6,000 64 KBytes 2 – 3.1 0.64 – 1 8086 29 K 1 MBytes 5 – 10 0.33 – 0.75 8088 29 K 1 MBytes 5 – 10 0.33 – 0.68 80186 29 K 1 MBytes 8 – 12 1.2 – 1.66 80286 134 K 16 MBytes 8 – 12 1.2 – 1.66 80386SX 275 K 16 MBytes 16 – 33 2.5 – 5 80386DX 275 K 4 GBytes 16 – 33 6 – 12 80486DX 3,200 K 4 GBytes 25 – 100 20 – 80 Pentium 3,200 K 4 GBytes 60 – 133 100 – 200 Pentium Pro 5,500 K 64 GBytes 150 – 200 ~ 250 Pentium II (Klamatch) 7,500 K 64 GBytes 233 – 500 ??? Pentium III (Katmai) 9,500 K 64 GBytes up to 1,200 ??? Pentium IV ??? ??? ??? ???
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
6
Other processors
Intel-compatible:AMD (e.g. K6, k7 series)CyrixIDT
Other general-purpose CPUs:
Motorola 68K series (Apple Macintosh)IBM PowerPCDEC AlphaSunMicro’s UltraSPARC, MAJC (for Java Computing)
Special-purpose processors
Microcontroller: e.g. Intel 8051,Digital Signal Processors: e.g. TMS320C seriesFor handheld products: Intel StrongArm
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
7
Microprocessor-based computer
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
8
Bus, memory & I/O
Bus: a set of connectionscarry the same type of information
binary Memory: ICs that store programs & data
I/O: Input/output devices via which themicroprocessor communicates with outside world
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
10
Memory & addressComputer memory is organized on per byte basis: data are stored ingroups of 8 bits. The location of a data byte is represented by an address in thememory system. Each address points to a 8-bit data.
The address is also a binary number.
Address
11001111000
01110100001
11110001010
11001011011
00000000100
10000000101
01010010110
10000100111
Data in memory
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
11
Address bits & address bus1-bit address can point to only two memory locations.
8-bit address can index 28 = 256 memory locations.
The number of address bits is referred to as the width of address bus.
Intel 8086/8088 uses 20-bit address bus. Thus the address range is0000 0000 0000 0000 0000 – 1111 1111 1111 1111 1111
or in hexadecimal00000H – FFFFFH
The number of memory locations is 220 = 1,048,576
210 = 1,024 = 1 K 220 = 1 K × 1 K = 1 M230 = 1 K × 1 M = 1 G
Question: How many address bits are required to fully access the RAMin your home computer ?
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
12
I/O spaceI/O space is organized and addressed in the same way as the memoryspace. Each I/O address corresponds to an 8-bit I/O port. For Intel 8088, 64K (65,536) I/O ports are addressed. This requires only16 address lines.
For memory space addressing, all 20 address lines are used. The I/O and memory share the same address bus. A separate controlsignal is needed to indicate whether the bus is carrying I/O address ormemory address.
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
13
8088 based microcomputer
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
14
Microprocessor operation
There is little memory inside a microprocessor (µµµµP). This internalmemory is referred as register.The µµµµP has to load data and program from outside into itsinternal registersBoth data and program are binaryProgram is often stored in the memoryProgram is divided into many tiny steps. Each step is performedby an instructionTypically an instruction is several bytes longData are either loaded from the memory or supplied by the I/O
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
15
Fetch
Decode
Execution
load an instruction from memoryinto an internal register
interpret the fetched instruction
execute the instructione.g. read/write data, arithmeticcomputation on loaded data
Fetch-decode-execution cycle
During the fetch-decode-execution cycle, the µµµµP may receive aninterrupt signal via the control bus
Upon the interrupt request, the µµµµP will finish the execution of currentinstruction and then responds to the interrupt
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
16
Programming the microprocessor
An instruction is a simple command telling the µµµµP what to doEach model of microprocessor has its own instruction setIntel 8088 has 90 basic instructions.The µµµµP understands binary numbers only. Any instruction is nothingbut a string of 0’s and 1’s, which is called machine language.Each instruction may occupy multiple bytes:
Op code Operand ... ... Operand
indicatingwhat to do
data (or the addresseswhere data are stored)
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
17
Machine language
B8 23 01 [Move the value 0123H to AX]05 25 00 [Add the value 0025H to AX]8B D8 [Move the content of AX to BX]03 D8 [Add the content of AX to BX]8B CB [Move the content of BX to CX]2B C8 [Subtract the content of AX from CX]2B C0 [Subtract the content of AX from AX]C3 [Return to system]
AX, BX, CX, etc. are the internalregisters in the µµµµP.
0123H means hexadecimal value 0123,i.e. 0000 0001 0010 0011
Binary code Action
1st instruction2nd instruction
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
18
Assembly languageProgramming directly with machine codes is neither desirable norfeasible. It is very difficult to debug.
Assembly language is represented by word-like terms that aremuch more comprehensible than binary number.
B8 23 01 MOV AX,0123H [Move the value 0123H to AX]
05 25 00 ADD AX,25H [Add the value 0025H to AX]
8B D8 MOV BX,AX [Move the content of AX to BX]
03 D8 ADD BX,AX [Add the content of AX to BX]
8B CB MOV CX,BX [Move the content of BX to CX]
2B C8 SUB CX,AX [Subtract the content of AX from CX]
2B C0 SUB AX,AX [Subtract the content of AX from AX]
C3 RET [Return to system]
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
19
Arithmetic& logic unit
EU registerset
Segmentregisters
Instructionqueue
Execution unit (EU)
Bus interface unit (EU)
Buscontrol
unit
databus
Databus
Addressbus
Controlbus
Registers: small, fastmemory that store data oraddresses temporarily.
In a 8086/8088, there areten 16-bit EU registers andanother four 16-bit segmentregisters.
16 bit
(16 bit in 8086,8 bit in 8088)
(20 bit)
8088/8086 internal architecture
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
20
Internal registers
Flag register
8 bit
8 bit 8 bit
16 bit
16 bit
16 bit
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
21
Segment and offset8086/8088 uses a 20-bit address bus
However, all of its internal registers are 16 bit. How are these registersused to store the 20 bit address ?
16-bit segmentaddress
16-bit offset address
20-bit physicaladdress
0371115
+)
shift by 4 bit
0371115
037111519
The offset address can specify up to 216 = 64 KBytes of memory.
The segment address gives the beginning of such a 64 K block.
Revised on 2001/9/10 1:15 PM ELE3230A Microprocessor & Computer SystemsLecture on 10 September 2001
22
CS is a segment register, holding thevalue A000H.
IP holds the offset address 5F00H.
The physical address is A5F00H
Exercises:
CS = 2300H and IP = 1000H
CS = 1A00H and IP = B000H
Segment and offset (continued)
⇒ 23000H + 01000H = 24000H
⇒ 1A000H + 0B000H = 25000H