Computer Architecture Notes
Computer Architecture Notes
Unit-I Computer architecture and organization, computer generations, von Neumann model,
CPU organization, CPU organization, Register organization, Various CPU register, Register
Transfer, Bus and Memory Transfers, Arithmetic, Logic and Shift micro-operations, Arithmetic
logic shift unit.
Unit–II The arithmetic and logic unit, Fixed-Point representation: integer representation,
signmagnitude, 1’s and 2’s complement and range, Integer arithmetic: negation, addition and
subtraction, multiplication, division, Floating-Point representation, Floating-Point arithmetic,
Hardwired micro-programmed control unit, Control memory, Micro-program sequence.
Unit–III Central Progressing Unit (CPU), Stack Organization, Memory Stack, Reverse Polish
Notation. Instruction Formats, Zero, One, Two, Three- Address Instructions, RISC Instructions
and CISC Characteristics, Addressing Modes, Modes of Transfer, Priority Interrupt, Daisy
Chaining, DMA, Input-Output Processor (IOP).
Unit–IV Computer memory system, Memory hierarchy, main memory: RAM, ROM chip,
auxiliary and associative memory, Cache memory: associative mapping, direct mapping,
setassociative mapping, write policy, cache performance, Virtual memory: address space,
memory space, address mapping, paging and segmentation, TLB, page fault, effective access
time, replacement algorithm.
https://pravin-hub-rgb.github.io/BCA/resources/sem3/coatbc304/index.html
Computer generations are periods marked by significant
advancements in technology, with each generation characterized by new
components, increased capabilities, and improved efficiency. Here's a brief
overview:
Generations of Computers:
The Mathematician John Von-Neuman designed the specification for the first
programmable computer in 1954, where the programs themselves could be stored in
memory, not just data.
Instructions are stored in memory and are retrieved and processed by the Central
Processing Unit one by one. This blueprint is known as the Von-Neumann Architecture.
● Fetch an Instruction
● Decode the Instruction
● Execute the Instruction
The process above is repeated indefinitely, and is known as the fetch, decode, execute
cycle.
The job of the control unit is to coordinate and control all the other parts of the CPU. It
tells the registers & ALU what to do with an instruction that is passed to them.
The CU decodes the instructions retrieved from memory and instructs the ALU to
perform an arithmetic or logic instruction on the data from the decoded instruction.
The job of the ALU is to perform the calculations or logic that the CU has decoded.
● Addition
● Subtraction
● Division
● Multiplication
● Selection / Branching
● Repetition / looping.
Registers
The registers form part of the CPU Cache, temporarily storing data ready for processing
or send to the RAM.
PC – Program Control Register
The program control register stores the address of the current instruction. Once the
current instruction has been fetched and decoded, the program control register
changes to the address of the next instruction.
IR – Instruction Register
The instruction register contains the current instruction itself, retrieved from it’s stored
address.
The memory address register contains the memory location of either the next instruction
to be fetched or the location of where the results of the current process are to be stored.
The memory data register contains either the data retrieved from memory (either an
instruction or an operand) during the current fetch cycle at the address stipulated in the
MAR, or the data the is due to be written to memory.
ACC – Accumulator
The accumulator receives the results of the current process from the ALU and stores it
for the use in the next Fetch-Decode-Execute cycle.
IX – Index Register
Buses
Buses are the physical wires along which data is passed, both within the CPU itself and
across the motherboard.
CPU Bus
The CPU bus is used to pass data around the CPU between the CU,ALU and registers.
Control Bus
The Control bus sends signals to the RAM, indicating whether to initiate a read or write
on the address received along the address bus
Address Bus
The address bus is the wire along which the address of the memory location in RAM
required for the read/write is sent.
Data Bus
The data bus is the wire along which the data is sent either to or from the RAM
(depending whether a read or write has been initiated.
● We are familiar with the general format of a register, which is utilized for
storing and manipulating data. A register typically consists of a mode, opcode,
and operand.
1. Mode: Specifies the address mode.
2. Opcode: Indicates the operation to be performed.
3. Data: Contains the actual data.
● This type of register is employed in computer architectures.
● Now, let's delve into the Single Accumulator Organization: Basic computers
often adopt the single accumulator organization, where the accumulator
serves as a dedicated register.
● Operations are executed within the Arithmetic Logic Unit (ALU), which resides
inside the Central Processing Unit (CPU). The CPU is directly linked to the
register, ensuring high-speed data transfer.
● The input data for the ALU is sourced from the accumulator register, and the
result of the ALU calculation is then stored back in the accumulator.
● Single Accumulator Organization is chosen when cost-effectiveness is a
priority. By minimizing the number of registers, we reduce the overall system
cost.
● Registers are the fastest form of memory, and connecting them directly to the
CPU ensures rapid data exchange, contributing to high system performance.
The more registers used, the higher the cost. To achieve cost-effectiveness, a
single accumulator register is employed.
● Definition of Single Accumulator Organization: In this architecture, a single
accumulator register is designated for arithmetic and logic operations. It
optimizes cost by limiting the number of registers, emphasizing efficiency in
simple computing systems.
General Architecture of Single Accumulator Organization
● The depicted bus organization features seven CPU registers, and its
functionality is detailed as follows:
● The output of each register is linked to two multiplexers (MUX), both of which
play a crucial role in transferring register data into the Arithmetic Logic Unit
(ALU).
● Two buses, A and B, are utilized for data transfer. The selection lines in each
multiplexer determine whether to choose data from a register or from input
data. Data is transmitted to the ALU via buses A and B.
● The OPR (Operation) signal serves to define the type of operation to be
executed by the ALU.
● The result of the operation conducted by the ALU can be directed to other
units within the system or stored in any of the processor registers.
● A decoder is employed to select the register where the result will be stored.
The decoder activates one of the register load inputs, specifying the
destination register for storing the result.
Control Word
● A control word, designed for the aforementioned CPU organization, consists
of four fields as illustrated below:
Stack Organization
Register Stack
● When processor registers are organized in a stack-like fashion, it is termed a
register stack. The diagram above illustrates a 64-word register stack.
● The stack pointer (SP) contains the address of the topmost element in the
stack.
● When the stack is empty, the EMPTY flag is set to 1, and when the stack is
full, the FULL flag is set to 1.
● The DR (Data Register) contains the data either being popped from or
pushed into the stack.
● Additional benefits of a register stack include faster access times and
reduced memory bus contention, making it suitable for certain computing
tasks requiring high-speed data manipulation.
● For example, in the figure, three items (A, B, and C) are placed in the stack,
with item C at the top. Thus, the stack pointer (SP) holds the address of C
(SP = 3).
PUSH Operation:
○ Step 2: Store the value of the Data Register (DR) at the address
pointed to by SP.
POP Operation:
● When performing a POP operation to remove an element from the stack, the
following steps are executed:
○ Step 1: Retrieve the data from the address stored in the Stack Pointer
(SP) and store it in the Data Register (DR).
SP → SP - 1
empty]
Memory Stack
PUSH Operation
SP → SP - 1
M[SP] ← DR
POP Operation
DR ← M[SP]
SP → SP + 1
Addressing Modes
An instruction format is a collection of bits that defines the type of instruction,
operands, and the type of operation. The instruction format is represented by a
rectangular box, and a basic instruction format includes the following fields: Opcode,
Mode, and Address.
Data transfer instructions facilitate the movement of data from one location to
another within the computer system. These instructions are essential for controlling
the flow of information, including:
The table below presents a list of eight common data transfer instructions widely
utilized across various computer architectures:
Data Manipulation Instructions
1. Arithmetic Instructions
2. Logical and Bit Manipulation Instructions
3. Shift Instructions
Arithmetic Instructions
Shift Instructions
Shift instructions move bits within a register either to the left or right. Logical shifts
insert 0 to the end bit position. The table below illustrates various types of shift
instructions:
Pipelining
● Pipelining involves dividing a process into several suboperations, with each
suboperation associated with a segment.
● The output of each segment is stored in a register, and this register information
is passed to the next segment, facilitating a continuous flow of data.
● Each segment operates independently, allowing for concurrent execution of all
segments in the pipeline.
● The term "pipelining" is derived from the sequential transfer of information from
one segment to another.
Segment 1: R1 ← Ai, R2 ← Bi
Segment 2: R3 ⇆ R1 * R2, R4 ← Ci
Segment 3: R5 ← R3 + R4
Pipelining is an efficient technique that allows for the overlap of different stages of
instruction execution, thereby improving overall throughput. Each segment operates
concurrently, enabling the processor to handle multiple instructions simultaneously.
This approach significantly enhances the speed and efficiency of data processing in
modern computer architectures.
What is the General Register
Organization?
In General Register Organization, the CPU uses a set of general-purpose registers to
store data temporarily during program execution. These registers are small, high-speed
storage locations within the CPU. Unlike accumulator-based architectures, where data
each capable of storing different types of data such as integers, floating-point numbers,
The use of these general-purpose registers allows for faster data processing since
accessing data from registers is significantly faster than fetching it from memory.
Additionally, many CPU instructions are designed to operate directly on data stored in
1. Registers
In the General Register Organization, the CPU contains several general-purpose
registers. These registers are essential for storing data that is actively being processed,
providing fast access compared to slower memory storage. This feature is fundamental
in optimizing performance, especially when dealing with frequently accessed variables
2. Operand Access
The CPU directly accesses operands from the registers, which eliminates the need to
access slower memory constantly. By using the registers, data retrieval and
manipulation become faster, which in turn speeds up program execution. The general-
purpose registers act as intermediate storage for operands used in arithmetic and
logical operations.
3. Data Processing
In this architecture, the CPU can perform arithmetic and logical operations directly on
data stored in registers, bypassing the need for intermediate memory transfers. This
approach reduces the time spent in data movement, improving overall execution speed.
4. Instruction Format
The instruction format in General Register Organization usually includes fields that
specify the operation to be performed and the operands (which are typically register
addresses). These instructions are designed to be compact, allowing efficient use of the
5. Context Switching
One critical feature of General Register Organization is its ability to support context
switching. When the CPU switches between processes, it saves the contents of its
general-purpose registers to memory and later restores them when the process is
resumed. This mechanism allows multiple processes to share the CPU while preserving
operand must always be located in a register, while the second operand can either be in
where one address refers to a register and the other may refer to either a register or a
memory location.
employs three-address instruction formats. In this case, all operands involved in the
arithmetic or logical operation must be in the registers. The results of computations are
includes the IBM 360 and PDP-11 computer architectures. These systems are known
for their efficient use of registers and their ability to perform complex operations with
reduced demand on memory, making them highly effective for a range of computing
tasks.
Conclusion
In conclusion, general register organization is a powerful CPU design approach that
on a single accumulator. As, it plays a critical role in modern CPU designs, particularly
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 operation
R1 <-- R1 * R2
The use of a large number of registers results in a short program with limited
instructions.
Some examples of General register-based CPU Organizations are IBM 360
and PDP- 11.
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.
The advantages of General register-based CPU organization –
● The efficiency of the CPU increases as large number of registers are
RAM is faster than from a hard drive, it’s still not quick enough for the CPU,
which is why registers are used to store and retrieve data faster. They work
memory being the next step in speed, though still slower than registers. Each
microprocessors.
main memory.
stored in IR. As soon as the instruction is placed in IR, the CPU starts
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.
central processing unit (CPU) used to indicate the status of the CPU
Sign Flag, Overflow Flag, Parity Flag, Auxiliary Carry Flag, and
different flags that indicate the status of any operation. For instance,
or zero, then these flags are set high accordingly. and the flags are
1. Carry C: Set to 1 if an add operation produces a carry or a subtract
operations.
So, these are the different registers that are operating for a specific purpose.
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 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
Most modern computers use 32-bit or 64-bit registers, and that’s why we
call them 32-bit or 64-bit processors. This terminology refers to the width of
the processor’s registers and how much data it can handle at once.
In some specialized processors, you might see even larger registers like 128-
bit or 256-bit. These are used for specific tasks such as vector processing or
cryptography where dealing with large data sets and parallel processing is
important.
Purpose of Registers
Registers play a very important role in computers, and they are used by CPU
programs before the CPU follows them. This helps the computer
computer can grab them fast without going far away to get them.
It’s like keeping your favorite tools on a shelf right next to you,
So, registers are like the computer’s quick-access memory, helping it work
Registers define the storage area that influences the data and instructions. It
can send data and instructions from one register to another register, memory to
register, and memory to memory, the register transfer approach is used. This
register is used in the transmission of data and instructions between memory
and processors to implement the particular tasks.
R2←R1
It indicates a transfer of the content of register R1 into register R2. It labelled a
replacement of the content of R2 by the content of R1. The content of the
source register R1 does not shift after the transfer.
We need the transfer to appear only under a fixed control condition. This can be
displayed using an if-then statement.
P: R2 ← R1
The diagram demonstrates the block diagram that shows the transfer from R1 to
R2. The n outputs of register R1 are linked to the n inputs of register R2. The
letter n can denote any number of bits for the register. It will be restored by an
actual number when the duration of the register is established.
A bus structure, on the other hand, is more efficient for transferring information
between registers in a multi-register configuration system.
A bus consists of a set of common lines, one for each bit of register, through
which binary information is transferred one at a time. Control signals determine
which register is selected by the bus during a particular register transfer.
The following block diagram shows a Bus system for four registers. It is
constructed with the help of four 4 * 1 Multiplexers each having four data inputs
(0 through 3) and two selection inputs (S1 and S2).
We have used labels to make it more convenient for you to understand the input-
output configuration of a Bus system for four registers. For instance, output 1 of
register A is connected to input 0 of MUX1.
The two selection lines S1 and S2 are connected to the selection inputs of all
four multiplexers. The selection lines choose the four bits of one register and
transfer them into the four-line common bus.
When both of the select lines are at low logic, i.e. S1S0 = 00, the 0 data inputs of
all four multiplexers are selected and applied to the outputs that forms the bus.
This, in turn, causes the bus lines to receive the content of register A since the
outputs of this register are connected to the 0 data inputs of the multiplexers.
Similarly, when S1S0 = 01, register B is selected, and the bus lines will receive the
content provided by register B.
The following function table shows the register that is selected by the bus for
each of the four possible binary values of the Selection lines.
Note: The number of multiplexers needed to construct the bus is equal to the
number of bits in each register. The size of each multiplexer must be 'k * 1' since
it multiplexes 'k' data lines. For instance, a common bus for eight registers of 16
bits each requires 16 multiplexers, one for each line in the bus. Each multiplexer
must have eight data input lines and three selection lines to multiplex one
significant bit in the eight registers.
The three state gates can be considered as a digital circuit that has three gates,
two of which are signals equivalent to logic 1 and 0 as in a conventional gate.
However, the third gate exhibits a high-impedance state.
The most commonly used three state gates in case of the bus system is a buffer
gate.
○ The control inputs to the buffers determine which of the four normal inputs will
communicate with the bus line.
○ A 2 * 4 decoder ensures that no more than one control input is active at any given
point of time.
Memory Transfer
Most of the standard notations used for specifying operations on memory
transfer are stated below.
○ The transfer of information from a memory unit to the user end is called a Read
operation.
○ We must specify the address of memory word while writing the memory transfer
operations.
Read: DR ← M [AR]
○ The Read statement causes a transfer of information into the data register (DR)
from the memory word (M) selected by the address register (AR).
Write: M [AR] ← R1
○ The Write statement causes a transfer of information from register R1 into the
memory word (M) selected by address register (AR).
Arithmetic Micro-operations
In general, the Arithmetic Micro-operations deals with the operations performed
on numeric data stored in the registers.
1. Addition
2. Subtraction
3. Increment
4. Decrement
5. Shift
Note: The increment and decrement micro-operations are symbolized by '+ 1'
and '? 1' respectively. Arithmetic operations like multiply and divide are not
included in the basic set of micro-operations.
omputers work mainly based on instructions. These are simple commands that tell the
system what to do, such as adding and subtracting or multiplying and dividing. Every
operation a computer performs starts with data stored in registers. But how does this
Micro operations are the smallest tasks the CPU performs, directly manipulating data in
registers. They handle everything from transferring data between registers to performing
calculations. In this blog, we look deeper into logic micro-operations, how they work,
strings of bits. Each bit within the register is treated individually and functions as an
independent binary variable. This bitwise approach allows for a total of 16 distinct logic
truth tables. The table below illustrates the truth table for all 16 logic micro-operations.
In the table, x and y represent the variables or registers where the data is stored. F0,
F1…., F15 denote the outputs produced after each logic micro-operation is applied.
So, what does each logic micro-operation do? Let’s take a look:
1. Clear: This logic micro-operation sets all bits in the register to 0. Hence, it’s
effectively resetting the data. It’s used to initialize or erase the contents of a
register.
2. AND: The AND operation performs a bitwise AND between corresponding bits of
two registers. The output bit is 1 only if both input bits are 1. Otherwise, it is 0.
3. Transfer A: Transfer A copies the contents of register A directly to the output
without any changes.
4. Transfer B: The Transfer B operation copies the contents of register B directly to
the output without any changes.
5. Exclusive OR: The Exclusive OR (XOR) performs a bitwise comparison
between two registers. The output bit is 1 if the corresponding bits of the inputs
are different, and it is 0 if they are the same.
6. OR: The OR performs a bitwise OR between corresponding bits of two registers.
The output bit is 1 if at least one of the input bits is 1, otherwise it is 0.
7. NOR: This operation performs a bitwise OR operation followed by negation. The
output bit is 1 only if both input bits are 0. Otherwise, the output is 0. It’s used to
invert the result of an OR operation.
8. Exclusive NOR: The Exclusive NOR operation performs a bitwise comparison
between two registers. It produces an output of 1 when the corresponding bits
are the same and 0 when they are different.
9. Complement B: Complement B inverts all the bits in register B. It changes 1s to
0s and 0s to 1s. This is for performing negation or generating the complement of
the data.
10. Complement A: The Complement A operation inverts all the bits in register A. It
changes 1s to 0s and 0s to 1s.
11. NAND: The NAND logic micro-operation performs a bitwise AND operation
between two registers and then negates the result. The output bit is 0 only if both
input bits are 1. Otherwise, the output is 1. It’s the inverse of the AND operation.
Set to all 1’s: operation sets all the bits in a register to 1. This is used to initialize a
register.
Implementing logic micro-operations in hardware involves using logic gates for each bit
or pair of bits in the registers to carry out the desired logic function. Although there are
16 possible logic micro-operations, most computers rely on just four: AND, OR, XOR
Hardware Implementation
Logic Diagram of Hardware Implementation of Logic Circuit
The hardware implementation, as shown in the diagram, consists of a single stage that
generates the four basic logic micro-operations. It uses four logic gates and a
multiplexer. Each gate performs one of the required logic functions: AND, OR, XOR, or
NOT. Their outputs are fed into the multiplexer’s data inputs.
The multiplexer then uses two selection inputs, S1 and S0, to choose which data input
to pass to the output. This configuration represents one stage, and for a circuit handling
n bits, this setup would be replicated n times to accommodate all the bits.
compression algorithms.
secure data encryption and decryption. Similarly, in image processing, they are used to
2. Machine Learning
Logic micro-operations are used in machine learning algorithms to manipulate data and
make decisions based on patterns in the dataset. These operations are crucial for tasks
like image recognition, voice recognition, and natural language processing, where fast
3. Arithmetic Circuits
adders and subtracters. They combine XOR, AND, and OR operations to perform key
Conclusion
In conclusion, understanding logic micro-operations is crucial for anyone pursuing a
career in software engineering or related fields. These fundamental operations form the
backbone of data manipulation, optimization, and efficient system design. A solid grasp
of logic micro operations is important for technical expertise and also ensures your job-
Now, to implement the micro operation, the contents of specified registers are
allocated in the inputs of the common Arithmetic Logic Unit. The Arithmetic
Logic Unit performs an operation that leads as a result and gets transferred to
a destination register. Arithmetic Logic Unit may be a combinatory circuit in
order that the complete register transfer operation from the supply registers
through the ALU and into the destination register is performed throughout one
clock pulse amount. Sometimes, the shift micro operations are performed in a
separate unit, but sometimes it is made as a part of full ALU.
One stage of ALSU
We can combine and make one ALU with common selection variables by
adding arithmetic, logic, and shift circuits. We can see the, One stage of an
arithmetic logic shift unit in the diagram above. Some particular micro
operations are selected through the inputs S1 and S0.
The circuit whose one stage is given in the below diagram provides 8
arithmetic operations, 4 logic operations, and 2 shift operations, and Each
operation is selected by the 5 variables S3, S2, S1, S0, and Cin.
The below table shows the 14 operations perform by the Arithmetic Logic Unit: