Mod 1
Mod 1
Dr. C.R.Dhivyaa
Assistant Professor
School of Computer Science and Engineering
Vellore Institute of Technology, Vellore
BCSE205L - Computer Architecture and
Organization
•Course Objectives
2
BCSE205L - Computer Architecture and
Organization
•Course Outcomes
3
BCSE205L - Computer Architecture and
• Syllabus
Organization
4
BCSE205L - Computer Architecture and
Organization
• Syllabus
5
BCSE205L - Computer Architecture and
• Syllabus
Organization
6
BCSE205L - Computer Architecture and
Organization
• Text and Reference Books
7
BCSE205L - Computer Architecture and
Organization
Assessment Course Outcome Timeline Marks
method
CAT-1 As decided in As Scheduled by 15(50)
Course Committee Dean Academics
Meeting
QUIZ-1 CO2 Before CAT 2 20
CAT-2 As decided in As Scheduled by 15(50)
Course Committee Dean Academics
Meeting
Digital CO4 Before FAT 10
Assignment
FAT All Modules As Scheduled by 40(100)
Dean Academics
8
Overview of Organization and Architecture
•Computer Architecture and Computer Organization are related but distinct
concepts in the field of computer science.
•Computer Architecture
• refers to the design of the internal workings of a computer system, including
the CPU, memory, and other hardware components.
• involves decisions about the organization of the hardware, such as the
instruction set architecture, the data path design, and the control unit design.
• is concerned with optimizing the performance of a computer system and
ensuring that it can execute instructions quickly and efficiently.
9
Overview of Organization and Architecture
•Computer Architecture
• refers to those attributes of a system visible to a programmer.
• Architectural attributes includes
• Instruction set
10
Overview of Organization and Architecture
•Organizational attributes includes
• Hardware details transparent to the programmer
• Control signals
• Interfaces between the computer and peripherals
• Memory technology used
3. it deals with high-level design issues. it deals with low-level design issues.
12
Overview of Organization and Architecture
Computer Architecture Computer Organization
6. Computer Architecture is also called as Computer Organization is frequently
Instruction Set Architecture (ISA). called as micro architecture.
Computer Architecture comprises
7. logical functions such as instruction Computer Organization consists of physical
sets, registers, data types and addressing units like circuit designs, peripherals and
modes. adders.
13
Functional Components of Computer
• Input Unit
• Output Unit
• Memory Unit
• Central Processing Unit (CPU)
• Arithmetic and Logic Unit (ALU)
• Control Unit
• Memory Registers
Functional components of a computer
•Basic functional units of a computer – Five functionally
independent main parts. Arithmetic and logic unit(ALU):
• Performs the desired
Input unit accepts information: operations on the input
•Human operators, information as determined
•Electromechanical devices (keyboard) by instructions in the memory
•Other computers
15
Functional components of a computer
•Basic functional units of a computer – Five functionally
independent main parts.
16
Functional components of a computer
• Input Unit :
• A computer accepts the information through input device.
• Input device writes data into the memory through the data path. Some of the
common input devices are keyboard, mouse, joystick, scanner etc.
• Output Unit:
• The Output unit send the processed result to the user using output device.
• It reads the data from memory through data path.
• Some devices are monitor, printer etc.
Functional components of a computer
• Central Processing Unit (CPU) :
• Brain of the computer - control center of the computer.
• It first fetches instructions from memory and then interprets them so as to know
what is to be done.
• CPU executes or performs the required computation and then either stores the
output or displays on the output device
• Arithmetic and Logic Unit (ALU) :
• performs mathematical calculations and takes logical decisions. Arithmetic
calculations include addition, subtraction, multiplication and division
Functional components of a computer
• Central Processing Unit (CPU) :
• Control Unit :
• coordinates and controls the data flow in and out of CPU and also controls all
the operations of ALU, memory registers and also input/output units.
• It is also responsible for carrying out all the instructions stored in the program.
• It decodes the fetched instruction, interprets it and sends control signals to
input/output devices until the required operation is done properly by ALU and
memory.
Functional components of a computer
• Central Processing Unit (CPU) :
• Memory Registers :
• A register is a temporary unit of memory in the CPU. These are used to store
the data which is directly used by the processor.
• Registers can be of different sizes(16 bit, 32 bit, 64 bit and so on) and each
register inside the CPU has a specific function like storing data, storing an
instruction, storing address of a location in memory etc.
• The user registers can be used by an assembly language programmer for storing
operands, intermediate results
Functional components of a computer
• Memory Unit (MU) :
• Memory unit stores instructions and data.
• Recall, data is represented as a series of bits.
• To store data, memory unit thus stores bits.
• Processor reads instructions and reads/writes data from/to the memory during the
execution of a program.
• In theory, instructions and data could be fetched one bit at a time.
• In practice, a group of bits is fetched at a time.
• Group of bits stored or retrieved at a time is termed as “word”
• Number of bits in a word is termed as the “word length” of a computer.
• In order to read/write to and from memory, a processor should know where to look:
• “Address” is associated with each word location.
22
Functional components of a computer
• Memory Unit (MU) :
• Processor reads/writes to/from memory based on the memory address:
• Access any word location in a short and fixed amount of time based on the
address.
• Random Access Memory (RAM) provides fixed access time independent of
the location of the word.
• Access time is known as “Memory Access Time”.
• Memory and processor have to “communicate” with each other in order to
read/write information.
• In order to reduce “communication time”, a small amount of RAM (known as
Cache) is tightly coupled with the processor.
• Modern computers have three to four levels of RAM units with different speeds
and sizes:
• Fastest, smallest known as Cache
• Slowest, largest known as Main memory. 23
Memory unit (contd..)
• Primary storage is insufficient to store large amounts of data and
programs.
• Primary storage can be added, but it is expensive.
• Store large amounts of data on secondary storage devices:
• Magnetic disks and tapes,
• Optical disks (CD-ROMS).
• Access to the data stored in secondary storage in slower, but take advantage of the
fact that some information may be accessed infrequently.
• Cost of a memory unit depends on its access time, lesser access time
implies higher cost.
24
Information in a computer -- Instructions
• Instructions specify commands to:
• Transfer information within a computer (e.g., from memory to ALU)
• Transfer of information between the computer and I/O devices (e.g.,
from keyboard to computer, or computer to printer)
• Perform arithmetic and logic operations (e.g., Add two numbers,
Perform a logical AND).
25
Information in a computer -- Instructions
• A sequence of instructions to perform a task is called a program,
which is stored in the memory.
• Processor fetches instructions that make up a program from the
memory and performs the operations stated in those instructions.
• What do the instructions operate upon?
-----Data
26
Information in a computer -- Data
• Data are the “operands” upon which instructions operate.
• Data could be:
• Numbers,
• Encoded characters.
• Data, in a broad sense means any digital information.
• Computers use data that is encoded as a string of binary digits called bits.
27
How are the functional units connected?
• For a computer to achieve its operation, the functional units need to communicate with eac
other.
• In order to communicate, they need to be connected.
Bus
28
Basic Operational Concepts
•Activity in a computer is governed by instructions.
•To perform a task, an appropriate program consisting of a list
of instructions is stored in the memory.
•Individual instructions are brought from the memory into
the processor, which executes the specified operations.
•Data to be used as operands are also stored in the memory.
•Typical Instruction - Add LOCA, R0
•What is the function of Add LOCA, R0 and How does it execute!!??
31
Basic Operational Concepts
•Typical Instruction - Add LOCA, R0
• Add the operand at memory location LOCA to the operand
in a register R0 in the processor.
• Place the sum into register R0.
• The original contents of LOCA are preserved.
• The original contents of R0 is overwritten.
The instruction combines a memory access
•Steps: operation with an ALU operation.
1. Instruction is fetched from the memory into the processor.
2. The operand at LOCA is fetched and added to the contents of R0
3. The resulting sum is stored in register R0.
24
Basic Operational Concepts
•Separate Memory Access and ALU Operation
• In many modern computers, those two types of operation are performed by separate
instructions – Performance reason.
• Same instruction can be realized by the following two instruction sequence.
25
Basic Operational Concepts
•Connection between the processor and the memory
• Instruction register (IR)
• Program counter (PC)
• Memory address register (MAR)
• Memory data register (MDR)
• General-purpose register (R0 – Rn-1) are used
to store temporary data during any ongoing
operation. Its content can be accessed by
assembly programming.
26
Basic Operational Concepts
• In addition to ALU and CU circuitry, processor
has special purpose and general purpose registers
• Instruction register (IR) - Holds the instruction
that is currently being executed.
• Program counter (PC) – Holds the memory
address of the next instruction to be fetched and
executed. During the execution of an
instruction, the content of the PC are updated to
the address of the next instruction to be
executed.
27
Basic Operational Concepts
• To facilitate the communication with memory
and processor
• Memory address register (MAR) – Holds the
address of the location to be accessed.
• Memory data register (MDR) – Contains the
data to be written into or read out of the
addressed location
27
Basic Operational Concepts
Steps to Fetch Instruction from memory
1. Program - stored in memory through input unit
2. PC is set to point to the first instruction (holds the
address of the first instruction)
3. The contents of PC are transferred to MAR and Read
control signal is sent to the memory
4. The instruction in the corresponding address (MAR)
is fetched from memory and loaded into MDR.
5. The contents of MDR are transferred to IR
6. Instruction - ready for execution
37
Basic Operational Concepts
Steps to Fetch Data
• If operand is in memory, the corresponding address
should be sent to MAR – initiating Read Cycle.
• Data fetched from memory and stored in MDR , then
to ALU
• Perform operation in ALU
• Store the result back in the memory
• To general-purpose register
• To memory (address to MAR, result to MDR –
Write in memory in specified location)
• PC is incremented to fetch the next instruction
38
Registers and Register Files
Registers:
• To speed up the processor operations, the processor includes some internal
memory storage locations called registers.
• Memory hierarchy
1. Registers
2. Cache memory
3. Main memory
4. Secondary memory
• At higher level of hierarchy, memory is faster, more expensive.
• Registers are top level of hierarchy.
40
Registers and Register Files
Registers:
• Registers are temporary storage locations inside the processor circuit that hold data and
addresses.
• Some registers are used internally (by processor only) and cannot be accessed outside the
processor, while others are user-accessible.
• Most modern processor architectures include both types of registers
• Internal registers include the program counter (PC), instruction register (IR), memory
data register (MDR), and memory address register (MAR)
• The storage time of internal registers is extremely temporary, as they often hold data for
less than a millisecond
• The register file is the component that contains all the general purpose registers of the41
processor.
Registers – User Visible Registers
• Register - Two roles
• User visible registers – referenced by machine instruction – visible to the users
• Controland Status registers – employed to control the operation – Not visible to the
users
• User-Visible Registers
• General Purpose Registers
• Data Registers
• Address Registers
• Condition Codes Registers
42
Registers – User Visible Registers
• General Purpose Registers
Add R1, R0
• True GP Registers
• Registers that can contain the operand for any Opcode.
• Restricted / Dedicated GP Registers
• Used for specific operations like floating point and stack operations (dedicated
registers).
• Data Registers - Used only to hold data and cannot be employed in the calculation of
an operand address.
• Accumulators (AC) - temporary storage location which holds intermediate value in
arithmetic and logic operation results.
43
Registers – User Visible Registers
• Address Registers – devoted for particular addressing mode.
• Segment registers - holds the address of the base segment.
• Index registers – used for indexed addressing and may be auto-indexed (increment).
• Stack pointer (SP) – points to the top of the stack.
• Condition Codes (Flag) Registers
• FLAG register is the status register that contains the current state of the processor
(reflects the result of arithmetic operation).
• Machine instructions allow these bits to be read by implicit reference (No explicit call needed).
• Programmers cannot alter them.
• Example: In some machines, sub-routine calls will result in automatic saving of all user visible
registers, to be restored on return. 44
Registers – User Visible Registers
• Condition Codes (Flag) Registers
• CCR contains five flag bits – set by CPU Hardware (ALU)– to hold information about
the result of an arithmetic or logical operation instruction that has just been
executed.
• Flag Bits:
• Carry C: Set to 1 if an add operation produces a carry or a subtract
operation produces a borrow; otherwise cleared to 0.
• Overflow V: Useful only during operations on signed integers.
• Zero Z: Set to 1 if the result is 0, otherwise cleared to 0.
• Negate N: Meaningful only in signed number operations. Set to 1 if a negative
result is produced.
45
Registers – Control and Status registers
• Control and Status Registers
• Not visible to the user, May be visible in a control or operating system mode
(supervisory mode).
• Program counter (PC) holds the address of the instruction that should be executed
next.
• Instruction register(IR) holds the actual instruction to be executed.
• Memory Address Register (MAR) connects to address bus
• Memory Buffer Register (MBR) connects to data bus, feeds other registers.
46
Example of Register Organizations
47
Register Files
• A register file is an array of processor registers (Array of GP registres) in a CPU.
Dedicated read and write ports
• Implemented by way of fast static RAMs with multiple ports.
• Ordinary multi-ported SRAMs will usually read and write through the same ports.
Dedicated write port
• Example: Register file with
3 access ports
48
Register Files
• Example: Register file with 3 access ports – Logic Diagram
49
Register Files
• Example: Register file with 3 access ports – Logic Diagram
01
50
Register Files
• Example: Register file with 3 access ports – Logic Diagram
0101
0101
0101
01
0101
51
Register Files
• Example: Register file with 3 access ports – Logic Diagram
0101
0101
0101
01 10
0101
52
Register Files
• Example: Register file with 3 access ports – Logic Diagram
0110 0101
0110 0110
0101
0101 0110
01 10
0101 0110
53
Given to ALU
Register Files
• Example: Register file with 3 access ports – Logic Diagram
11
0110 0101
0110 0110
0101
0101 0110
01 10
0101 0110
54
Register Files
• Example: Register file with 3 access ports – Logic Diagram
1011 (from ALU)
11
1011
1011
0110 0101
0110 0110
0101
0101 0110
01 10
0101 0110
55
Interconnection of Components - Bus Structures
• All five functional units must be connected in
some way to form an operational system.
• There are many ways to connect different parts
inside a computer together.
• Bus
• A group of lines that serves as a connecting
path for several devices.
• Group of conducting lines that carries data,
address and control signals.
• Data Bus, Address Bus, Control Bus
56
Interconnection of Components - Bus Structures
• The simplest way to interconnect
functional units is to use single bus.
• It can support only one transfer at a
time.
• Only two units can actively use the bus
at any given time.
• Advantages: Simple, low cost,
flexibility for attaching peripheral
devices.
57
Interconnection of Components - Bus Structures
• Multiple Bus structure achieve more
concurrency in operations by allowing two
or more transfers to be carried out at the
same time.
• It provides better performance at an
increased cost and complexity.
58
Interconnection of Components - Bus Structures
• Speed Issues
•Different devices have different transfer/operate speed.
•If the speed of bus is bounded by the slowest device connected to it, the
efficiency will be very low.
•How to solve this?
•A common approach – Use buffer registers.
•Buffer registers are used to prevent a high speed processor from
being locked to a slow I/O device during a sequence of data transfer.
59
Organization of Von Neumann Machine
(IAS Computer)
• Developed by John Von Neumann in 1940 at Princeton University.
• IAS - Institute for Advanced Studies.
• The task of entering and altering programs for ENIAC was extremely tedious
• ENIAC - (Electronic Numerical Integrator And Computer) - world's first general-
purpose electronic computer - the world's first programmable computer
• Disadvantage: programming the computer was a complex, manual process that
could take days.
60
Organization of Von Neumann Machine
(IAS Computer)
• IAS computer is the father of all modern computers
• Primary concept - storing the program in memory.
• Stored program concept – program stored in the computer along with any
relevant data
• A stored program computer consists of a processing unit and an attached
memory system.
• The processing unit consists of data-path and control.
• The data-path contains registers to hold data and functional units,
such as arithmetic logic units and shifters, to operate on data. 61
Structure of Von Neumann Machine
• Numbers are represented in binary form, and each instruction is a binary code.
• Control Unit operates the IAS by fetching instructions from memory and executing them one at a time.
Von Neumann Machine
(Expanded structure of IAS)
• Basic Elements
• Processor
• Memory
• Note:
• Each word – 40 bits
• Two instructions (each 20 bits)
stored
IAS
Architecture
The control unit and the ALU contain storage locations - registers, defined
as follows:
•Memory buffer register (MBR): Contains a word to be stored in memory
or sent to the I/O unit, or is used to receive a word from memory or from
the I/O unit.
•Memory address register (MAR): Specifies the address in memory of the
word to be written from or read into the MBR.
•Instruction register (IR): Contains the 8-bit opcode instruction being
executed.
•Instruction buffer register (IBR): Employed to hold temporarily the
righthand instruction from a word in memory.
IAS
Architecture
•Program counter (PC): Contains the address of the next instruction pair to
be fetched from memory.
•Accumulator AC) and multiplier quotient (MQ): Employed to
hold temporarily operands and results of ALU operations.
For example, the result of multiplying two 40-bit numbers is an 80-bit
number – (40 bits are stored in the AC and the least significant in the MQ).
Each word – 40 bits. Hence two registers MQ and AC are used for temporarily storing 80 bits.
Then transferred to memory and stored in two consecutive 40 bit words in the memory…
Example
ACAC
=73 MQ
MEMORY
1. LOAD M(500), ADD M(501)
2. STOR M(500), (Other Ins)
.....
500. 3
501. 4
MBR
MBR
ADD MBR
LOAD =
= 34
500
500
M(501)
STOR
PC 1 PC 2
MAR 500 MAR 501
MBR 3 MBR 4
IR LOAD M(500) IR ADD M(501)
IBR ADD M(501) IBR ADD M(501) 501
IBR
Add PCPC=
Mar
MAR ← 12
=
←PC
AC 3 AC 7
PC 3 M(501)
LOAD M(500), ADD
4
PC 2 IR MAR
MAR
MAR
MAR= = 12
501
=500
=500
STOR M(500), (Other Ins)
address = 501
MAR 500 address
address
address= =2 1
= 500
MBR 7
IR STOR M(500)
IBR Other Ins
AC 7
Example
MEMORY
1. LOAD M(500), ADD M(501)
2. STOR M(500), (Other Ins)
.....
500. 3
501. 4
PC 1 PC 2
MAR 500 MAR 501
MBR 3 MBR 4
IR LOAD M(500) IR ADD M(501)
IBR ADD M(501) IBR ADD M(501)
AC 3 AC 7
PC 2
MAR 500
500 7
MBR 7
IR STOR M(500)
IBR Other Ins
AC 7
IAS Architecture
Register transfer operation for addition operation
1. LOAD M(500), ADD M(501) 2.STOR M(500), Other Instructions
Register transfer operations: (PC = 1)
MAR ← PC
MBR ← M[MAR]
IBR ← MBR[20:39]
IR ← MBR[0:7]
MAR ← MBR[8:19]
MBR ← M[MAR]
AC ← MBR
IR ← IBR[0:7]
MAR ← IBR[8:19]
PC PC+1
MBR ← M[MAR]
AC ← AC + MBR
IAS Instructions
The IAS computer had a total of 21 instructions grouped as follows:
• Data transfer: Move data between memory and ALU registers or between
two ALU registers.
• Unconditional branch: Normally, the control unit executes instructions in
Sequence from memory. This sequence can be changed by a branch
instruction, which facilitates repetitive operations.
•Conditional branch: The branch can be made dependent on a
condition, thus allowing decision points.
•Arithmetic: Operations performed by the ALU.
•Address modify: Permits addresses to be computed in the ALU and then
inserted into instructions stored in memory.
Problems
1. Write an appropriate assembly language code for the following operation and interpret
to Von Neumann IAS architecture. (Assume that data variables ‘Y’ & ‘Z’ available at
memory locations 801 & 802 respectively. And X will be stored 803 onwards.)
X=Y*Z
Solution
LOAD MQ, M(801) MQM[801] Note: The result of multiplying two 40-bit numbers is an
80-bit number;
MUL M(802) ACMQ * M[802]
STOR M(803) M[803]AC 40 MSB are stored in the AC and the 40 least significant bits
are stored in the MQ.
LOAD MQ ACMQ
They are then transferred to Memory and stored in two
STOR M(804) M[804]AC
consecutive 40 bit word.
Problems
2.Write an ALP for the given expression using Von Neumann instruction set and
write the register transfer notation for the same. Assume that B,C and D are available
in the memory locations 450, 451 and 452 respectively.
A= (B+ C)*D
3.Write an ALP for the given expression using Von Neumann instruction set and
write the register transfer notation for the same. Assume that A, B and X are
X = A + B/2
Problems
4.Write an ALP for the given expression using Von Neumann instruction set and
write the register transfer notation for the same. Assume that B, C, D and Z are available
Memory Single memory for instructions and data Separate memory for instructions and data
CPU accesses instructions and data through a CPU accesses instruction and data memory spaces
Access
shared bus separately
Easier to modify programs as instructions and More difficult to modify programs that require the
Modification
data are stored in the same memory CPU to modify its own code
Easy to share data between different parts of a More difficult to share data between different
Data sharing
program parts of a program
• While the CPU executes from cache, it acts as a pure Harvard machine.
• When accessing backing memory, it acts like a von Neumann machine.
RISC Characteristics
• RISC stands for Reduced Instruction Set • It has simpler instructions and thus
Computer Processor simple instruction decoding.
• It is a microprocessor architecture with a • More general-purpose registers.
simple collection and highly customized • The instruction takes one clock cycle in
set of instructions. order to get executed.
• It is built to minimize the instruction • The instruction comes under the size of
execution time by optimizing and a single word.
limiting the number of instructions. • Pipeline can be easily achieved.
• Few data types.
• Simpler addressing modes
RISC Architecture
• Hardware of RISC architecture is designed to execute
the instruction quickly - because of the more precise and
smaller number of instructions and a large number of
CPU
registers.
• Data path - store and manipulate data in a computer.
• responsible for managing data within the processor and
its movement between the processor and the memory.
• Cache - to reduce the access time to the main memory.
• Instruction cache - for retrieving and storing the data of
frequently used instructions - speeds up the process of
instruction execution.
• Data cache - provides storage for frequently used data
from the main memory.
CISC Architecture
CISC Characteristics
• Instructions are complex, and thus it has
• CISC Stands for Complex Instruction
complex instruction decoding.
Set Computer, developed by the Intel.
• Instructions may take more than one clock
• has a large collection of complex
cycle in order to get executed.
instructions that range from simple to
• Instruction is larger than one-word size.
very complex. • Lesser general-purpose registers since the
• specialized in the assembly language operations get performed only in the memory.
level, which takes a long time to • More data types.
execute the instructions. • Complex addressing modes.
CISC Architecture
• Cache memory - for holding both data and instructions.
• Thus, they share the same path for both instructions and
data.
• Instructions with variable length format - Thus, the number
of clock cycles required to execute the instructions may be
varied.
• Microprogram control unit - uses a series of microinstructions
of the microprogram stored in the “control memory” of the
microprogram control unit and generate the control signals.
• Control units - access the control signals produced by the
microprogram control unit & operate the functioning of
processors hardware.
RISC and CISC Architecture
Example: A= B+C