Comparison Between MPU - Computer - MCU
Comparison Between MPU - Computer - MCU
Definition of Microprocessor
A microprocessor is a tiny electronic chip found inside a computer's central processing unit,
microcontroller unit and other electronic devices. Its basic function is to take input, process it and then
provide appropriate output.
2 branches of applications:
1. Personal Computer – These microprocessor-based computers were intended to be versatile
tools that could load and run various programs such as word processor, spreadsheets, database
and games. They could also be easily custom-programmed by the user to do whatever the
programmer imagined. (Example : Intel 4004, and the likes)
2. Microcomputer (or Microcontroller unit) – A microprocessor-based computer as a control unit
embedded in a marketable product. These microcomputer is made up of the same elements as
the personal computer, but it is programmed once by the manufacturer. Then it spends its life
performing its intended tasks, such as waiting for buttons to be pressed and turning ON & OFF
devices such as lights, motors, beepers, etc.( Example: Intel 8051 family)
Digital computer – is a combination of digital device and circuits that can perform a programmed
sequence of operations with a minimum of human intervention.
- Is simply a high-speed machine that can manipulate data, solve problems, , and make
decisions, all under the control of the program.
Computer programmer – provides a program of instructions and data that specifies every detail of
what to do, what to do it and when to do it.
SECRET AGENT 89
- A far-fetched analogy that contains many concepts involved in computer operation.
Mission: Secret agent 89 is trying to find out the number of the airport landing strip where a known
terrorist will be landing.
Background: His contact tells him that the information is located in a series of post office boxes. To
ensure that no one else gets the information, it is spread through 10 different boxes. His contact gives
him 10 keys along with the following instructions:
1. The information in each box is written in code.
2. Open box 1 first and execute the instruction located there.
3. Continue through the rest of the boxes in sequence unless instructed to do otherwise.
4. One of the boxes contains information that will misdirect anyone but Agent 89.
1
1) Add the number stored in box 9 to your 2) Divide the previous result by the number
secret agent code number stored in box 10
3) Subtract the number stored in box 8 4) If the previous result is not equal to 30, go
to box 7. Otherwise continue to next box.
5) Subtract 13 from the previous result. 6) Return to headquarters for more
instructions.
7) The landingwill take place on strip #3 8) 20
9) 11 10) 2
Note: A computer like secret agent 89, decode and then execute the instructions stored in memory
sequentially, beginning with the first location.
Arrows – indicate the direction in which data, information, or control signals are flowing.
2 different-size arrows:
1. Larger arrows – represent data or information that consists of large number of parallel lines
2. Smaller arrows – represent control signals that are normally only one or a few lines.
2
Memory Unit
The memory stores groups of binary digits(word) that can represent instructions ( program) that the
computer is to perform and the data that are to be operated on by the program. The memory also
serves as storage for intermediate and final results of arithmetic operation (arrow 4). Operation of the
memory is controlled by the control unit (arrow 6), which signals for either a read or a write operation. A
given location in memory is accessed by the control unit that provides the appropriate address
code(arrow 7). Information can be written into the memory from the ALU or the input unit (arrow 8),
again under control of the control unit. Information can be read from memory into the ALU (arrow 2 ) or
into the output unit ( arrow 9).
Input Unit
The input unit consists of all of the devices used to take information and data that are external to the
computer and put them into the memory unit (arrow 8 ) or the ALU (arrow 3). The control unit
determines where the input information is sent ( arrow 10). The input unit is used to to enter the
program and data into the memory unit prior to starting the computer. This unit is also used to enter
data into the ALU from an external device during the execution of a program. Some of the common
input devices are keyboard, toggle switches, modems, magnetic-strip reader, magnetic disc units,
magnetic tape units, analog-to-digital converter(ADC), etc.
Output Unit
The output unit consists of the devices used to transfer data and information from the computer to the
“outside world”. The output devices are directed by the control unit (arrow 12) and can receive data
from memory (arrow 9) or the ALU (arrow 5); the data are then put into appropriate form for external
use. Example of common output devices are LED readouts, indicator lights, printers, disk or tape units,
video monitors, and DAC(digital-to-analog converter).
Control Unit
It directs the operation of all of the other units by providing timing and control signals. This unit contains
logic and timing circuits that generate the proper signals necessary to execute each instruction in a
program.
The control unit fetches an instruction from memory by sending an address (arrow7) and a read
command (arrow 6) to the memory unit. The instruction word stored at the memory location is then
transferred to the control unit (arrow 11).
Computer Interfacing – transmitting digital information between a computer and its peripherals in a
compatible and synchronized way.
Peripherals – the devices that make up the input and output units because they are external to the rest
of the computer.
Pronounced as separate letters, CPU is the abbreviation for central processing unit. Sometimes referred
to simply as the central processor, but more commonly called processor, the CPU is the brains of
the computer where most calculations take place. In terms of computing power, the CPU is the most
important element of a computer system.
On large machines, the CPU requires one or more printed circuit boards. On personal computers and
small workstations, the CPU is housed in a single chip called a microprocessor. Since the 1970's the
microprocessor class of CPUs has almost completely overtaken all other CPU implementations.
3
The CPU itself is an internal component of the computer. Modern CPUs are small and square and
contain multiple metallic connectors or pins on the underside. The CPU is inserted directly into a CPU
socket, pin side down, on the motherboard.
Memory Unit
clocks
RAM ROM
Input Output
Microprocessor(
Interface Interface
MPU)
Input Output
Device Device
Input/ output section – contain the interface circuits needed to allow the peripherals to communicate
properly with the rest of the computer.
Input/output interface circuits – in some cases, are LSI chips designed by the MPU manufacturer to
interface the MPU to a variety of I/O devices. In other cases, the interface circuits may be a simple as a
buffer register.
Embedded control application: all of the basic elements of a microcomputer are integrated into a single
IC known as the “single-chip microcomputer”.
4
THE MICROPROCESSOR (MPU)
The MPU is the heart of every microcomputer (or microcontroller). It performs a number of functions,
including:
1. Providing timing and control signals for all elements of the microcomputer
2. Fetching instructions and data from memory
3. Transferring data to and from memory and I/O devices
4. Decoding instructions
5. Performing arithmetic and logic operations called for by instructions
6. Responding to I/O-generated control signals such as RESET and INTERRUPT
The MPU contains all of the logic circuitry for performing these functions, but its internal logic is
generally not externally accessible. Instead, we can control what happens inside the MPU by the
program of instructions that we put in memory for the MPU to execute, that makes the MPU so versatile
and flexible.
Example: When we want to change its operation, we simply change the programs stored in RAM
(software) or ROM(firmware) rather than rewire the electronics(hardware).
A
DPTR R7 Address Bus
R6
Register R5
ALU
section
R0 Data Bus
PC
IR
Control and Timing Circuit Control Bus
Major functional areas of Microprocessor
Register section
- Contains various registers (inside the MPU), each of which performs a special function.
Program Counter – the most important register that keeps track of the addresses of the
instruction codes as they are fetch from memory. This is used in a subsequent description
of the program execution.
5
- Other MPU register are used to perform function depending on its type.
ALU Section
- Performs a variety of arithmetic and logic operations on data. These operations include
addition, subtraction, AND, OR, Ex-OR, shifting, incrementing and decrementing. More
advance MPU have ALU that can do multiplication and division.
Review questions:
1. Explain the difference between a microprocessor and a microcomputer.
2. Name the basic elements of a microcomputer.
3. Name the three major sections of an MPU.
4. What is the function of the PC?
COMPUTER WORDS
Note: a computer with a larger word size can execute programs of instructions at a faster rate because
more data and more instruction information are stuffed onto one word. The larger word sizes, however,
mean more lines making up the data bus, and therefore more interconnections between the CPU and
memory and I/O devices.
6
Types of Computer Words
2 kinds of information:
1. Instructions
2. Data- can be numerical or character information that is to be processed by a program that the
CPU is executing.
- can be in many forms including unsigned binary, BCD, floating-point (something like
engineering notations), or ASCII codes for characters, among others.
Example:
Signed-bit: +86 = 0 1010110 – numerical data
ASCII code (8-bits): “V” = 01010110 – character information
16-bits ASCII code: “VW” = 01010110 01010111
16-signed bits: +22103 = 01010110 01010111
Review Questions:
1. What two types of information are stored in computer words?
2. What is the advantage of a larger-word-size computer?
INSTRUCTION WORDS
- These words contain the information necessary for a computer to execute its various
operations, and the format and codes for these can vary widely from computer to
computer.
- Carry two basic units of information:
1. The operation to be informed (op code)
2. The address of the operand (data) to be operated upon (operation address)
7 6 5 4 3 2 1 0
Figure: Typical Single-Address Instruction Word
Operation code (op code) - represents the operation that the computer is being instructed to perform,
such as addition, subtraction, or moving data. It tells the computer what to do.
Operand address – represents the location in memory where the operand is stored. It tells computer
where to get data.
MULTIBYTE INSTRUCTIONS
Single word – a complete instruction that contains op code and operand address information stored in a
single memory location.
7
Three basic instruction formats:
1. Single –byte instruction
byte 0ne : Op Code
bits 7 6 5 4 3 2 1 0
2. Two-byte instruction
byte 0ne : Op Code
bits 7 6 5 4 3 2 1 0
3. Three-byte instruction
byte 0ne : Op Code
bits 7 6 5 4 3 2 1 0
Purpose:
Byte one – for the op code (instruction such as add, move, etc.)
Byte two – for the data value
Byte three – operand address
Machine language – the instruction words that are represented by 1s and 0s, the only language that the
machine (computer) understand.
Example: Some 8051 instructions
8
Mnemonic – abbreviation of instructions for easier to remember than op code.
High-level language – these are languages design to make it easy for man to write a program.
Note: it is important to understand that these high-level language instructions must be converted to
machine language instructions and placed in the computer’s internal memory before the computer can
execute them.
Compiler – a software or program that converts high-level language into machine language. It translates
these high-level instructions into a set of binary instructions (machine language) that can be loaded into
the microcomputer’s memory.
Assembly language – the complete set of mnemonics for a computer instruction set
Example:
Write a machine-language program that starts at address 0000H and does the following:
9
Memory Memory
Assembly Language Description
Address Contents
(hex) (hex)
0000 2 LIMP 0100H JUMP to start of program
0001 1
0002 0
First column – lists the hex address of each memory location being used by the program
Second column – gives the hex equivalent of the word stored in each memory location
Note: These hex values represent the actual binary addresses and instruction codes that the computer
understands.
Third column – gives the assembly language mnemonic and operand address associated with each
instruction.
Explanation:
The program starts executing at address 0000 when power is first applied, which resets the system. The
instruction that is generally stored at the reset address is a jump instruction that sends the micro to the
main program. The main program in this case starts at 0100, where it makes a decision either to jump
immediately to the rest of the program at 010A or to execute the instructions from 0102-0109. In either
case, it eventually executes the rest of the program from 010A until it is told to jump back to 0100 and
do it all over again.
PROGRAM EXECUTION
10
1. Fetch cycle – during which the control unit fetches the instruction codes (op code and operand
address) from memory
2. Execute cycle – during which the control unit performs the operation called for by the op code.
Reset – operation starts here when activated by applying power. This will initialize a program counter
(PC) to a starting count of 0000.
Recall: Program counter – a counter within the control unit that keeps track of the program addresses
as the computer sequences through them.
Write operation – when CPU sending data to another computer element and CPU is writing into the
selected element.
Read operation – when the CPU is receiving data from another element and the CPU is reading from the
selected element.
Bus system – carry all of the information and signals involved in the system operation.
Three buses:
1. Address bus – a unidirectional bus (information flows in only one direction), from CPU to the
memory or I/O elements that carry memory addresses/locations. Each of these addresses
corresponds to one memory location or one I/O element.
2. Data bus – a bidirectional bus (data can flow in either direction), from or to CPU that carry
various data. The CPU is performing a read /write operation.
3. Control bus – a set of signals that is used to synchronize the activities of the separate
microcomputer elements/units. Example is the CPU’s interrupt input, used by I/O devices to get
the attention of the CPU when it is performing other tasks.
TIMING
- Generates the basic clock signal to time all of its operation.
1. Machine cycle – all operations of the system, such as fetching and executing instructions,
reading and writing data, fit exactly into periods.
11
12