Understanding Hardware: CPU - Part 2
We have read about the CPU in the previous article. We have learned that
the primary job of CPU is to fetch instructions from memory and execute them.
This memory could be either ROM or RAM. So CPU can't work alone. It must be
connected to the memory chips. For connecting to the other chips, CPU will
have a set of pins. These pins are divided into three groups. Address pins,
Data pins and Control pins. In the same way all types of memory chips will
also have address, data and control pins.
When CPU chip is soldered to the printed circuit board (PCB) these pins are
connected to the address lines, data lines and control lines of the PCB.
These lines on the PCB are also connected to the memory chips. In this way
PCB is providing a connection between CPU and memory chips.
All address lines put together we refer as address bus, similarly data bus
and control bus. Number of lines in the bus is refered as width of the
bus. When someone says data bus width is 8, it means that there are
8 data lines in the data bus.
The width of the data bus indicates, how many bits of data, at a time can
be transfered between CPU and memory. CPU typically needs to transfer data
between registers and memory. So normally the width of the data bus is
identical to the register size in bits. If register size
is 32 bit, then there will be 32 data lines. This allows transfering of
whole register at a time to memory. But in some rare CPUs, data lines
may be less than register size. In such case, multiple transfers are used.
The Data pins or Data lines are numbered as D0 to D7 for 8 bit data bus,
and D0 to D15 for 16 bit data bus. When 8 bit data is transfered over the bus,
the Least Signficant Bit(LSB) is transfered on D0 and Most Significant
Bit (MSB) on D7.
The number of address lines determines the addressing capacity of the CPU.
If CPU got only 8 address lines, it can address only 2 power 8, that is 256
memory locations. If CPU has 16 address lines, then it can address 2 power 16,
that is 64 Kilo Bytes (KB) of memory. Note that here Kilo means 1024 not 1000.
CPU with 20 address lines can address 1 Mega Bytes of memory. Again here
Mega means 1024 x 1024. Similarly CPU with 32 address lines can address
4 Giga Bytes (GB) of memory. One Giga is 1024 x 1024 x 1024.
The Address pins or Address lines are numbered from A0 to A15 for 16 bit
address bus. Least significant bit of address is sent on the A0 line and
most significant bit on A15.
As discussed above, CPU is connected to memory and other chips through
its bus lines. Each transaction on the bus, which involves transfer of
data is called a bus cycle. The bus cycle describes the hardware protocol
for transfer of data. Based on the purpose and direction of data transfer,
bus cycles are divided into three types:
- Instruction fetch cycle
- Memory read cycle
- Memory write cycle
Instruction fetch cycle and memory read cycle are identical. But differs
only in purpose. CPU's job is always to fetch an instruction by using
this instruction fetch cycle. So CPU continuously uses this cycle.
The memory read and memory write cycles are used by the CPU, when it is
executing Load and Store instructions. Execution of 'Load' instruction,
involves movement of data from memory to register. So CPU uses memory read
cycle. To execute 'Store' instruction, it uses memory write cycle. Store
instruction needs to move data from register to memory.
CPU features compare
If you compare embedded hardware with a car, CPU is like engine of a car.
To make a car, engine needs to be connected to wheels through transmission
system. Breaking system, fuel system, steering control, seats and so many
other things makes car. Similarly to make an embedded hardware board, CPU
must be connected with many chips like memory chips and IO chips. This will
be the topico of next articles.
When we compare engines of two cars, we compare features like engine volume,
number of cylinders, power, torque etc.. Similarly when we wish to compare
two CPUs, the following features are normally compared:
- Clock speed
- CPU processing ability (8/16/32/64 bit CPU)
- Data bus width
- Address bus width
- Number of registers
- Instruction set it supports
Our CPU features
The CPU so far we are studying is a simple CPU meant for educational
purpose. A graphical simulation of this CPU was developed at DEPIK.
Following are the features of this CPU.
- Clock speed 4 MHz
- CPU processing ability (8 bit CPU)
- 8 data lines
- 8 address lines
- 6 registers (4 general purpose registers, Program counter, status register)
- simple RISC model 20 instructions
Answer the following questions to check the understanding of the subject
1. What is Data bus and explain its purpose
2. What is address bus and explain its purpose
3. What is the difference between instruction fetch cycle and memory read cycle?
4. List the CPU features, that can be used to compare two CPUs