Chapter 4 CPU Architecture
Chapter 4 CPU Architecture
Microcontroller Systems
Chapter 4
CPU Architecture
1. CPU Architecture
2. The Microprocessor unit
2.1 Basic Microcomputer architecture
2.2 the purpose of the major components of a computer
system
2.3 The role of the CPU in computer systems
2.4 Internal working of CPUs
3. Harvard and von Neumann architectures
Introduction.
In this section we will examine the inside of a CPU.
Then, we will compare the
Harvard and von Neumann architectures.
Inside CPU_1.
A program stored in memory provides instructions to the CPU to
perform an action.
The action can simply be adding data such as payroll data or controlling a
machine such as a robot.
The function of the CPU is to fetch these instructions from memory and
execute them.
Inside CPU_1.
Inside CPU_2.
To perform the actions of fetch and execute, all CPUs are equipped with
resources such as the following:
1. Registers
The CPU uses registers to store information temporarily.
» Two values to be processed,
» or the address of the value needed to be fetched from memory.
Registers inside the CPU can be 8-bit, 16-bit, 32-bit, or even 64-bit
registers, depending on the CPU.
In general, the more and bigger the registers, the better the CPU.
The disadvantage of more and bigger registers is the increased cost of
such a CPU.
Inside CPU_3.
2. ALU (arithmetic/logic unit).
The ALU section of the CPU is responsible for performing arithmetic
functions such as add, subtract, multiply, and divide, and logic
functions such as AND, OR, and NOT.
3. a Program Counter
The function of the program counter is to point to the address of the
next instruction to be executed.
As each instruction is executed, the program counter is incremented
to point to the address of the next instruction to be executed.
The contents of the program counter are placed on the address bus to
find and fetch the desired instruction.
In the IBM PC, the program counter is a register called IP, or the
instruction pointer.
Inside CPU_4.
4. Instruction decoder
The function of the instruction decoder is to interpret the instruction
fetched into the CPU.
One can think of the instruction decoder as a kind of dictionary,
storing the meaning of each instruction and what steps the CPU
should take upon receiving a given instruction.
Just as a dictionary requires more pages the more words it defines, a
CPU capable of understanding more instructions requires more
transistors to design.
Figure shows the steps that the CPU goes through to execute an instruction..
The actions performed by the CPU to run the program above would
be as follows_1:
The CPU’s program counter can have a value between 0000 and
FFFFH.
The program counter must be set to the value 1400H, indicating
the address of the first instruction code to be executed.
After the program counter has been loaded with the address of the
first instruction, the CPU is ready to execute.
The CPU puts 1400H on the address bus and sends it out.
The memory circuitry finds the location while the CPU activates
the READ signal, indicating to memory that it wants the byte at
location 1400H.
This causes the contents of memory location 1400H, which is B0,
to be put on the data bus and brought into the CPU.
The actions performed by the CPU to run the program above would be as
follows_2:
The CPU decodes the instruction B0 with the help of its instruction
decoder dictionary.
When it finds the definition for that instruction it knows it must bring the
byte in the next memory location into register A of the CPU.
Therefore, it commands its controller circuitry to do exactly that.
When it brings in value 21H from memory location 1401, it makes sure
that the doors of all registers are closed except register A.
Therefore, when value 21H comes into the CPU it will go directly into
register A.
After completing one instruction, the program counter points to the
address of the next instruction to be executed, which in this case is 1402H.
Address 1402 is sent out on the address bus to fetch the next instruction..
The actions performed by the CPU to run the program above would be as
follows_3:
From memory location 1402H the CPU fetches code 04H.
After decoding, the CPU knows that it must add the byte sitting at the
next address (1403) to the contents of register A.
After the CPU brings the value (in this case, 42H) into register A, it
provides the contents of register A along with this value to the ALU to
perform the addition.
It then takes the result of the addition from the ALU’s output and puts it
into register A.
Meanwhile the program counter becomes 1404, the address of the next
instruction.
Address 1404H is put on the address bus and the code is fetched into the
CPU, decoded, and executed. This code again is adding a value to register
A.
The program counter is updated to 1406H.
The actions performed by the CPU to run the program above would be as
follows_3:
Finally, the contents of address 1406 are fetched in and executed. This
HALT instruction tells the CPU to stop incrementing the program counter
and asking for the next instruction.
Without the HALT, the CPU would continue updating the program
counter and fetching instructions.
Now suppose that address 1403H contained value 04 instead of 42H. How would
the CPU distinguish between data 04 to be added and code 04?
Remember that code 04 for this CPU means “adds the next value into register A.”
Therefore, the CPU will not try to decode the next value. It simply adds the
contents of the following memory location into register A, regardless of its value.
For this reason you do not see Harvard architecture implemented in the world
of PCs and workstations.
This is also the reason that microcontrollers such as AVR use Harvard
architecture internally,
but they still use von Neumann architecture if they need external memory for
code and data space.
The von Neumann architecture was developed at Princeton University, while
the Harvard architecture was the work of Harvard University.