Computer Organisation-Unit - II
Computer Organisation-Unit - II
Computer Organisation-Unit - II
Fundamental Concepts
Processor fetches one instruction at a time, and perform the operation specified.
Instructions are fetched from successive memory locations until a branch or a jump instruction is
encountered.
Processor keeps track of the address of the memory location containing the next instruction to be
fetched using Program Counter (PC).
Instruction Register (IR)
Executing an Instruction
Fetch the contents of the memory location pointed to by the PC. The contents of this location are
loaded into the IR (fetch phase). IR ← [[PC]]
Assuming that the memory is byte addressable, increment the contents of the PC by 4 (fetch
phase). PC ← [PC] + 4
Carry out the actions specified by the instruction in the IR (execution phase).
Processor Organization
Register Transfers
Example
Suppose we wish to transfer the contents of register R1 to register R4. This can be
accomplished as follows.
Enable the output of registers R1 by setting R1out to 1. This places the contents of R1 on the
processor bus.
Enable the input of register R4 by setting R4in to 1. This loads data from the processor bus
into register R4.
All operations and data transfers with in the processor take place within time periods
defined by the processor clock.
The control signals that govern a particular transfer are asserted at the start of the clock
cycle.
Bus
D Q
1
Q
Riout
Ri in
Clock
Figure 2.3 Input and output for one register bit.
Performing an Arithmetic or Logic Operation
The ALU is a combinational circuit that has no internal storage.
ALU gets the two operands from MUX and bus. The result is temporarily stored in
register Z.
What is the sequence of operations to add the contents of register R1 to those of R2 and store
the result in R3?
o R1out, Yin
MDRinE
Clock
MAR in
Address
Read
MR
MDR inE
Data
MFC
MDR out
Step Action
Figure: 2.6 Control sequence for execution of the instruction Add (R3), R1.
Multiple-Bus Organization
MUX
Fig 2.10: Control Sequence for the Instruction for the three bus organization
Hardwired Control
To execute instructions, the processor must have some means of generating the control signals
needed in the proper sequence.
Two categories: hardwired control and micro programmed control
Hardwired system can operate at high speed; but with little flexibility.
CLK
Clock Control step Reset
counter
Step decoder
T 1 T2 Tn
INS1
External
INS2 inputs
Instruction
IR Encoder
decoder
Condition
INSm codes
Run End
Control signals
Generating Zin
Zin = T1 + T6 • ADD + T4 • BR + …
Figure 2.13: generation of the Zin control signal for the Processor in figure
COMPUTER ORGANISATION RAMANUJA NAYAK
Generating End
T7 T5 T4 T5
End
A Complete Processor
Instruction Data
cache cache
us System b
Main Input/
memory Output
MDRout
MAR in
WMFC
Select
PCout
R1out
R3out
Read
PCin
Micro -
End
R1in
Add
Zout
IRin
Yin
Zin
i instructi n
on
1 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0
2 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0
3 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
4 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0
5 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0
6 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1
Step Action
Figure 2.17: Control sequence for execution of t he instruction Add (R3), R1.
Clock PC
Control
store CW
The previous organization cannot handle the situation when the control unit is required to check
the status of the condition codes or external inputs to choose between alternative courses of
action.
Use conditional branch microinstruction.
Microinstructions
A straightforward way to structure microinstructions is to assign one bit position to each control
signal.
However, this is very inefficient.
The length can be reduced: most signals are not needed simultaneously, and many signals are
mutually exclusive.
All mutually exclusive signals are placed in the same group in binary coding.
Microinstruction
F1 F2 F3 F4 F5
0000: No transfer 000: No transfer 000: No transfer 0000: Add 00: No action
0001: PC out 001: PC in 001: MAR in 0001: Sub 01: Read
0010: MDR out 010: IR in 010: MDR in 10: Write
0011: Z out 011: Z in 011: TEMP in
0100: R0 out 100: R0 in 100: Y in 1111: XOR
0101: R1 out 101: R1 in
16 ALU
0110: R2 out 110: R2 in functions
0111: R3 out 111: R3 in
1010: TEMP out
1011: Offset out
F7 F8
F6
Enumerate the patterns of required signals in all possible microinstructions. Each meaningful
combination of active control signals can then be assigned a distinct code.
Vertical organization
Horizontal organization
IR
External Condition
Inputs codes
Decoding circuits
AR
Control store
Microinstruction decoder
Control signals
F0 F1 F2 F3
F4 F5 F6 F7
F8 F9 F10
Octal
address F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0 0 01 1 0 0 0 0
0 0 1 0 0 0 0 0 0 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 00 0 1 0 0 0
0 0 2 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 00 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 1 1 0
1 21 01 0 1 0 0 1 0 1 00 0 1 1 0 0 1 0 0 0 0 01 1 0 0 0 0
1 22 01 1 1 1 0 0 0 0 11 1 0 0 0 0 0 0 0 0 0 00 0 1 0 0 1
1 7 0 0 1 1 1 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 01 0 1 0 0 0
1 7 1 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 00 0 0 0 0 0
1 7 2 0 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 0 00 0 0 0 0 0
1 7 3 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 0 00 0 0 0 0 0
Cache Memory
Cache memory bridges the speed mismatch between the processor and the main memory.
When cache hit occurs,
The required word is present in the cache memory.
The required word is delivered to the CPU from the cache memory.
When cache miss occurs,
The required word is not present in the cache memory.
The page containing the required word has to be mapped from the main memory.
This mapping is performed using cache mapping techniques.
Cache Mapping-
Cache mapping defines how a block from the main memory is mapped to the cache
memory in case of a cache miss.
OR
Cache mapping is a technique by which the contents of main memory are brought into
the cache memory.
The following diagram illustrates the mapping process-
1. Direct Mapping
2. Fully Associative Mapping
3. K-way Set Associative Mapping
1. Direct Mapping-
In direct mapping,
A particular block of main memory can map only to a particular line of the cache.
The line number of cache to which a particular block can map is given by-
Example-
Consider cache memory is divided into ‘n’ number of lines.
Then, block ‘j’ of main memory can map to line number (j mod n) only of the cache.
Example-
Consider the following example of 2-way set associative mapping-
Here,
k = 2 suggests that each set contains two cache lines.
Since cache contains 6 lines, so number of sets in the cache = 6 / 2 = 3 sets.
Block ‘j’ of main memory can map to set number (j mod 3) only of the cache.
Within that set, block ‘j’ can map to any cache line that is freely available at that
moment.
If all the cache lines are occupied, then one of the existing blocks will have to be
replaced.
Need of Replacement Algorithm-
Set associative mapping is a combination of direct mapping and fully associative
mapping.
It uses fully associative mapping within each set.
Thus, set associative mapping requires a replacement algorithm.
Division of Physical Address-
In set associative mapping, the physical address is divided as-
COMPUTER ORGANISATION RAMANUJA NAYAK
Special Cases-
If k = 1, then k-way set associative mapping becomes direct mapping i.e.
If k = Total number of lines in the cache, then k-way set associative mapping becomes fully
associative mapping.
Virtual Memory
Virtual memory is the separation of logical memory from physical memory. This separation
provides large virtual memory for programmers when only small physical memory is
available.
Virtual memory is used to give programmers the illusion that they have a very large memory
even though the computer has a small main memory. It makes the task of programming easier
because the programmer no longer needs to worry about the amount of physical memory
available.
Address mapping using pages:
The table implementation of the address mapping is simplified if the information in
the address space. And the memory space is each divided into groups of fixed size.
Moreover, the physical memory is broken down into groups of equal size called
blocks, which may range from 64 to 4096 words each.
The term page refers to groups of address space of the same size.
Also, Consider a computer with an address space of 8K and a memory space of 4K.
COMPUTER ORGANISATION RAMANUJA NAYAK
If we split each into groups of 1K words we obtain eight pages and four blocks as
shown in the figure.
At any given time, up to four pages of address space may reside in main memory in
any one of the four blocks.