CA Unit-1
CA Unit-1
CA Unit-1
1
A Von Neumann-based computer:
Uses a single processor
Uses one memory for both instructions and data.
Executes programs following the fetch-decode-execute cycle
Components of Von-Neumann Model: Central Processing Unit, Buses and Memory Unit.
1. Central Processing Unit:
The part of the Computer that performs the bulk of data processing operations is called
the Central Processing Unit and is referred to as the CPU.
The Central Processing Unit can also be defined as an electric circuit responsible for
executing the instructions of a computer program.
The CPU performs a variety of functions dictated by the type of instructions that are
incorporated in the computer.
The major components of CPU are: ALU, Control Unit and registers.
(i) Arithmetic and Logic Unit (ALU): It performs the required micro-operations for
executing the instructions. In simple words, ALU allows arithmetic (add, subtract, etc.)
and logic (AND, OR, NOT, etc.) operations to be carried out.
(ii) Control Unit: It controls the operations of components like ALU, memory and
input/output devices. It consists of a program counter that contains the address of the
instructions to be fetched and an instruction register into which instructions are fetched
from memory for execution.
(iii) Registers: Registers refer to high-speed storage areas in the CPU. The data processed
by the CPU are fetched from the registers.
Following is the list of registers that plays a crucial role in data processing:
Registers Description
MAR (Memory This register holds the memory location of the data that needs
Address Register) to be accessed.
MDR (Memory This register holds the data that is being transferred to or from
Data Register) memory.
AC (Accumulator) This register holds the intermediate arithmetic and logic results.
PC (Program This register contains the address of the next instruction to be
Counter) executed.
CIR (Current This register contains the current instruction during processing.
Instruction Register)
2
2. Buses:
Buses are the means by which information is shared between the registers in a multiple-
register configuration system.
A bus structure consists of a set of common lines, one for each bit of a register, through
which binary information is transferred one at a time.
Control signals determine which register is selected by the bus during each particular
register transfer.
Von-Neumann Architecture comprised of three major bus systems for data transfer.
Bus Description
Address Bus Address Bus carries the address of data (but not the data) between the
processor and the memory.
Data Bus Data Bus carries data between the processor, the memory unit and the
input/output devices.
Control Bus Control Bus carries signals/commands from the CPU.
3. Memory Unit:
A memory unit is a collection of storage cells together with associated circuits needed
to transfer information in and out of the storage.
The memory stores binary information in groups of bits called words.
The internal structure of a memory unit is specified by the number of words it contains
and the number of bits in each word.
Two major types of memories are used in computer systems: RAM (Random Access
Memory) and ROM (Read-Only Memory)
General Purpose System:
The General Purpose Computer System is the modified version of the Von-Neumann
Architecture. In simple words, we can say that a general purpose computer system is a
modern day architectural representation of Computer System.
The CPU (Central Processing Unit) consists of the ALU (Arithmetic and Logic Unit),
Control Unit and various processor registers.
The CPU, Memory Unit and I/O subsystems are interconnected by the system bus which
includes data, address, and control-status lines.
The following image shows how CPU, Memory Unit and I/O subsystems are connected
through common single bus architecture.
3
Parallel Processing:
Parallel processing can be described as a class of techniques which enables the system
to achieve simultaneous data-processing tasks to increase the computational speed of a
computer system.
A parallel processing system can carry out simultaneous data-processing to achieve
faster execution time. For example, while an instruction is being processed in the ALU
component of the CPU, the next instruction can be read from memory.
The primary purpose of parallel processing is to enhance the computer processing
capability and increase its quantity, i.e. the amount of processing that can be
accomplished during a given interval of time.
A parallel processing system can be achieved by having a multiplicity of functional units
that perform identical or different operations simultaneously. The data can be distributed
among various multiple functional units.
The following diagram shows one possible way of separating the execution unit into
eight functional units operating in parallel.
The adder & integer multiplier performs the arithmetic operation with integer numbers.
The logic, shift, and increment operations can be performed simultaneously on different
data.
The floating-point operations are separated into three circuits operating in parallel.
All units are independent of each other, so one number can be shifted while another
number is being incremented.
The operation performed in each functional unit is indicated in each block of the
diagram:
4
INSTRUCTION CODES:
A computer instruction is a binary code that determines the micro-operations in a
sequence for a computer. They are saved in the memory along with the information.
Each computer has its specific group of instructions.
They can be categorized as follows:
Opcodes specify the operation for specific instructions.
Operands are definite elements of computer instruction that show what information
is to be operated on.
Address determines the registers or the areas that can be used for that operation.
It consists of 12 bits of memory that are required to define the address as the memory
includes 4096 words.
The 15th bit of the instruction determines the addressing mode (where direct addressing
corresponds to 0, indirect addressing corresponds to 1).
Therefore, the instruction format includes
12 bits of address.
3 bits for Opcodes.
1 bit for the addressing mode.
5
The following block diagram shows the instruction format for a basic computer.
There are three parts of the Instruction Format which are as follows −
1. Addressing Modes:
Instructions that define the address of a definite memory location are known as memory
reference instructions.
The method in which a target address or effective address is known within the
instruction is known as addressing mode.
The address field for instruction can be represented in two different ways are as follows:
Direct Addressing − It uses the address of the operand.
Indirect Addressing − It facilitates the address as a pointer to the operand.
Effective Address (EA): An effective address is the location of an operand which is
stored in memory.
2. Opcodes:
An opcode is a collection of bits that represents the basic operations including add,
subtract, multiply, complement, and shift.
The total number of operations provided through the computer determines the number
of bits needed for the opcode.
These operations are implemented on information that is saved in registers or memory.
3. Address/ Operand:
The address is represented as the location where a specific instruction is constructed in
the memory.
The address bits of an instruction code is used as an operand and not as an address. In
such methods, the instruction has an immediate operand.
If the second part has an address, the instruction is referred to have a direct address.
There is another possibility in the second part including the address as a pointer to
operand. This is referred to as an indirect address.
In the instruction code, one bit can signify if the direct or indirect addressing mode is
executed.
6
Types of Instruction Code: The following are some common types of instruction codes:
1. One-operand instructions:
These instructions have one operand and perform an operation on that operand.
For example, the "neg" instruction in the x86 assembly language negates the value
of a single operand.
2. Two-operand instructions:
These instructions have two operands and perform an operation involving both.
For example, the "add" instruction in x86 assembly language adds two operands
together.
3. Three-operand instructions:
These instructions have three operands and perform an operation that involves all
three operands.
For example, the "fma" (fused multiply-add) instruction in some processors
multiplies two operands together, adds a third operand, and stores the result in a
fourth operand.
4. Data transfer instructions:
These instructions move data between memory and registers or between registers.
For example, the "mov" instruction in the x86 assembly language moves data from
one location to another.
5. Control transfer instructions:
These instructions change the flow of program execution by modifying the program
counter.
For example, the "jmp" instruction in the x86 assembly language jumps to a
different location in the program.
6. Arithmetic instructions:
These instructions perform mathematical operations on operands.
For example, the "add" instruction in x86 assembly language adds two operands
together.
7. Logical instructions:
These instructions perform logical operations on operands.
For example, the "and" instruction in x86 assembly language performs a bitwise
AND operation on two operands.
7
8. Comparison instructions:
These instructions compare two operands and set a flag based on the result.
For example, the "cmp" instruction in x86 assembly language compares two
operands and sets a flag indicating whether they are equal, greater than, or less than.
9. Floating-point instructions:
These instructions perform arithmetic and other operations on floating-point
numbers.
For example, the "fadd" instruction in the x86 assembly language adds two
floating-point numbers together.
COMPUTER REGISTERS:
Computer registers are memory storing units that operate at high speed.
It's a component of a computer's processor.
Registers are a type of computer memory used to accept, store, and transfer data and
instructions used by the CPU right away.
It can hold any type of data, including a bit sequence or a single piece of data.
During the execution of a program, registers are used to store data temporarily.
The following are the various computer registers and their functions:
1. Accumulator Register (AC):
It is a general-purpose Register.
The initial data to be processed, the intermediate result, and the final result of the
processing operation are all stored in this register.
If no specific address for the result operation is specified, the result of arithmetic
operations is transferred to AC.
The number of bits in the accumulator register equals the number of bits per word.
A word is the natural unit of data used by a particular processor design. A word is a
fixed-sized piece of data handled as a unit by the instruction set.
2. Program Counter (PC):
A program counter (PC) is a CPU register in the computer processor which has the
address of the next instruction to be executed from memory.
It is a digital counter needed for faster execution of tasks as well as for tracking the
current execution point.
8
3. Address Register (AR):
It is the address of the memory location or Register where data is stored or retrieved.
The size of the Address Register is equal to the width of the memory address is directly
related to the size of the memory because it contains an address.
4. Data Register (DR):
The operand is stored in the Data Register from memory.
When a direct or indirect addressing operand is found, it is placed in the Data Register.
This value was then used as data by the processor during its operation. It's about the
same size as a word in memory.
5. Instruction Register (IR):
The instruction is stored in the Instruction Register.
The instruction register contains the currently executed instruction. Because it includes
instructions, the number of bits in the Instruction Register equals the number of bits in
the instruction, which is n bits for an n-bit CPU.
6. Temporary Register (TR):
The Temporary Register is used to hold data while it is being processed. As Temporary
Register stores data, the number of bits it contains is the same as the number of bits in
the data word.
7. Input Register (INPR): Input Register is a register that stores the data from an input
device. The computer's alphanumeric code determines the size of the input register.
8. Output Register (OUTR): The data that needs to be sent to an output device is stored in
the Output Register. Its size is determined by the alphanumeric code used by the computer.
Following is the list of some of the most common registers in computer:
Register Symbol No. of Function
Bits
Accumulator AC 16 It's a processor register.
Program counter PC 12 It stores the address of the instruction.
Address Register AR 12 It is used for storing memory addresses.
Data Register DR 16 A general-purpose register used for storing data during calculations.
Instruction Register IR 16 It stores current instruction being executed.
Temporary Register TR 16 It holds the temporary data.
Input Register INPR 8 It carries the input character.
Output Register OUTR 8 It carries the output character
9
INSTRUCTION CYCLE:
It is also known as Fetch-Execute-Cycle.
The instruction cycle is a basic computer system that deals with the central processor
unit's core operations.
The instruction cycle is defined as the basic cycle in which a computer system fetches
an instruction from memory, decodes it, and then executes it.
All instructions in a computer system are executed in the RAM of the computer system.
The CPU is in charge of carrying out the instruction.
Each instruction cycle in a basic computer includes the following procedures:
It has the ability to retrieve instructions from memory.
It's used to decode the command.
If the instruction has an indirect address, it can read the effective address from memory.
It is capable of carrying out the command.
The instruction cycle is divided into five stages, which are described below:
1. Initiating Cycle
2. Fetching of Instruction
3. Decoding of Instruction
4. Read of an Effective Address
5. Execution of Instruction
Initiating Cycle:
During this phase, the computer system boots up and the Operating System loads into the
central processing unit's main memory. It begins when the computer system starts.
Fetching of Instruction:
The first phase is instruction retrieval.
Each instruction executed in a central processing unit uses the fetch instruction.
During this phase, the central processing unit sends the PC to MAR and then the READ
instruction to a control bus.
After sending a read instruction on the data bus, the memory returns the instruction that
was stored at that exact address in the memory.
The CPU then copies data from the data bus into MBR, which it then copies to registers.
The pointer is incremented to the next memory location, allowing the next instruction
to be fetched from memory.
10
Decoding of Instruction:
The second phase is instruction decoding. During this step, the CPU determines which
instruction should be fetched from the instruction and what action should be taken on
the instruction.
The instruction's opcode is also retrieved from memory, and it decodes the related
operation that must be performed for the instruction.
Read of an Effective Address:
The third phase is the reading of an effective address. The operation's decision is
made during this phase.
Any memory type operation or non-memory type operation can be used.
Direct memory instruction and indirect memory instruction are the two types of memory
instruction available.
Execution of Instruction:
The last step is to carry out the instructions. The instruction is finally carried out at
this stage and the result is saved in the register.
The CPU gets prepared for the execution of the next instruction after the completion of
each instruction.
The execution time of each instruction is calculated, and this information is used to
determine the processor's processing speed.
Why do we need an Instruction Cycle?
The instruction cycle of a computer system is necessary for understanding the flow of
instructions and the execution of an instruction in a computer processor.
It is responsible for the complete flow of instructions from the start of the computer system
till its shutdown.
The instruction cycle helps to understand the internal flow of the central processing unit,
allowing any faults to be immediately resolved.
It deals with a computer processor's basic operations and demands a detailed understanding
of the many steps involved.
It is common for all instruction sets to require a thorough understanding to perform all
operations efficiently.
The processing time of a programme can be easily calculated using the instruction cycle,
which helps in determining the processor's speed. The processor's speed determines how
many instructions can be executed simultaneously in the central processing unit.
All instructions for the computer processor system follow the fetch-decode-execute cycle.
11
MEMORY REFERENCE INSTRUCTIONS:
Memory reference instructions are those commands or instructions which are in the custom to
generate a reference to the memory and approval to a program to have an approach to the
instructed information and that states as to from where the data is cache continually. These
instructions are known as Memory Reference Instructions.
There are seven memory reference instructions which are as follows:
1. AND:
The AND instruction implements the AND logic operation on the bit collection from the
register and the memory word that is determined by the effective address. The result of
this operation is moved back to the register.
2. ADD:
The ADD instruction adds the content of the memory word that is denoted by the effective
address to the value of the register.
3. LDA:
The LDA instruction shares the memory word denoted by the effective address to the
register.
4. STA:
STA saves the content of the register into the memory word that is defined by the effective
address. The output is next used to the common bus and the data input is linked to the bus.
It needed only one micro-operation.
5. BUN:
The Branch Unconditionally (BUN) instruction can send the instruction that is
determined by the effective address. They understand that the address of the next
instruction to be performed is held by the PC and it should be incremented by one to receive
the address of the next instruction in the sequence. If the control needs to implement
multiple instructions that are not next in the sequence, it can execute the BUN instruction.
6. BSA:
BSA stands for Branch and Save-return Address. These instructions can branch a part
of the program (known as subroutine or procedure). When this instruction is performed,
BSA will store the address of the next instruction from the PC into a memory location that
is determined by the effective address.
7. ISZ:
The Increment if Zero (ISZ) instruction increments the word determined by effective
address. If the incremented cost is zero, thus PC is incremented by 1. A negative value is
saved in the memory word through the programmer. It can influence the zero value after
getting incremented repeatedly. Thus, the PC is incremented and the next instruction is
skipped.
12
FLYNN'S CLASSIFICATION OF COMPUTERS:
M.J. Flynn proposed a classification for the organization of a computer system by the
number of instructions and data items that are manipulated simultaneously.
The sequence of instructions read from memory constitutes an instruction stream.
The operations performed on the data in the processor constitute a data stream.
Note: The term 'Stream' refers to the flow of instructions or data.
Flynn's classification divides computers into four major groups that are:
1. Single instruction stream, single data stream (SISD)
2. Single instruction stream, multiple data stream (SIMD)
3. Multiple instruction stream, single data stream (MISD)
4. Multiple instruction stream, multiple data stream (MIMD)
14
3. MISD: (Multiple Instruction and Single Data stream)
MISD stands for ‘Multiple Instruction and Single Data stream’.
MISD structure is only of theoretical interest since no practical system has been
constructed using this organization.
In MISD, multiple processing units operate on one single-data stream. Each processing
unit operates on the data independently via separate instruction stream.
Here, M = Memory Unit, CU = Control Unit, P = Processor Units
Example: The experimental Carnegie-Mellon computer (1971)
15
INSTRUCTION SET ARCHITECTURE:
Instruction Set Based Classification of Processors (RISC, CISC and Their Comparisons)
RISC PROCESSOR:
RISC stands for Reduced Instruction Set Computer Processor, a microprocessor
architecture with a simple collection and highly customized set of instructions.
It is built to minimize the instruction execution time by optimizing and limiting the
number of instructions.
It means each instruction cycle requires only one clock cycle, and each cycle contains
three parameters: fetch, decode and execute.
The RISC processor is also used to perform various complex instructions by combining
them into simpler ones.
RISC chips require several transistors, making it cheaper to design and reduce the
execution time for instruction.
Examples: SUN’s SPARC, PowerPC, Microchip PIC processors, RISC-V.
16
RISC Processor Architecture:
RISC processor is implemented using the hardwired control unit. The hardwired
control unit produces control signals which regulate the working of processors
hardware. RISC architecture emphasizes on using the registers rather than memory.
This is because the registers are the ‘fastest’ available memory source. The registers are
physically small and are placed on the same chip where the ALU and the control unit
are placed on the processor. The RISC instructions operate on the operands present
in processor’s registers.
The hardware of RISC architecture is designed to execute the instruction quickly,
which is possible because of the more precise and smaller number of instructions and a
large number of registers.
In RISC, the data path is used to store and manipulate data in a computer. It is
responsible for managing data within the processor and its movement between the
processor and the memory.
The processor uses a cache to reduce the access time to the main memory.
The instruction cache is beneficial for retrieving and storing the data of frequently used
instructions. It speeds up the process of instruction execution. The data cache provides
storage for frequently used data from the main memory.
CISC PROCESSOR:
The CISC Stands for Complex Instruction Set Computer, developed by the Intel.
It has a large collection of complex instructions that range from simple to very complex
and specialized in the assembly language level, which takes a long time to execute the
instructions.
So, CISC approaches reducing the number of instruction on each program and ignoring
the number of cycles per instruction.
It emphasizes to build complex instructions directly in the hardware because the hardware
is always faster than software.
However, CISC chips are relatively slower as compared to RISC chips but use little
instruction than RISC.
Examples of CISC processors are VAX, AMD, Intel x86 and the System/360.
18
CISC Processors Architecture:
Here, you have a special microprogram control unit that uses a series of
microinstructions of the microprogram stored in the “control memory” of
the microprogram control unit and generate the control signals.
The control units access the control signals produced by the microprogram control
unit & operate the functioning of processors hardware.
Instruction and data path fetches the opcode and operands of the instructions from the
memory.
Cache and main memory is the location where the program instructions and operands
are stored.
Advantages of CISC Processors:
1. The compiler requires little effort to translate high-level programs or statement languages
into assembly or machine language in CISC processors.
2. The code length is quite short, which minimizes the memory requirement.
3. To store the instruction on each CISC, it requires very less RAM.
4. Execution of a single instruction requires several low-level tasks.
5. CISC creates a process to manage power usage that adjusts clock speed and voltage.
6. It uses fewer instructions set to perform the same instruction as the RISC.
Disadvantages of CISC Processors:
1. CISC chips are slower than RSIC chips to execute per instruction cycle on each program.
2. The performance of the machine decreases due to the slowness of the clock speed.
3. Executing the pipeline in the CISC processor makes it complicated to use.
4. The CISC chips require more transistors as compared to RISC design.
19
Difference between the RISC and CISC Processors:
S.No. RISC CISC
1. Reduced Instruction Set Computer. Complex Instruction Set Computer.
2 It emphasizes on software to optimize the It emphasizes on hardware to optimize
instruction set. the instruction set.
3. It is a hard wired unit of programming in Microprogramming unit in CISC
the RISC Processor. Processor.
4 It requires multiple register sets to store It requires a single register set to store the
the instruction. instruction.
5. It has simple decoding of instruction. It has complex decoding of instruction.
6. Uses of the pipeline are simple in RISC. Uses of the pipeline are difficult in CISC.
7. It uses a limited number of instruction It uses a large number of instruction that
that requires less time to execute the requires more time to execute the
instructions. instructions.
8. It uses LOAD and STORE that are It uses LOAD and STORE instruction in
independent instructions in the register- the memory-to-memory interaction of a
to-register a program's interaction. program.
9. RISC has more transistors on memory CISC has transistors to store complex
registers. instructions.
10. The execution time of RISC is very short. The execution time of CISC is longer.
11. RISC architecture can be used with high- CISC architecture can be used with low-
end applications like telecommunication, end applications like home automation,
image processing, video processing, etc. security system, etc.
12. It has fixed format instruction. It has variable format instruction.
13. The program written for RISC Program written for CISC architecture
architecture needs to take more space in tends to take less space in memory.
memory.
14. Example of RISC: ARM, PA-RISC, Examples of CISC: VAX, Motorola
Power Architecture, Alpha, AVR, ARC 68000 family, System/360, AMD and the
and the SPARC. Intel x86 CPUs.
20