Uploaded by iampierced219

P02 EEE184-LECTURE-NOTES-1

advertisement
EEE184 LECTURE NOTES
I.
BASIC BUILDING BLOCKS OF MICROCOMPUTER
A microcomputer has three basic blocks: a central processing unit (CPU), a memory unit,
and an input/output unit.
The CPU executes all the instructions and performs arithmetic and logic operations on
data. The CPU of the microcomputer is called the “microprocessor.”
A memory unit stores both data and instructions. The memory section typically
contains ROM and RAM chips.
An I/O (Input/Output) unit transfers data between the microcomputer and the external
devices via I/O ports (registers).
Figure 1. Basic blocks of a microcomputer
Figure 2. Simplified version of a typical microcomputer
II.
TYPICAL MICROCOMPUTER ARCHITECTURE
a. MICROCOMPUTER BUS
i. ADDRESS BUS – information transfer takes place only in one direction, from the
microprocessor to the memory or I/O elements. For example, a microprocessor
with 20 address pins can generate 220 = 1,048,576 (one megabyte) different
possible addresses on the address bus. It’s addresses are from 0 to 1,048,575.
ii. DATA BUS – data can flow in both directions, that is, to or from the
microprocessor.
iii. CONTROL BUS – consists of a number of signals that are used to synchronize the
operation of the individual microcomputer elements. The microprocessor sends
some of these control signals to the other elements to indicate the type of
operation being performed.
b. CLOCK SIGNALS
The system clock signals are contained in the control bus. These signals generate the
appropriate clock periods during which instruction executions are carried out by the
microprocessor.
Figure 3. Clock signal
III.
THE SINGLE – CHIP MICROPROCESSOR
The microprocessor is divided into three main areas: the Register section, control unit and
the arithmetic and logic unit (ALU).
a. Register section – The number, size, and types of registers vary from one
microprocessor to another. However, the various registers in all microprocessors carry
out similar operations.
Basic microprocessor registers:
i. Instruction Register (IR). The instruction register stores instructions. The
contents of an instruction register are always decoded by the microprocessor as
an instruction. After fetching an instruction code from memory, the
microprocessor stores it in the instruction register. For example, a 16-bit
microprocessor has a 16-bit instruction register.
ii. Program Counter (PC). The program counter contains the address of the
instruction or operation code (op-code). The program counter normally contains
the address of the next instruction to be executed.
iii. Memory Address Register (MAR). The memory address register contains the
address of data. The microprocessor uses the address, which is stored in the
memory address register, as a direct pointer to memory. The contents of the
address consist of the actual data that is being transferred.
iv. Accumulator (A). It is used to store the result after most ALU operations.
Use of the Basic Microprocessor Registers:
To provide a clear understanding of how the basic microprocessor registers are used, a
binary addition program will be considered. The program logic will be explained by
showing how each instruction changes the contents of the four registers. Assume that
all numbers are in hex. Suppose that the contents of the memory location 2010 are to
be added with the contents of 2012.
Let us consider that address 2010 contains 0002 and address 2012 contains 0005. The
following are the steps involve in the addition of the two numbers:
(1) Load the memory address register (MAR) with the address of the first data item to
be added, that is, load 2010 into MAR.
(2) Move the contents of this address to a data register, D0; that is, move first data into
D0.
(3) Increment the MAR by 2 to hold 2012, the address of the second data item to be
added.
(4) Add the contents of this memory location to the data that was moved to the data
register, D0 in step 2, and store the result in the 16-bit data register, D0.
v. Index Register – is typically used as a counter in address modification for an
instruction, or for general storage functions. The index register is particularly
useful with instructions that access tables or arrays of data.
vi. Status Register – also known as the “processor status word register” or the
“condition code register,” contains individual bits, with each bit having special
significance. The bits in the status register are called “flags.”
Some of the common flags:
(1) Carry Flag – used to reflect whether or not the result generated by an
arithmetic operation is greater than the microprocessor’s word size.
(2) Zero Flag – is used to show whether the result of an operation is zero.
(3) Parity Flag – is set to 1 to indicate whether the result of the last operation
contains either an even number of 1 ’s (even parity) or an odd number of 1 ’s
(odd parity), depending on the microprocessor.
(4) Sign Flag – also known as negative flag. It is used to indicate whether the
result of the last operation is positive or negative.
(5) Overflow Flag – arises from the representation of the sign flag by the most
significant bit of a word in signed binary operation. The overflow flag is set to 1
if the result of an arithmetic operation is too big for the microprocessor’s
maximum word size, otherwise it is reset to 0.
Example: Determine the carry (C), sign (S), zero (Z), overflow (V), and parity (P)
flags for the following operation: 0110 plus 1010.
Let us assume that the parity bit=1 is an odd parity.
Therefore, the C=1, S=0, Z=1, V=1 and P = 0.
Then the flag register can be implemented by this circuit.
Figure 4. Flag register
vii. Stack Pointer Register – The stack consists of a number of RAM locations set
aside for reading data from or writing data into these locations and is typically
used by subroutines (a subroutine is a program that performs operations
frequently needed by the main or calling program).
b. Control Unit – The main purpose of the control unit is to read and decode instructions
from the program memory. To execute an instruction, the control unit steps through the
appropriate blocks of the ALU based on the op-codes contained in the instruction
register.
The common control signals:
i. RESET – This input is common to all microprocessors. When this input pin is
driven to HIGH or LOW (depending on the microprocessor), the program
counter is loaded with a predefined address specified by the manufacturer. For
example, in the 80486, upon hardware reset, the program counter is loaded
with FFFFFFF0. This means that the instruction stored at memory location
FFFFFFF0 is executed first.
Μ… ) – This output line is common to all microprocessors. The
ii. READ/WRITE (𝑅/π‘Š
status of this line tells the other microcomputer elements whether the
microprocessor is performing a READ or a WRITE operation.
Μ…Μ…Μ…Μ…Μ…Μ…Μ…Μ…Μ…Μ… – This is an input to the microprocessor. Slow devices (memory and I/O)
iii. π‘…πΈπ΄π·π‘Œ
use this signal to gain extra time to transfer data to or receive data from a
microprocessor.
iv. Interrupt Request (INT or IRQ) – The external I/O devices can interrupt the
microprocessor via this input pin on the microprocessor chip. When this signal is
activated by the external devices, the microprocessor jumps to a special
program, called the “interrupt service routine.”
c. Arithmetic and Logic Unit (ALU) – The ALU performs all the data manipulations, such as
arithmetic and logic operations, inside the microprocessor. The size of the ALU conforms
to the word length of the microcomputer. This means that a 32-bit microprocessor will
have a 32-bit ALU. Typically, the ALU performs the following functions:
(1) Binary addition and logic operations
(2) Finding the ones complement of data
(3) Shifting or rotating the contents of a general-purpose register 1 bit to the left or
right through carry
ACTIVITY 01:
1. Assume that these are signed numbers for an 8-bit microprocessor, find the sign,
carry, zero, and overflow flags:
a. 6E16 + 3A16
b. 0916 + 1716
2. If we have a 16K addresses in the memory. How many address pins are needed for
accessing all the addresses in the memory? Determine the range of memory
addresses in hexadecimal.
Download