Chapter 6-Computer Architecture
Chapter 6-Computer Architecture
The processor
• Can be referred to generally as Central Processing Unit (CPU)
which is responsible for fetching, decoding and executing of all
computer instructions.
• It is commonly called the brain of the computer
• Computers cannot work without the processor
Co-Processor
This is an additional processor used for a specific task and improves
processing speed by executing jobs concurrently, e. g. maths co-
processor
Maths Core-Processor: an additional processor which works alongside
the main processor, capable of processing large representations using
large size registers, particularly used for floating point calculations
Processor Performance
The traditional processor’s performance is affected by these four main
components:
(a) Clock Speed
- The processor contains a timing device known as the clock. It
determines the timing of all operations.
- This sends out signals at a given interval, and all processes within the
computer will start with one of these pulses.
- A process may take any amount of time to complete, but it will only
start on a pulse.
(d) Architecture
- The architecture of a processor will affect its performance,
- A better designed processor will perform better than a different
processor.
2. Control unit
It manages the execution of instructions by running the clock.
It coordinates and controls all operations of computer system.
It also called the supervisor of the computer. It performs the following:
- Fetches the next instruction to be executed
- Decodes instructions
- Manages execution of instructions
- Executes decoded instructions
- Uses control signals to manage rest of processor.
- It carries out the Fetch-Execute Cycle as illustrated below:
(c) Registers:
- This is a high-speed storage area in the CPU used to temporarily
hold small units of program instructions and data immediately
before, during and after execution by the CPU.
- It is a small amount of storage available on the CPU whose contents
can be accessed more quickly than storage available elsewhere
- Registers are special memory cells that operate at very high speed.
They provide the fastest way for a CPU to access data.
- The CPU contains a number of registers and each has a predefined
functions
Index register
It is a register used for modifying operand addresses during
program execution,
Used in performing vector/array operations.
Used for indirect addressing where an immediate constant (i.e.
which is part of the instruction itself) is added to the contents of
the index register to form the address to the actual operand or
data
Flags Register: Used to record the effect of the last ALU operation
Fetch
The PC stores the address of the next instruction which needs to
be carried out
As instructions are held sequentially in the memory, the value in
the PC is incremented so that it always points to the next
instruction.
When the next instruction is needed, its address is copied from
the PC and placed in the MAR
The data which is stored at the address in the MAR is then copied
to the MDR
Once it is ready to be executed, the executable part if the
instruction is copied into the CIR
Decode
The instruction in the CIR can now be split into two parts, the
address and the operation
The address part can be placed in the MDR and the data fetched
and put in the MAR.
Execute
The contents of both the memory address register and the
memory data register are sent together to the central processor.
The central processor contains all the parts that do the
calculations, the main part being the CU (control unit) and the
Load the address that is in the program counter (PC) into the
memory address register (MAR).
Increment the PC by 1.
Load the instruction that is in the memory address given by the
MAR into the MDR
Load the instruction that is now in the MDR into the current
instruction register (CIR).
Decode the instruction that is in the CIR.
If the instruction is a jump instruction then
Load the address part of the instruction into the PC
Reset by going to step 1.
Execute the instruction.
Reset by going to step 1.
The first step simply places the address of the next instruction into the
memory Address Register so that the control unit can fetch the
instruction from the correct part of the memory. The program counter
is then incremented by 1 so that it contains the address of the next
instruction, assuming that the instructions are in consecutive locations.
Now that the instruction has been fetched the control unit can decode it
and decide what has to be done. This is the execute part of the cycle. If it
is an arithmetic instruction, this can be executed and the cycle restarted
as the PC contains the address of the next instruction in order. However,
if the instruction involves jumping to an instruction that is not the next
one in order, the PC has to be loaded with the address of the instruction
that is to be executed next. This address is in the address part of the
current instruction, hence the address part is loaded into the PC before
the cycle is reset and starts all over again.
Memory Unit
Is the computer memory that temporarily stores the operating system,
application programs and data currently use.
It used to store the following:
Program instructions in current use;
Data in current use;
Parts of Operating System that are currently in use.
Some architectures have a Memory Unit (Main memory) which has two
types: RAM and ROM.
Diagram
- Address bus:
Used for transferring memory addresses from the processor
when it is accessing main memory
They are used to access memory during the read or write
process
The width of the address bus determines the maximum
possible memory capacity of the computer.
This a uni-directional bus (one way). The address is send from
CPU to memory and I/O ports only.
- Control bus:
The purpose of the control bus is to transmit command, timing
and specific status information between system components.
Timing signals indicate the validity of data and address
information. Command signals specify operations to be
performed. Specific status signals indicate the state of a data
transfer request, or the status of request by a components to
gain control of the system bus
This is a bi-directional bus used for carrying control signals
(Signals can be transferred in both directions).
They carry signals to enable outputs of addressed port and
memory devices
Control signals regulate activities on the bus.
Control buses transmit command, timing and status
information between computer components.
Typical control signals are:
Memory Read
Compiled by KapondeniT. Page 12 of 34
Memory Write
I/O Read
I/O Write
Interrupt Request
Interrupt Grant
Reset
Ready hold
etc
Timing signals: indicate validity of data and information.
Command signals: Specify operations to be performed
Status signals: Indicate state of data transfer request or status
of a request.
Interrupt priorities
Interrupts have different priorities
This is important if two interrupts are received simultaneously the
processor for it to decide which one is more important to execute first.
There are four levels of priority, which are (highest priority order):
- Hardware Failure: can be caused by power failure or memory
parity error.
- Program Interrupts: Arithmetic overflow, division by zero, etc
- Timer Interrupts: generated by the internal clock
- I/O Interrupts:
Interrupt Handling
At the end of each Fetch-Execute cycle, the contents of the interrupt
registers are checked.
Should there be an interrupt; the following steps will typically be taken:
a) The current fetch-decode-execute cycle is completed
b) The operating system halts current task
c) The contents of the PC and other registers will be stored safely
in a stack.
d) The highest priority interrupt is identified. Interrupts with a
lower priority are disabled.
e) The source of the interrupt is identified.
f) The start address of the interrupt handler is loaded into the PC.
g) The interrupt handler is executed.
h) Interrupts are enabled again, and the cycle will restart with
any further interrupts.
i) The PC and other registers are “popped” from the stack and
restored.
j) The user’s program resumes with the next step in its cycle.
- If the interrupt 002 is received, the base number 5000 is added to it,
which allows the processor to know that the handler can be found by
opening the data stored at address 5002.
- The address 5002 simply stores a pointer to another memory
location, 6280, where the actual handler routine begins.
- The advantage of this approach is that each interrupt only needs to
give the processor an offset number, such as 002, and the processor
can determine from that the correct memory location to use. This is
more efficient than the interrupt sending the full memory address
itself. This approach also allows the interrupt routines to be stored
anywhere in the memory, with the pointer table updated to reflect if a
handler routine is moved
Sources of interrupts
- power failure/system failure
- peripheral e.g. printer (buffer empty)/hardware
- clock interrupt
- user interrupt e.g. new user log on request
- software
Buffer
- Buffer: This is a temporary memory store for data awaiting
processing or output, compensating speed at which devices
operate, for example printer buffer.
- A buffer is a memory in the interface between two devices which
temporarily store data which is being transmitted from one
device to another
- A buffer is a small amount of fast memory outside the processor
that allows the processor to get on with other work instead of
being held up by the secondary device.
- The buffer is necessary if the two devices work at the different
speed
- Buffering is appropriate where an output device processes data
slower than the processor. For example, the processor sends data
to the printer, which prints much slower and the printer does not
need to wait for the printer to finish printing in order for it to
carry out the next task.
- It therefore saves the data in a buffer where it will be retrieved by
the printer.
- Buffering usually match devices that work at different speeds, e.g.
processor and disk.
Cache Memory
- A cache is a small and very high speed memory used to speed
up the transfer of data and instructions, doubling the speed of
the computer in some cases.
- It can located inside or close to the CPU Chip
- it is placed between the CPU and the main memory.
- It stores frequently or most recently used instructions and data
- It is faster than RAM
- The data and instructions that are most recently or most
frequently used by CPU are stored in cache memory.
Diagram A Diagram B
• In the first clock cycle the processor gets the instruction from
memory and decodes it. In the next clock cycle the required data
is taken from memory. For each instruction this cycle repeats and
hence needs two cycles to complete an instruction
• Pipelining the instructions is not possible with this architecture.
• A stored-program digital computer is one that keeps its
programmed instructions, as well as its data, in read-write,
random access memory (RAM), that is the Von Neumann
computer. This makes the machines much more flexible.
• By treating those instructions in the same way as data, a stored-
program machine can easily change the program, and can do so
under program control.
• Once in the computer’s memory a program will be executed one
instruction at a time by repeatedly going through
• In the vast majority of modern computers, the same memory is
used for both data and program instructions.
Advantages
- Almost all data can be processed by the von Neumann
computer
- Cheaper than alternative types of processing
- Its design is very simple
Disadvantages
- Slower than other architectures
- Limited by bus transfer rate
- Does not maximise CPU utilisation
- Poorly written programs can have their data mixed up as both
data and instructions share the same memory
Diagram A Diagram B
Disadvantages
Serial Processing
Each instruction is executed in turn until the end of the program.
Advantages
- Nearly all programs can run on serial processing and therefore
no additional complex code can be written.
- All data types are suitable for serial processing
- Program can use the previous result in the next operation
- Data set are independent of each other
- Cheaper to handle than parallel
Disadvantages
- Slows data processing especially in the Von Neumann
architecture (bottleneck)
- Too much thrashing especially with poorly designed programs
Parallel Processing
- Parallel processing is the ability of a computer system to divide a
job into many tasks which are executed simultaneously, using
more than one processor, thus allowing multiple processing.
- Multiple CPUs can be used to carry out different parts of the fetch-
execute cycle.
- The computer is able to perform concurrent data processing to
achieve faster execution time.
- The system may have two or more ALUs and be able to execute
two or more instructions at the same time.
- It may also have two or more processors operating concurrently
As long as the pipelines can be kept full, it is making best use of the CPU.
This is an example of single instruction single data (SISD) processor,
again it should be quite clear why, the processor is processing a single
instruction to a single bit of data.
In pipelining, three instructions are dealt with at the same time. This
reduces the execution time considerably.
However, this would only be true for a very linear program.
Once jump instructions are introduced the problem arises that the
wrong instructions are in the pipeline waiting to be executed, so every
time the sequence of instructions changes, the pipeline has to be cleared
and the process started again.
Processors with pipelining are organized inside into stages which can
semi-independently work on separate jobs. Each stage is organized and
linked into a 'chain' so each stage's output is fed to another stage until
the job is done. This organization of the processor allows overall
processing time to be significantly reduced
Op-code (operator):
- is the part that represent the operations that the computer can
understand and carry out. It is the mnemonic part of the
instruction/that indicates what it is to do/code for the operation.
They are easier to remember. They can be represented by
mnemonics which are the pseudo names given to the different
operations that make it easier. E.g. ADD.
Operand:
- it is the address field in an instruction that holds data to be used
by the operation given in the opcode, e.g. in ADD 12, “12” is the
operand
- is the data to be manipulated, there’s no point telling the
computer what to ADD if there’s no data to apply it to. It can hold
the address of the data, or just the data.
The data is what the operation is being applied to, there are a number of
different ways in which this data can be represented, and this is known
as addressing.
1. Immediate Addressing
This is where the value to be used is stored in the instruction.
This is when the value in the instruction is not an address at all
but the actual data (constant to be used in the program).
The data to be operated on is held as part of the instruction
format.
The data to be used is stored immediately after the op code for the
instruction. Thus the operand field actually contains the data
e.g: LDA #&80 : Means that Load the hexadecimal value of 80 into
the accumulator register.
MOVE #8, R1: Moves the value 8 into register R1
Immediate addressing uses the # symbol.
This is very simple, although not often used because the program
parameters cannot be changed.
This means that the data being operated on can’t be adjusted and
only uses constants.
Can be used to initialize constants.
2. Direct Addressing
The address in the instruction is the address to be used to get to
the operand.
The operand gives the address of the data to be used in the
program.
3. Indirect Addressing
- In this mode of addressing, the address given in the instruction
holds the address of where the data is stored.
- This is whereby the real address is stored in the memory so the
value in the address part of the instruction is pointing to the
address of the data.
- The address of data in memory is held in another memory
location and the operand of the instruction holds the address of
this memory location.
Relative Addressing
- The same as Indexed Addressng except that the PC replces the
Index Register.
- E.g Load Ri, X (PC)
- This loads register Ri with the contents of the memory location
whose address is the sum of the contents of the PC and the value
X.
- This is direct addressing that does not commence from the start of
the address of the memory.
- It begins from a fixed point, and all addresses are relative to that
point.
- allows a real address to be calculated from a base address by
adding the relative address
- relative address is an offset and can be used for arrays
Indexed Addressing
- The address part of the instruction is added to a value held in the
index register.
- It is where the actual address is found by adding a displacement
to the base address.