Unit 1 BCA 303 CA
Unit 1 BCA 303 CA
Prepared By:
Dr Tejinder Kaur
Associate Professor
Basics of Computer Architecture
Computer architecture is about designing a computer system
to balance performance, efficiency, cost, and reliability. It
describes how a system is built from its components. This can
be a high-level overview or a detailed explanation, including the
instruction set architecture, micro architecture, logic design,
and implementation
Course: Co
mputer Network
Different Types Of CPU Registers
• There are several types of registers available in the CPU for different
purposes let's discuss each one by one:
• Accumulator : This is the most frequently used register used to store data
taken from memory. It is indifferent numbers in different microprocessors.
• General Purpose Registers : These are numbered as R0, R1, R2....Rn-1, and
used to store temporary data during any ongoing operation. Its content can be
accessed by assembly programming. Modern CPU architectures tend to use
more GPR so that register-to-register addressing can be used more, which is
comparatively faster than other addressing modes .
continue
• Program Counter (PC) : Program Counter (PC) is used to keep the track of the
execution of the program. It contains the memory address of the next instruction to be
fetched. PC points to the address of the next instruction to be fetched from the main
memory when the previous instruction has been successfully completed. Program
Counter (PC) also functions to count the number of instructions. The incrementation of
PCs depends on the type of architecture being used. If we are using a 32-bit
architecture, the PC gets incremented by 4 every time to fetch the next instruction.
• Instruction Register (IR): The IR holds the instruction which is just about to be
executed. The instruction from the PC is fetched and stored in IR. As soon as the
instruction is placed in IR, the CPU starts executing the instruction, and the PC points
to the next instruction to be executed.
• Stack Pointer (SP): The stack PCs pointer points to the top of the stack, which is a
part of the memory used to store function calls and other operations.
• Flag Register: A flag register , also known as a status register or condition code
register, is a special type of register in a computer's central processing unit (CPU) used
to indicate the status of the CPU or the outcome of various operations such as Zero
Flag, Carry flag, Sign Flag, Overflow Flag, Parity Flag, Auxiliary Carry Flag, and
Interrupt Enable Flag.
continue
• Size of CPU Register
• The number and size of the register in the CPU depend on the
processor design and can have an important impact on its
performance and capabilities on the CPU. Now, let's discuss the
different sizes of the register available in the CPU:
• 8-bit registers: These can store 8 bits of data, which is the same as 1
byte. They are used for simple arithmetic and data manipulation.
• 16-bit registers: These hold 16 bits of data, or 2 bytes. These
registers are found in older processors or certain systems that need
16-bit operations.
• 32-bit registers: These can store 32 bits of data or 4 bytes. They are
common in many processors and can handle larger data sizes and
more complex calculations than 8-bit or 16-bit registers.
• 64-bit registers: These hold 64 bits of data, or 8 bytes. Modern
processors often use these, providing more computational power and
better memory-addressing capabilities.
General Register Organization
continue
or example:
MULT R1, R2, R3
This is an instruction of an arithmetic multiplication written in assembly language. It uses three address fi
this instruction is:
R1 <-- R2 * R3
This instruction also can be written using only two address fields as:
MULT R1, R2
In this instruction, the destination register is the same as one of the source registers. This means the oper
R1 <-- R1 * R2
continue
• When we are using multiple general-purpose
registers, instead of a single accumulator register, in
the CPU Organization then this type of organization is
known as General register-based CPU Organization.
In this type of organization, the computer uses two or
three address fields in their instruction format. Each
address field may specify a general register or a
memory word. If many CPU registers are available for
heavily used variables and intermediate results, we
can avoid memory references much of the time, thus
vastly increasing program execution speed, and
reducing program size.
continue
• Features of a General Register based CPU organization:
• Registers: In this organization, the CPU contains a set of registers, which are
small, high-speed memory locations used to store data that is being processed by
the CPU. The general-purpose registers can be used to store any type of data,
including integers, floating-point numbers, addresses, and control information.
• Operand access: The CPU accesses operands directly from the registers, rather
than having to load them from memory each time they are needed. This can
significantly improve performance, as register access is much faster than
memory access.
• Data processing: The CPU can perform arithmetic and logical operations
directly on the data stored in the registers. This eliminates the need to transfer
data between the registers and memory, which can further improve performance.
• Instruction format: The instruction format used in a General Register based
CPU typically includes fields for specifying the operands and operation to be
performed. The operands are identified by register numbers, rather than memory
addresses.
• Context switching: Context switching in a General Register based CPU involves
saving the contents of the registers to memory, and then restoring them when the
process resumes. This is necessary to allow multiple processes to share the CPU.
CONTINUE
• The advantages of General register-based CPU
organization -
• The efficiency of the CPU increases as large number of
registers are used in this organization.
• Less memory space is used to store the program since
the instructions are written in a compact way.
• The disadvantages of General register based CPU
organization -
• Care should be taken to avoid unnecessary usage of
registers. Thus, compilers need to be more intelligent in
this aspect.
• Since a large number of registers are used, thus extra
cost is required in this organization.
Computer instructions
• Basic Computer Instructions
• Basic computer instructions are commands given
to a computer to perform specific tasks. These
instructions are typically divided into three
categories:
• Data Transfer Instructions: Move data between
memory and registers (e.g., Load, Store).
• Arithmetic and Logic Instructions: Perform
math or logic operations (e.g., Add, Subtract, AND,
OR).
• Control Instructions: Guide the flow of the
program (e.g., Jump, Branch, Call).
continue
• Data Transfer Instructions
• These instructions deal with moving data from one
location to another within the computer. Think of it
as copying or transferring information between
various components like memory, registers, or
storage.
• Common Data Transfer Instructions:
• Load: Copies data from memory to a register
(temporary storage inside the CPU).
• Store: Transfers data from a register to memory.
• Move: Transfers data from one register to another.
continue
• Arithmetic and Logic Instructions
• These instructions are used to perform
mathematical and logical operations. They
enable computers to handle calculations and
make decisions based on certain conditions.
• Arithmetic Instructions:
• Add: Adds two numbers.
• Subtract: Subtracts one number from another.
• Multiply: Multiplies two numbers.
• Divide: Divides one number by another.
continue
• Logic Instructions:
• AND: Compares two bits and returns 1 if
both are 1; otherwise, returns 0.
• OR: Compares two bits and returns 1 if at
least one is 1.
• NOT: Inverts a bit (1 becomes 0, and 0
becomes 1).
• XOR (Exclusive OR): Returns 1 if the
bits are different, 0 if they are the same.
continue
• Control Instructions
• Control instructions determine the flow of execution in a
program. They guide the computer on which instruction to
execute next, allowing flexibility in decision-making and
repeated actions.
• Common Control Instructions:
• Jump (JMP): Directs the program to execute a specific
instruction elsewhere in the code.
• Conditional Branch: Jumps to another instruction only if a
specific condition is true. Example: Branch if zero (BZ) or
branch if not zero (BNZ).
• Call: Transfers control to a subroutine (a set of instructions
performing a specific task) and returns afterward.
• Return: Brings back control to the main program after a
subroutine is executed.
Instruction Cycles,
Each phase of Instruction Cycle can be
decomposed into a sequence of elementary
micro-operations. In the above examples,
there is one sequence each for the Fetch,
Indirect, Execute and Interrupt Cycles.
continue
• Fetch cycle: This cycle retrieves the instruction from memory and
loads it into the processor's instruction register. The fetch cycle is
essential for the processor to know what instruction it needs to
execute.
• Decode cycle: This cycle decodes the instruction to determine
what operation it represents and what operands it requires. The
decode cycle is important for the processor to understand what it
needs to do with the instruction and what data it needs to retrieve
or manipulate.
• Execute cycle: This cycle performs the actual operation specified
by the instruction, using the operands specified in the instruction or
in other registers. The execute cycle is where the processor
performs the actual computation or manipulation of data.
• Store cycle: This cycle stores the result of the operation in memory
or in a register. The store cycle is essential for the processor to
save the result of the computation or manipulation for future use.
Memory reference instruction,
Memory reference instructions (MRIs)
are a type of machine language instruction
that allows a program to access and
manipulate data stored in memory. These
instructions provide the memory address
where the data resides or where the data
should be stored. They are crucial for
operations like loading data into registers,
storing data from registers into memory,
and performing arithmetic and logical
continue
• Data Access:
• Memory reference instructions are crucial for fetching data
needed for computations or storing the results of calculations
back into memory.
• Program Control:
• They can also be used to control the flow of execution by
branching to different memory locations based on conditions.
• Key Components:
• Opcode: Specifies the operation to be performed (e.g., load,
store, add, branch).
• Address: Indicates the specific memory location the
instruction refers to.
• Addressing Mode: Determines how the address is calculated
(e.g., direct or indirect).
continue
• Common Examples:
• Load (LDA): Transfers data from a memory location to a register
(often the accumulator).
• Store (STA): Transfers data from a register to a memory location.
• Add (ADD): Adds the contents of a memory location to the
accumulator.
• Branch (BUN, BSA): Changes the program's flow by jumping to a
different memory address.
• Increment and Skip if Zero (ISZ): Increments a memory location
and skips the next instruction if the result is zero.
• Importance:
• Memory reference instructions are fundamental to the operation of
any computer system, enabling it to work with data stored in
memory.
• They are essential for executing complex programs and performing
various tasks.
Input / Output instructions.
Input/output (I/O) instructions in computer
architecture are used to transfer data
between the C Input / Output instructions
PU and peripheral devices like keyboards,
monitors, and storage devices. These
instructions facilitate communication
between the computer system and the
external world, enabling the system to
receive data from users and send data to
users or other systems.
continue
• I/O instructions allow the CPU to
communicate with peripheral devices, like
keyboards, printers, or hard drives.
• 🧩 Types of I/O Techniques
• Programmed I/O: CPU waits and checks the
device status until it’s ready.
• Interrupt-driven I/O: Device notifies CPU via
an interrupt when ready.
• Direct Memory Access (DMA): Device
transfers data directly to memory without CPU
intervention.
Register transfer Language
• Register Transfer Language (RTL) is a low-level
language that is used to describe the functioning of
a digital circuit and, more specifically, the transfer
of information between registers. It provides how
data moves from one register to the other and how
data is processed within the digital system.
Through RTL, there is a capability of creating
abstraction levels where high-level design
descriptions can be created and easily linked to
low-level hardware implementation in designing,
simulating, as well as synthesizing digital circuits.
continue
• Key Concepts of Register Transfer Language(RTL)
• The meaningful descriptions are provided by RTL for
the flow of data between the registers of the hardware.
• It is applied to the representation of synchronous
circuits: circuits that are controlled by clock signals.
• Transfer of data and logical operations are described
for the register level.
• As mentioned earlier, RTL designs are documented
most often in hardware description languages,
including Verilog or VHDL.
• It is an abstraction layer between high-order
Application Specific Integrated Circuits (ASICs) and
physical devices.
continue
• Advantages of Register Transfer Language
(RTL)
• Enables efficient hardware design.
• This makes it possible to simulate some
activities and perhaps detect some errors at an
early date.
• Implements conceptual description up to the
gate-level hardware.
• It helps to reuse the design components.
• It gives a clear guide on how to do timing
analysis on a given design.
continue
• Disadvantages of Register Transfer Language
(RTL)
• Although the performance is high, this type can be
quite challenging to debug.
• These may lead to inefficient large constructions if not
well optimized for beneficial use.
• The reasoning behind it is rather hardware-oriented
and may cause problems that are hard to comprehend
without knowledge of message flow.
• Synthesis results appear to depend on the capabilities
of specific tools.
• Compared to high-level descriptions, the amount of
abstraction retrieved by this system is very low.
continue
Register Transfer
Register transfer refers to the process of
moving data between registers within a
digital system, such as a computer. It
involves copying the contents of one
register to another, often using micro-
operations like load, shift, count, or
clear. This transfer can be represented
symbolically using a register transfer
language (RTL).
Example:
A register transfer from register R1 to register R2 can be represented in
RTL as: R2 <- R1.
This indicates that the data stored in register R1 is copied to register R2.
Bus & memory transfer,
In a computer system, bus transfer refers
to the movement of data between different
components, such as registers, memory,
and I/O devices, using a shared pathway
called a bus. Memory transfer specifically
involves moving data into or out of memory
locations, either from a register or another
memory location.
Bus Transfer:
•A bus is a collection of parallel lines that act as a shared communication pathway for tra
•It allows multiple devices to communicate with each other without needing separate con
each pair of devices.
•Parallel bus: Uses multiple lines to transmit data simultaneously, enabling faster data
•Serial bus: Transmits data sequentially, one bit at a time, typically using fewer lines.
•Examples of buses include the data bus, address bus, and control bus, each serving a sp
data transfer.
•Data bus: Carries the actual data being transferred.
•Address bus: Carries the memory addresses to specify the location for data transfer.
•Control bus: Carries control signals to manage the data transfer process.
•Bus transfer is an efficient way to move data: by utilizing a single set of lines for c
between multiple components.
Memory Transfer:
•Memory transfer involves moving data between different locations in memory or betw
components like the CPU.
•Read operation: Transfers data from a memory location to a register.
•Write operation: Transfers data from a register to a memory location.
•Memory transfer is fundamental for accessing and manipulating data stored in memor
•Common bus system is often used for memory transfers .
•Multiplexers and three-state buffers can be used to implement a common bus system
•Serial or parallel buses can be used for memory transfers: depending on the sp
architecture.
continue
continue
Let’s discuss the common bus system with
multiplexers. The construction of this bus system
for 4 registers is shown above. The bus consists of
4x1 multiplexers with 4 inputs and 1 output and 4
registers with bits numbered 0 to 3. There are 2
select inputs S0 and S1 which are connected to the
select inputs of the multiplexers. The output 1 of
register A is connected to input 0 of MUX 1 and
similarly other connections are made as shown in
the diagram. The data transferred to the bus
depends upon the select lines.
continue
Common bus system
Connections: The outputs of all the registers except the OUTR
(output register) are connected to the common bus. The output
selected depends upon the binary value of variables S2, S1 and S0.
The lines from common bus are connected to the inputs of the
registers and memory. A register receives the information from the
bus when its LD (load) input is activated while in case of memory
the Write input must be enabled to receive the information. The
contents of memory are placed onto the bus when its Read input is
activated. Various Registers: 4 registers DR, AC, IR and TR have
16 bits and 2 registers AR and PC have 12 bits. The INPR and
OUTR have 8 bits each. The INPR receives character from input
device and delivers it to the AC while the OUTR receives character
from AC and transfers it to the output device. 5 registers have 3
control inputs LD (load), INR (increment) and CLR (clear). These
types of registers are similar to a binary counter.
Adder and logic circuit: The adder and logic circuit
provides the 16 inputs of AC. This circuit has 3 sets of
inputs. One set comes from the outputs of AC which
implements register micro operations. The other set
comes from the DR (data register) which are used to
perform arithmetic and logic micro operations. The
result of these operations is sent to AC while the end
around carry is stored in E as shown in diagram. The
third set of inputs is from INPR. Note: The content of
any register can be placed on the common bus and an
operation can be performed in the adder and logic
circuit during the same clock cycle.
Micro-operations: Arithmetic, Logic
and
Micro-operations are the fundamental, atomic
operations performed by a computer's
CPU. They can be categorized into arithmetic,
logic, and shift micro-operations. Arithmetic
micro-operations involve numerical calculations
(addition, subtraction, increment, decrement)
on data stored in registers. Logic micro-
operations perform bitwise operations (AND,
OR, XOR, etc.) on data. Shift micro-operations
move data bits within a register, either left or
right.
continue
1. Arithmetic Micro-operations:
•These operations involve mathematical calculations on data stored in
registers.
•Examples include addition, subtraction, increment, decrement, and
complement operations.
•Addition: R3 ← R1 + R2 (adds the contents of registers R1 and R2, storing
the result in R3).
•Subtraction: R3 ← R1 - R2 (subtracts the contents of R2 from R1, storing
the result in R3).
•Increment: R1 ← R1 + 1 (increments the value in register R1 by 1).
•Decrement: R1 ← R1 - 1 (decrements the value in register R1 by 1).
•Complement: R2 ← R2' (complements the bits in register R2).
Logic Micro-operations: