ALU, Data-Path & Control Unit
ALU, Data-Path & Control Unit
Chapter 3
Introduction:
y A computer is used for the execution of the program, which consists of
a set of instructions stored in the memory.
y The actual work of executing the instructions of the program is done by
the processor(CPU).
y To process an instruction, CPU uses three internal components named
as:
1) Registers
2) ALU (arithmetic and logic unit)
3) Control unit (CU)
Registers
Status Flags
Internal CPU Bus
Shifter
Complementer
Control
paths
1) Register:
y A register is a storage component present inside the CPU which is
used to accept, store and transfer the data and instructions used by
ALU, Data-path & Control Unit
the CPU.
y Registers are very fast computer memory units because they are
made up of a group of flip flops and gates.
y Flip Flops are used to store the binary information, and gates control
the transfer of information in and out of registers.
2) ALU (arithmetic and logic unit):
y The arithmetic and logical operations on data items inside the
computer are performed by ALU.
91
Chapter 3
y All the other components like control unit, registers, memory, and
I/O bring the data for processing into the ALU and then take the
result back out.
y Data to be processed is forwarded to registers and ALU, and the
result of ALU operation is stored in specified registers.
y Based on the computation result, the ALU can also set flags.
For example, if the result of an ALU operation which is to be stored in
a register exceeds the length of that register, then overflow is set to 1.
y The control unit sends the signals that control the operation of the ALU
and also controls the movement of the data into and out of the ALU.
Instruction Decoder
Control signals
within CPU
Unit
Clock
Control signals to
control bus
92
Chapter 3
Control unit functions:
y In order to exchange data between memory and I/O modules, control
signals are being issued by the control unit external to the processor.
y Control signals internal to the processor are being issued by the control
unit for ALU to perform the specified operation, move the data between
the registers and to regulate other internal operations.
y Control unit handles tasks such as fetching, decoding, executing and
storage of results of the micro-operations.
y It regulates that the data inside the processor will be executed in what
sequence and will be stored in which register, i.e. it directs the data
flow sequence inside the processor as well as outside the processor.
y The two basic tasks performed by the control unit are:
1) Sequencing: The control unit makes the processor move through a
series of micro-operations in the proper sequence based on which
the program is being executed.
2) Execution: The control unit is also responsible for each micro-
operation to be performed.
Micro-operations:
y Execution of a program comprises sequential execution of instructions.
y Execution of each instruction is done during an instruction cycle which is
made up of shorter sub cycles (e.g. fetch cycle, execute cycle, interrupt
cycle).
y Execution of each sub cycle consists of one or more shorter operations,
called micro-operations.
y Micro-operations are the functional or atomic operations of a processor
that finishes its execution in 1 clock cycle.
93
Chapter 3
Program Execution
Indirect/ Interrupt
Fetch Execute
Direct
µ OP µ OP µ OP µ OP
Note:
Register to Register transfer operation is a µ-operation from the user's
point of view.
Mov r3, r4
Register : r3 r4
transfer language
r3 in
H/W Design : T3
ALU, Data-path & Control Unit
r4 out
T4
µ-operation list : T 1 : r4 o ut , r3 i n
Control signals
94
Chapter 3
Micro-instruction:
Note: Definitions
Micro-instruction designed with one micro-
Micro-instruction is a collection
operation or more than 1 µ-operation, will
of micro-operations.
always takes 1 cycle to complete.
Micro-program:
y Sequence of µ-instructions which are used to execute a task in the
hardware is known as µ-program.
Example: In order to execute an instruction, the instruction must be
brought to the processor from the memory. To complete this task following
micro-program is used:
t1: MAR ← (PC)
t2: MBR ← Memory
PC ← (PC) + step size
t3: IR ← (MBR)
The above micro-program consists of four micro-instructions, which takes
three clock cycles.
95
Chapter 3
bus, and the fetched instruction appears on the data bus, which is then
copied to memory buffer register (MBR)
Thus, the fetch cycle has four micro operations, which can be completed
in three clock cycles where each micro operation involves movement of
data in and out of registers.
Hardware design:
PCout PC
MARin
MARout MAR
Address Control
bus bus
ALU, Data-path & Control Unit
Memory
Memory
Data bus
MBRin MBR
MBRout
IR in IR
Fig. 3.8 Hardware Design of IF Cycle
96
Chapter 3
IF µ-program:
t1: MAR ← (PC)
t2: MBR ← Memory
PC ← (PC) + I
t3: IR ← (MBR)
Where I is the instruction length and t1, t2, and t3 are the time units.
First time unit (t1): MARin, PCout
Second time unit (t2): MARout, Memory, MBRin
PCout, Increment, PCin
Third time unit (t3): MBRout, IRin
Instruction:
Opcode Address
IR(Instruction Effective
Register) Address
y Then, this address is used to fetch the operand from the memory that
is stored in the corresponding address.
y The operand which is fetched from memory is kept on the data bus and
is then placed in the memory buffer register (MBR).
y The memory buffer register (MBR) places the operand in the accumulator
register for further processing.
97
Chapter 3
Hardware design:
IRout IR[Address]
MARin
MARout MAR
Address Control
bus bus
Memory
Memory
Data bus
MBRin MBR
MBRout
IRin IR
Fig. 3.9 Hardware Design of Direct Operand Fetch Cycle
opcode Address
ALU, Data-path & Control Unit
98
Chapter 3
the effective address(EA), so now, instead of an indirect address, the
address field contains a direct address.
y Then again, the address field of IR is transferred to MAR, and this
address is used to fetch the operand from the corresponding memory
location.
y The fetched operand appears on the data bus and is then placed in
MBR.
y Then, from the memory buffer register (MBR), the operand is placed in
accumulator register(AC) for further processing / execution.
Hardware design:
IRout IR [Address]
MARin
MARout MAR
Address Control
lines lines
Memory Memory
Data lines
MBRin
MBRout MBR {Effective Address}
MARin
MARout MAR
Address Control
lines lines
Memory Memory
Data lines
MBRin
MBRout MBR {operand}
ACCin
Accumulator
ALU, Data-path & Control Unit
99
Chapter 3
Hardware design:
IRout IR[Address]
MARin
MARout MAR RD
Address Control
bus bus
Memory
Memory
Data bus
ALU, Data-path & Control Unit
MBRin MBR
MBRout
ACin AC R1
ALU
Fig. 3.11 Hardware Design of Execute Cycle
100
Chapter 3
Micro-program:
t1: MAR ← (IR Address)
t2: MBR ← Memory
t3: Accumulator ← MBR
t4: R1 ← (R1) * (AC)
MBRin MARin
MBR MAR WR
MBRout MARout
Memory
Fig. 3.12 Hardware Design of Write Back ALU, Data-path & Control Unit
Micro program:
t1: MBR ← Accumulator
t2: MAR ← IR [Address]
t3: Memory ← MBR
101
Chapter 3
Instruction Cycle
Instruction
Cycle
No
INT
Yes Interrupt
Cycle
Service the Interrupt
Hardware design:
PCout PC SPout SP
{return address} {TOS address}
MBRin MARin
MBR MAR WR Routine
MBRout MARout addressout Routine address
Memory
Fig. 3.14 Hardware Design of Interrupt Cycle
Micro-program:
t1: MBR ← (PC)
t2: MAR ← Save-address
PC ← Routine address
t3: Memory ← (MBR)
102
Chapter 3
PRACTICE QUESTIONS
Sol: Fetch: 1 memory reference will be required for fetching the instruction.
Decode: Since the instruction is 1 word long, no memory reference is
required during decode.
Operand fetch: Since operand fetch, indirect addressing mode is used, so
two memory references will be required.
1 MR for getting the effective address, i.e. address of the operand.
1 MR for getting the operand.
Execute: No memory reference for execute cycle because given instruction is
MOV instruction only.
Write Back: One memory reference to write the operand at memory location
[2000]
Total memory references = 1 + 2 + 1 = 4
Q2 For the operand fetch using indirect addressing mode, how many number of
cycles are required to bring the operand to the CPU?
Sol: Ans. 4
The microprogram for operand fetch using indirect addressing mode is as
follows:
t1: MAR ← IR [Address]
t2: MBR ← Memory
ALU, Data-path & Control Unit
Thus, in these two cycles effective address, i.e., the address of the operand,
is brought to the CPU.
t3: MAR ← MBR
t4: MBR ← Memory
These two cycles are required to bring the operand from memory to the CPU.
So, total of 4 cycles is required.
103
Chapter 3
Q3 The fetch cycle consists of four micro-operations, and these four micro-op-
erations can be completed in three units of time__________.
Which among the four micro-operations can be completed in a single time
unit in the fetch cycle?
I) MAR ← (PC)
II) MBR ← Memory
III) IR ← (MBR)
IV) PC ← (PC) + Instruction size (I)
a) I and II can be completed in a single time unit.
b) II and IV can be completed in a single time unit.
c) III and IV can be completed in a single time unit.
d) I and IV can be completed in a single time unit.
Bus architecture:
y Two or more devices in a computer are connected through a common
ALU, Data-path & Control Unit
104
Chapter 3
Previous Years’ Question
System bus:
y The major units of a system, like memory, CPU and I/O are connected
by a system bus.
y Typically, the system bus contains the following lines:
a) Data lines: Data is transferred between various system modules
through data lines.
Data lines altogether are known as the data bus.
b) Address lines: The address of the data which is present on the data
bus is contained by address lines.
Address lines altogether are known as address bus.
c) Control lines: The control lines are bearers of control signals that
effectively establish the communication of control commands and
timing signals among different system components.
y The validity of address and data information is specified by timing
signals.
y Control signals describe the operation to be performed like memory
ALU, Data-path & Control Unit
Note:
1) The word length of the CPU can be described based on the width of
the data bus.
2) The memory capacity of the system can be described based on the
width of the address bus and data bus.
105
Chapter 3
Bus architecture:
Bus Architecture
System Bus
y Both the instructions and data are transferred through this single bus.
Advantages:
y The single bus architecture is not an expensive design.
y Less number of registers are associated.
y Flexible for attaching new peripheral devices.
Disadvantages:
y Only single transmission can be done by the bus at a given point in
time, i.e. only two units can actively use the bus at any given time.
y Less concurrency in operations.
y Requires a greater number of cycles for execution, thus making execution
ALU, Data-path & Control Unit
of process slow.
106
Chapter 3
y Also, when the aggregate data transfer demand becomes so large that it
reaches the capacity of the bus and thus bus may become a bottleneck.
y The above problems may not always be overcome by single bus architecture.
y This problem can be solved by using multiple buses, generally laid out
in a hierarchy.
y Multiple buses allow the devices to work simultaneously, thus improving
the CPU’s speed.
107
Chapter 3
y Buses P and Q are used to transmit the source operands to the P and Q
inputs of ALU, where an arithmetic or logic operation can be performed.
y The result is transmitted to the destination over bus S.
y Whenever required, the ALU can forward one of its two input operands,
not modified, to bus S.
Advantages:
y The number of cycles required for the execution of the process is less.
y More concurrency in operations.
Disadvantage:
y Multibus architecture is an expensive design.
Control signals:
y Every micro-operation is performed by activating some control signals.
y Control signals are put in directly as binary inputs to the independent
logic gates.
y Control signals can be used to activate an ALU function, a data path or
other external interfaces.
y The CPU consists of some general purpose and some special purpose
registers.
y All the registers are connected to a common data path known as BUS.
y For transferring the information from one register to another, each
register has two control signals Rin and Rout.
y When the content of the bus is loaded into the register R, then Rin must
be set to 1.
y When the content from the register R is loaded into the bus, then Rout
must be set to 1.
PC ← (PC) + 1
For this micro-operation control unit activates the following control signals:
1) A control signal that unlocks the gates and permits the contents present
in MAR onto the address bus.
2) A control signal to read the memory location and transfer the data onto
the data bus.
108
Chapter 3
3) A control signal that unlocks the gates and permits the contents on the
data bus to be transferred onto the MBR.
4) A control signal that increments the PC value by the instruction length
and stores it on PC.
t3: IR ← (MBR)
A control signal that allows the contents of MBR to be transferred to IR.
PCout
I1 IF PC→MAR
I2 ID Mem→MDR MARin
.
OF PC+1→PC
.
PD MDR→IR
.
In WB
109
Chapter 3
Disadvantage:
y It is not flexible because even very small changes in the Boolean
expression requires redesign and reconnection of a logic circuit.
y The blocks of decoder and encoder are combinational circuits that are
used to produce the desired control outputs.
y In control sequence, a different signal line for every step is provided by
the step decoder.
y While loading any instruction in IR (Instruction Register), one of the
output lines INS1 through INSk are set to 1, and all other lines are set to 0.
ALU, Data-path & Control Unit
y The input signals to the encoder block are combined to generate the
individual control signals Yin, PCout, Add, End etc.
eg. Zin = T1 + T6 ⋅ ADD + T4 ⋅ BR + .......
y The signal is asserted during time slot T1 for all instructions, during T6
for an ADD instruction during T4 for an unconditional branch instruction
and so on.
110
Chapter 3
Branch ADD
T4 T6
T1
Zin
Note:
PRACTICE QUESTIONS
Q4 Consider a system in which we have 4 control signals S0, S1, S2, S3 and 3 dif-
ferent instruction I1, I2, I3 and 4 µ-operations T1, T2, T3, T4. Following are the
control signals which are required for a particular instruction at different
µ-operation timings:
µ-operation/Instruction I1 I2 I3
T2 S0, S2 S3 S1, S3
111
Chapter 3
I1 I1 I1 I1
I4 I2 I2 I2
I3 I3 I3
I4 I4 I4
I5 I5
112
Chapter 3
Previous Years’ Question
A hardwired CPU uses 10 control signals S1 to S10, in various time steps T1 to T5, to
implement 4 instructions I1 to I4 as shown below: (GATE CS 2005)
T1 T2 T3 T4 T5
Which of the following pairs of expressions represent the circuit for generating control
signals S5 and S10, respectively?
((Ij + Ik)Tn indicates that the control signal should be generated in time step Tn if the
instruction being executed is Ij or Ik).
a) S5 = T1 + I2 ⋅ T3 and
S10 = (I1 + I3 ) ⋅ T4 + (I2 + I4 ) ⋅ T5
b) S5 = T1 + (I2 + I4 ) ⋅ T3 and
S10 = (I1 + I3 ) ⋅ T4 + (I2 + I4 ) ⋅ T5
c) S5 = T1 + (I2 + I4 )T3 and
S10 = (I2 + I3 + I4 ) ⋅ T2 + (I1 + I3 ) ⋅ T4 + (I2 + I4 ) ⋅ T5
d) S5 = T1 + (I2 + I4 ) ⋅ T3 and
S10 = (I2 + I3 ) ⋅ T2 + I4 ⋅ T3 + (I1 + I3 ) ⋅ T4 + (I2 + I4 ) ⋅ T5
Sol: d)
ALU, Data-path & Control Unit
113
Chapter 3
register(CDR).
y The sequencing unit loads the control address register and issues a
read command.
y Following are the functions of the control unit:
1) The READ command to the control memory is being issued by the
sequencing logic in order to execute an instruction.
2) The word whose address is given in the control register is read into
the control buffer register.
114
Chapter 3
3) Control signals and next address information are generated by the
content of the control buffer register.
4) Based on the next address information present inside the CDR and
ALU flags, a new address is being loaded by the sequencing the logic
unit in the CAR.
y The upper decoder converts the opcode of IR into the control memory
address.
y The lower decoder is not used for horizontal micro instructions, but for
vertical micro-instructions.
y Control Memory is associated with CAR (Control Memory address register)
and CDR (Control Memory data register) registers which are used to hold
the control memory address and control memory content, respectively.
Hardware design:
PC {Instruction Address}
Memory
MBR
IR {opcode}
Decoder
µ Sequence {µ-Instruction
unit address}
CAR
µ Programmed
CU
ROM {Control Memory}
CDR {µ-Instruction}
ALU, Data-path & Control Unit
Base H/w
Advantages:
y The use of micro-programming for implementing the control unit
simplifies the design of control unit.
115
Chapter 3
Note:
The Micro–programmed control unit is used for designing CISC architectures.
Instruction format:
The µ-Instruction in control memory is stored in the following format:
Control Word
log2 log2
(no. of Branch (no. of flags) log2 (Cache size)
Conditions)
Decoded Encoded
Binary Format Binary Format
Horizontal Vertical
Note:
Fields (branch condition, flag, control memory address) are used for
ALU, Data-path & Control Unit
jumping conditions.
Example: JNZ4004
In this we require three things
1) Condition: Jump if non zero
2) Flag: Zero flag
3) Address: 4004
116
Chapter 3
Micro-instruction sequencing:
The micro-programmed control unit carries out the two important
operations listed below as:
1) Microinstruction sequencing: It fetches the subsequent micro-
instruction from the control memory.
2) Microinstruction execution: It is the procedure of generating the control
signals to carry out the execution of the pre-fetched micro-instruction.
NZ zero flag
NZ zero flag
Hardware
=
True False
µ-sequencer unit No change in the
is loaded with target address µ-sequencer unit
4000
Base
µ-sequencer unit CAR ROM CDR
ALU, Data-path & Control Unit
H/w
µ-Programmed CU
117
Chapter 3
PRACTICE QUESTIONS
Sol: a), c)
Highest: hardwired control
lowest: vertical micro-programming.
y In hardwired, the control logic is implemented using gates and flipflops.
So, it is the fastest.
y In horizontal microprogramming, for each control signal, a separate bit
is used.
y In vertical microprogramming, control signals are expressed in the form
of encoded binary format.
Thus, a decoder is used.
So, for ‘n’ control signals, log2n bits are used, so it has the slowest
operational speed.
8 X
16 flags
log2 (16) = 4 bits
118
Chapter 3
Number of bits for next address field (X)
= 22 – (8 + 4)
= 10 bits
Size of control Memory = 210 * 22 bits = (210) * 22/8 = 2816 bytes.
Control field
n-bits
Sn ... S2 S1 S0
Control field
log2n bits
Decoder
Sn ... S2 S1 S0
y This micro-programmed control unit is slow since any one control signal
can be enabled altogether.
119
Chapter 3
µ-instruction design:
S3S2SS
1 0
- - 1011 -
⇒
ROM
Fig. 3.27 Microinstruction Design Example
Execution:
y Fetch T from the control memory (ROM)
- - 1011 -
S3S2S1S0
Hardware
y µ-Instruction format:
- - 00 01 11 -
⇒
ROM
120
Chapter 3
Execution:
- - 00 01 11 -
Select MUX
logic
11, 01, 00
Decoder
S3 S2 S1 S0
Note:
more than one signal can be unit none or only one signal
enabled at any instance of can be enabled at any instance
time. of time.
121
Chapter 3
PRACTICE QUESTIONS
Q8 Consider a hypothetical control unit, which has a total of 233 control signals.
How many bits are required in control memory word for horizontal mi-
cro-programming and vertical microprogramming, respectively?
a) 233, 233 b) 233, 1 c) 8, 8 d) 233, 8
Sol: Ans. d)
Horizontal micro-programming:
In horizontal micro-programming, for each control signal one bit is used.
233 bits
Vertical micro-programming:
In vertical micro-programming, for n control signals, log2n control bits are
ALU, Data-path & Control Unit
Control signals 2 10 4 1 18 23 6
How many more control bits are required using horizontal micro-program-
ming over vertical micro-programming?
Sol: Ans. 43
For vertical micro programming:
Micro-Instruction format:
2 10 4 1 18 23 6
Consider a CPU where all the instructions require 7 clock cycles to complete execution.
There are 140 instructions in the instruction set. It is found that 125 control signals
are needed to be generated by the control unit. While designing the horizontal micro-
programmed control unit, a single address field format is used for branch control logic.
What is the minimum size of the control word and control address register?
a) 125, 7 b) 125, 10 c) 135, 9 d) 135, 10
Sol: d) (GATE CS 2008 (IT))
123
Chapter 3
Q10 Consider a hypothetical control unit, which supports 512 bytes of the con-
trol word memory. If the control word is 20 bits long and hardware contains
4 flags and supports 16 branch conditions. What is the maximum number of
control signals that can be generated at a time using horizontal micro-pro-
gramming and vertical micro-programming, respectively?
a) 1, 1 b) 32, 32 c) 32, 1 d) 1, 32
Sol: Ans. c)
µ-instruction design:
20 bits
Branch Control Memory
Flag Control field
Condition Address
124
Chapter 3
Chapter summary
125