Computer Architecture Basics
Computer Architecture Basics
Tanya Shrivastava
UNIT – 3
Control unit use to control the signals. A Central Processing Unit is the most important
component of a computer system. A control unit is a part of the CPU which directs the
operation of the processor. A control unit controls the operations of all parts of the
computer.
It is the responsibility of the control unit to tell the computer‟s memory, arithmetic/logic
unit, and input and output devices how to respond to the instructions that have been sent to
the processor.
Control memory is use to control the memory in the control unit. Control Memory is the
storage in the micro programmed control unit to store the micro program.
Writeable Control Memory: Control Storage whose contents can be modified, allow the
change in micro program and Instruction set can be changed or modified is referred as
Writeable Control Memory.
The control memory consists of micro programs that are fixed and cannot be modified
frequently. They contain microinstructions that specify the internal control signals required to
execute register micro-operations. The machine instructions generate a chain of
microinstructions in the control memory.
CPUs and GPUs are examples of devices that use control units.
INSTRUCTION TYPES
Instruction
An instruction is something that someone tells you to do. Instruction is a command which is given by
the user to computer to perform some task.
These instructions are used to transfer the data from one place to another.
Data transfer instructions transfer the data between memory and processor registers, processor registers,
and I/O devices, and from one processor register to another.
There are eight commonly used data transfer instructions. Each instruction is represented by a
mnemonic symbol.
Load LD
Store ST
Move MOV
Exchange XCH
Input In
Output OUT
Push PUSH
Pop POP
2. Data Manipulation Instruction
Data manipulation instructions are those instructions that manipulate or change the content of the
data/registers/memory.
The data manipulation instructions are usually divided into three types:
1. Arithmetic instructions
2. Logical instructions and bit manipulation instructions
3. Shift instructions
Arithmetic instructions: The four basic operations of arithmetic instructions are addition,
subtraction, multiplication, and division. Arithmetic instructions include increment, decrement, add,
subtract, multiply, divide, add with Carry, subtract with Borrow, negate that is (2‟s) two's complement.
If there‟s a negative number, it is considered as negate (so two's complement).
Name Mnemonic
Increment INC
Decrement DEC
Add ADD
Subtract SUB
Multiply MUL
Divide DIV
Logical instructions and bit manipulation instructions: logical and bit manipulation instructions
starting with clear (that means clear the content of accumulator), complement the accumulator, AND,
OR, Exclusive-OR, Clear carry, Set carry, Complement carry, Enable interrupts, Disable interrupts, all
these are logical and bit manipulation instructions.
Name Mnemonic
Clear CLR
Complement COM
AND AND
OR OR
Exclusive-OR XOR
Enable Interrupt EI
Disable Interrupt DI
Shift instructions: Shift instructions allow the bits of a memory byte or register to be shifted one-bit
place to the right or the Left.
Name Mnemonic
Name Mnemonics
Branch BR
Jump JMP
Skip SKP
Call Call
Return RET
INSTRUCTION FORMAT
Instruction is an order given by user to computer that tells CPU what to do.
CPU fetches the instructions from main memory and one by one stored in the Instruction Register (IR)
in particular format after that executes instruction and result displayed to user.
Instruction format: Instruction format describe the layout or internal structure of instruction and how
instruction is represented in Instruction Register by CPU.
1st field: Opcode is also known as operation code. It tells the CPU which operation is to be performed in
the instruction. For example add (addition), sub (subtraction), mul (multiplication), mov etc.
2nd field: Address of operand also known as data. Data stored in main memory and its address stored in
address field of instruction.
3rd field: Mode defines way of calculating address of operand. Mode tells whatever the address of the
data is given, how CPU reach to that address. Weather it is Memory address or Register address.
ADD 2 5
Result = 7
In two address
instruction we
mainly use MOV
operation.
Instruction specifies
data itself. Basically we
use stack operation for
example PUSH and
POP.
Answer:
Expression: X = (A+B)*(C+D)
Postfixed : X = AB+CD+*
TOP means top of stack
M[X] is any memory location
PUSH A TOP = A
PUSH B TOP = B
PUSH C TOP = C
PUSH D TOP = D
LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
MUL R1, R2 R1 = R1 * R2
MOV X, R1 M[X] = R1
Q. Describe the Assembly Language Code for the expression X= (A-B) *(((C-D)/F)/G)
Answer:
Q. Discuss Instruction format and classify according to the basic computer systems. The
Instruction format has 16 bits, 12 bits are used to represent address part and one bit for mode
part then Calculate how many bits are required for opcode?
Solution:
A bus is a collection of small wires and a communication system that transfers data between the
internal components of the computer or between the computers.
A bus is a collection of wires used for the communication of different parts of a computer. Further, it uses
electric signals to pass the data and information.
TYPES OF BUSES
Data Bus: The data bus is bidirectional. The data bus is used to communicate or send the data from
one part to another.
Address Bus: The address bus is unidirectional. The address bus is used to communicate the address of
the given data and instructions.
Control Bus: The control bus is unidirectional. The control bus is used to control the signals between
different devices.
1 0 1 1 0 1 0 0
Types of Registers are:
The memory content store in the MDR is copied into the Instruction Register (IR).
It is used to store the instructions like LOAD, ADD, SUB, DIV, MUL, STORE, MOV, EXE etc.
Instruction Register (IR) is also known as Current Instruction Register (CIR).
MICRO OPERATIONS
In computer central processing units, micro-operations (also known as micro-ops) are the
functional or atomic, operations of a processor.
These are low level instructions used in some designs to implement complex machine instructions.
They generally perform operations on data stored in one or more registers.
They transfer data between registers or between external buses of the CPU, also performs
arithmetic and logical operations on registers.
Each instruction cycle is made up of a number of smaller units – Fetch, Indirect, Execute and
Interrupt cycles. Each of these cycles involves series of steps, each of which involves the
processor registers. These steps are referred as micro-operations.
Types of Micro-operations
1. Arithmetic Micro-operations
2. Logic Micro-Operations
3. Shift Micro-operations
Arithmetic Micro-operations
The basic Arithmetic Micro-operations are classified in the following categories:
1. Addition
2. Subtraction
3. Increment
4. Decrement
5. Shift
Some additional Arithmetic Micro-operations are classified as:
1. Add with carry
2. Subtract with borrow
3. Transfer/Load, etc.
Logic Micro-operations
1. Clear
2. AND
3. Exclusive OR
4. OR
5. NOR
6. NAND
Shift Micro-operations
1. Shift Left Register (shl)
2. Shift Right Register (shr)
3. Circular Shift Left Register (shlc)
4. Circular Shift Right Register (shrc)
5. Arithmetic Shift Left (ASHL)
6. Arithmetic Shift Right (ASHR)
An Instruction Cycle Consists of an instruction fetch, followed by zero or more operand fetches,
followed by zero or more operand stores, followed by an interrupt Check (if interrupts are enabled) The
major Computer System Components (processor, main memory, I/O modules) need to be
interconnected in order to Exchange data and control signals.
The most popular means on interconnection is the use of a shared System bus Consisting on multiple
lines.
Fetch Instruction: The Fetching instructions from the main memory begin the Execution Cycle. The
Current program counter will acquire the instruction placed in the instruction register (IR).
Decode Instruction: During this Cycle, the decoder interprets the encoded instruction Stored in the IR
(Instructions register).
Perform ALU operation: Two operands in the Instruction will be operated on a specified operator in
the instructions in an ALU (Arithmetic Logic Unit). for Example, if the instruction were to add two
numbers, the addition would occur here. The outcome of the process is output by the ALU, which takes
two values and Outputs one.
Access Memory: There are only two memory access instructions: LOAD and STORE. A value from
memory is copied to a register by LOAD, and a register value is copied to memory by STORE.
Update Register File: The ALU's output/result is written back to the register file in this phase to update
the register file. It‟s also possible that the result is due to a LOAD from memory. Some instructions do
not provide results that can save The BRANCH and JUMP are Example.
Update Program Counter (PC): At the Completion of the Current instructions Execution, we must
update the program Counter (PC) to the address of the next instructions so that we may return to step 1
and have the CPU acquire the next instruction. if the instruction was BRANCH or JUMP, the program
Counter might need to be set to a Different memory address that the following one.
PROGRAM CONTROL
The program control instructions control the flow of program execution.
Program control instructions modify or change the flow of a program. It is the instruction that
changes the sequence of the program's execution, which means it changes the value of the program
counter, due to which the execution of the program changes.
Jump JMP The jump instruction transfers the program sequence to the
memory address.
Test (by ANDing) TST Test instruction use to test the instructions.
RISC CISC
It focuses on software. It focuses on hardware
It uses only hardwired control unit It uses both hardwired and Microprogrammed
control unit
Code size is large Code size is small
The use of pipeline are simple in risc The use of pipeline are difficult in cisc
An instruction is executed in a single clock Instruction may take more than one clock cycle.
cycle.
The execution time of risc is very short The execution time of cisc is very long
Takes more space in memory Takes less space in memory
Less registers Use more registers
Fixed length instruction Variable length instruction
110011 1010101010110
001100 10110101010
101000 1100111000111100
Instructions are reduced Instructions are complex
Power consumption is less Power consumption is more
Load and Store independent instructions Load and Store independent instructions
(Register to Register) (Memory to Memory)
PIPELINING
Pipelining is a process of arrangement of hardware elements of the CPU such that its overall
performance is increased.
Simultaneous execution of more than one instruction takes place in a pipelined processor.
Let us see a real-life example that works on the concept of pipelined operation. Consider a water
bottle packaging plant. Let there be 3 stages that a bottle should pass through, Inserting the bottle
(I), Filling water in the bottle (F), and Sealing the bottle (S).
Let us consider these stages as stage 1, stage 2, and stage 3 respectively. Let each stage take 1
minute to complete its operation. Now, in a non-pipelined operation, a bottle is first inserted in the
plant, after 1 minute it is moved to stage 2 where water is filled. Now, in stage 1 nothing is
happening. Similarly, when the bottle moves to stage 3, both stage 1 and stage 2 are idle. But in
pipelined operation, when the bottle is in stage 2, another bottle can be loaded at stage 1.
Similarly, when the bottle is in stage 3, there can be one bottle each in stage 1 and stage 2. So,
after each minute, we get a new bottle at the end of stage 3. Hence, the average time taken to
manufacture 1 bottle is:
Hardwired Control Unit: The control hardware can be viewed as a state machine that changes from
one state to another in every clock cycle, depending on the contents of the instruction register, the
condition codes, and the external inputs. The outputs of the state machine are the control signals. The
sequence of the operation carried out by this machine is determined by the wiring of the logic
elements and hence named “hardwired”.
Fixed logic circuits that correspond directly to the Boolean expressions are used to generate the
control signals.
Hardwired control is faster than micro-programmed control.
A controller that uses this approach can operate at high speed.
RISC architecture is based on the hardwired control unit
A microprogram sequencer generates the address of the next microinstruction to be executed. The
address is used by a microprogram sequencer to decide which microinstruction has to be performed
next.
Microprogram sequencing is the name of the total procedure. The addresses needed to step through a
control store‟s microprogram are created by a sequencer, also known as a micro sequencer.
Microprogram Sequencing:
This refers to the process of determining the sequence in which microinstructions are executed to
complete a main instruction.
Sequential: Microinstructions are executed one after another in the order they are stored in the control
store. This is efficient for simple instructions.
Branching: Based on certain conditions (like the result of an operation), the microprogram can jump to
a different sequence of microinstructions within the control store. This allows for handling complex
instructions and conditional logic.
Control Address Register (CAR): Control address register receives the address from four
different paths. For receiving the addresses from four different paths, Multiplexer is used.
Multiplexer: Multiplexer is a combinational circuit which contains many data inputs and single
data output depending on control or select inputs.
Branching: Branching is achieved by specifying the branch address in one of the fields of the
micro instruction. Conditional branching is obtained by using part of the micro-instruction to
select a specific status bit in order to determine its condition.
Mapping Logic: An external address is transferred into control memory via a mapping logic
circuit.
Incrementer: Incrementer increments the content of the control address register by one, to select
the next micro-instruction in sequence.
Subroutine Register (SBR): The return address for a subroutine is stored in a special register
called Subroutine Register whose value is then used when the micro-program wishes to return
from the subroutine.
Control Memory: Control memory is a type of memory which contains addressable storage
registers. Data is temporarily stored in control memory. Control memory can be accessed quicker
than main memory.
Types of Micro-programmed Control Unit – Based on the type of Control Word stored in the
Control Memory (CM), it is classified into two types:
In the Horizontal micro-programmed control unit, the control signals are represented in the
decoded binary format, i.e., 1 bit/CS. Here ‘n’ control signals require n bit encoding. On the
other hand
In a Vertical micro-programmed control unit, the control signals are represented in the encoded
binary format. Here ‘n’ control signals require log2n bit encoding.
S.
No Horizontal µ-programmed CU Vertical µ-programmed CU
It is more flexible than a vertical micro- It is less flexible than horizontal but more flexible
5. programmed control unit. than that of a hardwired control unit.
Q. The Memory unit of a Computer has 512K words of 32 bits each. The Computer has an
Instruction format with four fields: an operation code field, a mode field to specify one of the
seven addressing modes, a register address field to specify one of the 90 processor register, and a
memory address. Analyse the instruction format and number of bits in each field if the instruction
is in one word memory.
Solution:
Q. A computer uses a memory unit of 512 K words of 32 bits each. A binary instruction code is
stored in one word of the memory. The instruction has four parts: an addressing mode field to
specify one of the two-addressing mode (direct and indirect), an operation code, a register code
part to specify one of the 256 registers and an address part. How many bits are there in
addressing mode part, opcode part, register code part and the address part?
Solution:
Q. A computer has 256 K word memory. The instruction format has 4 fields i.e., Opcode, register
field to represent one of the 60 processor registers, mode field represent one of 7 addressing
modes and memory address field. How many instructions the system supports when a 32- bit
instruction is placed in the one memory cell.
Or
Q. The memory unit of a computer has 256K words of 32 bits each. The computer has an
instruction format with four fields: an operation code field, a mode field to specify one of seven
addressing modes, a register address field to specify one of 60 processor registers, and a memory
address. Specify the instruction format and the number of bits in each field if the in instruction is
in one memory word.
Solution: