UNIT3 Merged Watermarked
UNIT3 Merged Watermarked
An instruction cycle is the complete process of fetching, decoding and executing the
instruction.
Name Mnemonics
Branch BR
Jump JMP
Skip SKP
Call Call
Return RET
The compare instruction performs an arithmetic subtraction. Here, the result of the
operation is not saved; instead, the status bit conditions are set. The test instruction
performs the logical AND operation on two operands and updates the status bits.
MICRO-OPERATIONS & CONTROL SIGNALS
As we can see in the above table, two Micro-Operations can take place in the same T-state i.e.
Please Note
Now that we know how an instruction is fetched, we can proceed further and learn Micro-Operations for
various instructions, of different Addressing Modes.
MICRO-OPERATIONS FOR IMMEDIATE ADDRESSING MODE
E.g.: MOV R1, 25H; R1 register gets the immediate value 25H
E.g.: MOV R1, R2; R1 register gets the data from Register R2
E.g.: MOV R1, [2000H]; R1 register gets the data from memory location 2000H
E.g.: MOV R1, [R2]; R1 register gets the data from memory location pointed by R2
E.g.: MOV [R2], R1; R1 register stores data into memory location pointed by R2
3. RISC allows the instruction to use free space on a microprocessor because of its simplicity.
4. RISC processor is simpler than a CISC processor because of its simple and quick design, and it can
complete its work in one clock cycle.
3. RISC processors require very fast memory to save various instructions that require a large collection
of cache memory to respond to the instruction in a short time.
It is a highly customized set of instructions used in portable devices due to system reliability such as
Apple iPod, mobiles/smartphones.
CISC
CICS stands for Complex Instruction Set Computer. CISC is the kind of chip that can be easily programmed
and makes the best and efficient use of memory. The main motive of CISC is to make compiler development
easy and simple. There is no need for the machine to generate instructions for the processor as CISC
eliminates the need.
2. The number of instructions is less as compared The number of instructions is more as compared
to CISC. to RISC.
3. The addressing modes are less. The addressing modes are more.
5. The RISC consumes low power. The CISC consumes high power.
6. The RISC processors are highly pipelined. The CISC processors are less pipelined.
An instruction requires several steps which mainly involve fetching, decoding and execution.
If these steps are performed one after the other, they will take a long time.
As processors became faster, several of these steps started to get overlapped, resulting in faster
processing. This is done by a mechanism called pipelining.
Time
F1 E1 F2 E2 F3 E3 F4 E4 F5 E5
Time
F1 E1 E2 E3 E4 E5
F2 F3 F4 F5
Overlapping fetching
and execution
Here the instruction process in divided into three stages of fetching, decoding and execution and are
overlapped. Hence three instructions are being processed at any point of time.
4 STAGE PIPELINING
ADVANTAGE OF PIPELINING
The obvious advantage of pipelining is that it increases the performance. As shown by the various
examples above, deeper the pipelining, more is the level of parallelism, and hence the processor becomes
much faster.
DRAWBACKS/ HAZARDS OF PIPELINING
There are various hazards of pipelining, which cause a dip in the performance of the processor. These
hazards become even more prominent as the number of pipeline stages increase. They may occur
due to the following reasons.
Data Hazard is caused when the result (destination) of one instruction becomes the operand
(source) of the next instruction.
Pipelining assumes that the program will always flow in a sequential manner.
Hence, it performs various stages of the forthcoming instructions before-hand, while the current
instruction is still being executed.
While programs are sequential most of the times, it is not true always.
Sometimes, branches do occur in programs.
In such an event, all the forthcoming instructions that have been fetched/ decoded etc have to be
flushed/ discarded, and the process has to start all over again, from the branch address. This causes
pipeline bubbles, which simply means time of the processor is wasted.
Start:
JMP Down
INC BL
MOV CL, DL
ADD AL, BL
…
…
…
Down: DEC CH
JMP Down is a branch instruction.
After this instruction, program should jump to the location “Down” and continue with DEC CH
instruction.
But, in a multistage pipeline processor, the sequentially next instructions after JMP Down have
already been fetched and decoded. These instructions will now have to be discarded and fetching will
begin all over again from DEC CH. This will keep several units of the architecture idle for some time.
This is called a pipeline bubble.
The problem of branching is solved in higher processors by a method called “Branch Prediction
Algorithm”. It was introduced by Pentium processor. It relies on the previous history of the
instruction as most programs are repetitive in nature. It then makes a prediction whether branch
will be taken or not and hence puts the correct instructions in the pipelines.
3) STRUCTURAL HAZARD
Structural hazards are caused by physical constraints in the architecture like the buses. Even
in the most basic form of pipelining, we want to execute one instruction and fetch the next one. Now
as long as execution only involves registers, pipelining is possible. But if execution requires to
read/ write data from the memory, then it will make use of the buses, which means
fetching cannot take place at the same time. So the fetching unit will have to wait and hence a
pipeline bubble is caused. This problem is solved in complex Harvard architecture processors, which
use separate memories and separate buses for programs and data. This means fetching and
execution can actually happen at the same time without any interference with each other.
E.g.: PIC 18 Microcontroller.
HARDWIRED CONTROL UNIT
INSTRUCTIONS
T-STATES
I1 I2 … IN
T1 Z1,1 Z1,2 … Z1,N
T2 Z2,1 Z2,2 … Z2,N
… … … … …
TM ZM,1 ZM,2 … ZM,N
ADVANTAGE:
It is the simplest method and is ideally suited for very small instruction sets.
DRAWBACK:
As the number of instructions increase, the circuit becomes bigger and hence more complicated.
As a tabular approach is used, instead of a logical approach (flowchart), there are duplications of many
circuit elements in various instructions.
DELAY ELEMENT METHOD
1) Here the behavior of the control unit is represented in the form of a flowchart.
2) Each step in the flowchart represents a control signal to be produced.
3) Once all steps of a particular instruction, are performed, the complete instruction gets executed.
4) Control signals perform Micro-Operations, which require one T-states each.
5) Hence between every two steps of the flowchart, there must be a delay element.
6) The delay must be exactly of one T-state. This delay is achieved by D Flip-Flops.
7) These D Flip-Flops are inserted between every two consecutive control signals.
8) Of all D Flip-Flops only one will be active at a time. So the method is also called “One Hot Method”.
9) In a multiple entry point, to combine two or more paths, we use an OR gate.
ADVANTAGE:
As the method has a logical approach, it can reduce the circuit complexity.
This is done by re-utilizing common elements between various instructions.
DRAWBACK:
As the no of instructions increase, the number of D Flip-Flops increase, so the cost increases.
Moreover, only one of those D Flip-Flops are actually active at a time.
SEQUENCE COUNTER METHOD
ADVANTAGE:
Avoids the use of too many D Flip-Flops.
1) HORIZONTAL MICRO-INSTRUCTION
Here every bit of the micro-instruction corresponds to a control signal.
Whichever bit is “1”, that particular control signal will be produced by the micro-instruction.
2) VERTICAL MICRO-INSTRUCTION
Here bits of the micro-instruction have to be decoded.
The decoded output decides the control signal to be produced.
HORIZONTAL MICRO-INSTRUCTION VERTICAL MICRO-INSTRUCTION
N bits in the micro-instruction will totally N bits in the micro-instruction will totally
3
produce N control signals. produce 2N control signals.
Multiple control signals can be produced Only one control signal can be produced by
4
by one micro-instruction. one micro-instruction.
As the control signals increase, the micro- To produce more control signals, more
5 instruction grows wider. Hence the Control number of micro-instructions are needed.
Memory grows Horizontally. Hence the Control Memory grows Vertically.
As seen from the above comparison, both methods have their pros and cons.
So a combination of both is used together called Nano-Programming.
NANO-PROGRAMMING (Very Important)
1) Horizontal µ-instructions can produce multiple control signals simultaneously, but are very wide.
2) This makes the Control Memory very large in size.
3) Vertical micro-instructions are narrow, but on decoding can produce only one control signal.
4) This makes the Control Memory small but the execution is slow.
5) Hence a combination of both techniques is needed called Nano-Programming.
6) Here we have a two level control memory.
7) The instruction is fetched from the main memory into IR.
8) Using its opcode we load address of its first micro-instruction into µPC,
9) Using this address we fetch the micro-instruction from µ-Control Memory (µCM) into µIR.
10) This is in vertical form and has to be decoded.
11) The decoded output loads a new address in a Nano program counter (nPC).
12) Using this address we fetch the Nano-instruction from Nano-Control Memory (nCM) into nIR.
13) This is in horizontal form and can directly generate control signals.
14) Such a combination gives advantage of both techniques.
15) The size of the Control Memory is small as µ-instructions are Vertical.
16) Multiple control signals can be produced simultaneously as Nano-instructions are Horizontal.
HARDWIRED CONTROL UNIT MICROPROGRAMMED CONTROL UNIT
Control signals are generated using Control signals are generated using
1
hardware. software (Microprogram).
Since hardware is used, the circuit is Since software is used, the circuit is
2
rigid. flexible.
Modification to the Control Unit requires Modification to the Control Unit simply
3
re-design of the entire hardware. requires re-programming of µ-instructions.
Ideally suited for processors with small Ideally suited for processors with large and
4
and simple instruction sets. complex instruction sets.
Cost is lower as Control Memory is not Cost is higher as Control Memory is needed
9
needed. inside the processor.
As seen from the above comparison, both methods have their pros and cons.
Hence modern processors use a combination of both.
Simple and regularly used instructions are decoded by a Hardwired Control Unit as they are faster.
Complex instructions are decoded by a Microprogrammed Control Unit as they are easier to design..
TYPICAL MICROPROGRAMMED CONTROL UNIT (Super Important!)
ADVANTAGES
DRAWBACKS
1) Control memory has to be present inside the processor, increasing its size.
2) This also increases the cost of the processor.
APPLICATIONS OF MICROPROGRAMMED CONTROL UNIT / MICROPROGRAMMING
Microprogramming has various advantages like flexibility, simplicity, cost effectiveness etc.
As a result, it plays a major role in the following applications.
3) EMULATION
Emulation is when one processor (A) is made to emulate or behave like another processor (B).
To do this, “A” must be able to execute the instructions of “B”.
If we re-program the Control Memory of “A”, same as that of “B”, then “A” will be able to emulate the
behavior of “B”, for every instruction. This is possible only in Microprogrammed Control Units.
Used generally when a main processor has to emulate the behavior of a math co-processor.
6) MICRO-DIAGNOSTICS
As Microprogrammed Control Units are software based, debugging an error is far more easy as
compared to doing the same for a complex hardwired control unit. This allows monitoring,
detection, isolation and repairs of any kind of system errors in the Control Unit.
At times, it can also act as a runtime substitute, if the corresponding hardwired component fails.
AB+ CD +* (EfL)
AB+CD+* Ef|
Zuo Adol w
Push A Tos A
Push ToseB
ADD Tos A+ B
Push C Tos C
Push D Tos D
ADD Tos c+D)
MUL
+B)* c+D)
P'oush & Tos E
rush F Tos F
DIV Tos (EIF)
MUL
Tos
(A+B)+(C+ D) *
(E }F )
PopaX
C fiust Adelauas
S
Load A AC MLAJ
Add B AC - AC+B
$to MLP P Ac
Load e AC MLC
t o Add D AC Ac+D
Mul MtP1 Ac AC PP
to MLP1| PAc
load
MCE
AC - ACF
Div
Mul MP1 ACC A C * P
Second Acdoluss
MOV R1, A R A
ADD R1 ,B RL -R1+B
MDV R2, C R 2 e C
R2 R 2t B
ADD R2,B
MUL Ri R 2 RL Ri* R2
R3 E
E
Mov R 3,
DTY R3, F R3 3 h
MUL R , R3 R R 1 R3
MoV X , RI
R
The Acdolbss
App R , A,B
R CtD
P DD R2, C D
R R2
MUL R1, Ri, R2
DTV R3, E,F e Ri R s
MUL Ri, R 3
, ,
n
Tnstucs
5 12
Mods
febch Ad
6 Bits
Exeu Ras
Rad
Tngtuutir qu
Sequna Countu
Se
1.
Fetehing
PC
PC+ i, \IR<-M
-
CAR
AR Lo 1i1,
li2-141 TI Deco de
nclict LDiutt
Ex ceeutu
$it adeb 12
7 y 16
si nstuchin 2
x
6
O11
MAm 4
12 1
Data
4o96
151 12 1) O
Ragiste
2 1
ooand bpexamd
Enst
Fetth fetch Stone
Mulbipla
Mulbiple
/Snstuu hin
Tns tuucien Obrand Data opond
opan ddebuss aoleluy
addbuss opaeni
cakudatind Decodin Cokeulaue Calulahed
Tnstuuen tomhte feteh Rutwn
r t ing tuulien Vectau data_
2 s6 K
tauol in
haspant
One
am
waHod
indiuec
6 adduu
adduuin
moo bu
Cool at to
a n opualien Cod g áteuy
64 giste
an
a
od an
ado
u he
Paut (alaulat
How many bets Q input
mermas
wo umat and indical
Deaw the instuucuen
obits in tath pat
tnole
H o many bis asu
024
3 22
Pol 256 K x
2 32 6it
2s6x l66 e4 X 3 2
2 2 x32
2 x32 2's
Size adobuess 8
8Bits
Sin o instuten /data =
32 Pit
32
oy coele 64
-(1+13 +6 5
1
A mon -pipline 7ste
teke So ns
lo n
Lgmend ppelire. o th chock ye
uatoigo piplim 5
Detest
temie perlup
s maxirum 4R20
instuthen . koet
1o0 teuk (
e achi'tval
u that Com
tp Ons
Sak n = S On 6
= o0
topx So
( 160
4T6
Smax = 50