Computer Architecture & Organization
Computer Architecture & Organization
Organization
An Introduction
2
Course Objectives
To understand architecture of a computer system
To gain an insight knowledge about the internal architecture and
working of microprocessors.
To understand working of memory devices, interrupt controllers and
I/O devices.
To understand organization of a computer system
3
Basic Structure & Function –
Computer System
Structure
5
Difference in Peripherals & Communication
Lines
6
Structure - Top Level
Peripherals Computer
Central Main
Processing Memory
Unit
Computer
Systems
Interconnection
Input
Output
Communication
lines
7
Structure – Top Level Contd..
Four main structural components:
8
Structure - The CPU
CPU
Computer Arithmetic
Registers and
I/O Login Unit
System CPU
Bus
Internal CPU
Memory Interconnection
Control
Unit
9
Structure – The CPU
Control Unit: controls the operation of CPU and hence the
computer.
Arithmetic and logic unit: performs the computer’s data
processing functions.
Registers: provides storage internal to CPU.
CPU interconnection: Mechanism that provides for
communication among the control unit, ALU, and registers.
10
Function
Function is the operation of individual components as part
of the structure.
Main functions performed by a computer system are:
Process Data
Store Data
Move Data
Control the above three functions
11
Functional View of Computer
12
Possible Operations
Data movement device Data storage device (read/write)
13
Possible Operations Contd..
Processing on data stored in storage or in external environment
14
Assignment 1
Write down the difference between computer
architecture and computer organization. (maz. 2 pages
assignment (hand written))
15
Computer Architecture
Computer Architecture refers to those attributes of a system
visible to a programmer
Those attributes that have direct impact on logical execution of a
program.
Architectural attributes include:
the instruction set,
no. of bits used to represent various data types (numbers, characters
etc),
I/O mechanisms and technology for addressing memory.
16
What is Computer Organization?
Organization is how features are implemented.
How does a Computer Work?
For Example: Is there a special hardware multiply unit for
multiplication operation or is it done by repeated addition?
Computer Organization refers to the operational units and their
interconnections that realize the architectural specifications.
Organizational attributes:
hardware details transparent to the programmer such as control
signals,
interfaces between peripherals and the computer,
the memory technology used.
17
Computer Organization vs. Architecture
Architecture:
Logical aspects of computer hardware that are visible to the
programmer
What instruction a computer understands!
Organization:
Physical aspects of computer hardware that are invisible to the
programmer
How does the computer hardware carries out instructions!
18
Computer Organization vs. Architecture
Contd..
Computer Organization must be designed to implement a
particular architectural specifications.
19
Computer Architecture &
Organization
Data Representation
Number System
Any number system using a range of digits that represents a
specific number. The most common numbering systems are
decimal, binary, octal, and hexadecimal.
Numbers are important to computers
represent information precisely
can be processed
For example:
to represent yes or no: use 0 for no and 1 for yes
to represent 4 seasons: 0 (autumn),1 (winter),2(spring) and 3 (summer)
2
Positional Number System
A computer can understand positional number system where
there are only a few symbols called digits and these symbols
represent different values depending on the position they
occupy in the number.
3
Decimal Number System
4
Binary Number System
5
Hexadecimal Number System
6
Conversion Between Number Systems
Converting Hexadecimal to Decimal
Multiply each digit of the hexadecimal number from right to
left with its corresponding power of 16.
Convert the Hexadecimal number 82ADh to decimal number.
7
Conversion Between Number Systems
Converting Binary to Decimal
Multiply each digit of the binary number from right to
left with its corresponding power of 2.
Convert the Binary number 11101 to decimal
number.
8
Converting octal to decimal
Rule:
Multiply each digit of the octal number from right to left with
its corresponding power of 8.
Example: 75477
9
Conversion Between Number Systems
Converting Decimal to Binary
Divide the decimal number by 2.
Take the remainder and record it on the side.
REPEAT UNTIL the decimal number cannot be
divided into anymore.
10
Converting Decimal to Octal
Divide the decimal number by 8.
Take the remainder and record it on
the side.
REPEAT UNTIL the decimal number
cannot be divided into anymore.
11
Conversion Between Number Systems
Converting Decimal to Hexadecimal
Divide the decimal number by 16.
Take the remainder and record it on the side.
REPEAT UNTIL the decimal number cannot be
divided into anymore.
12
Conversion Between Number Systems
Converting Hexadecimal to Binary
Given a hexadecimal number, simply convert each digit to it’s binary equivalent.
Then, combine each 4 bit binary number and that is the resulting answer.
11001 647
+ 10011 + 537
101100 1184
14
Binary Arithmetic Operations
Subtraction
Two numbers can be subtracted by subtracting each pair of
digits together with borrowing, where needed.
11001 627
- 10011 - 537
00110 090
15
Hexadecimal Arithmetic Operations
Addition
Like decimal numbers, two numbers can be added by adding
each pair of digits together with carry propagation.
5B39
+ 7AF4
D62D
Hexadecimal Addition
16
HexaDecimal Arithmetic Operations
Subtraction
Two numbers can be subtracted by subtracting each pair of
digits together with borrowing, where needed.
D26F
- BA94
17DB
Hexadecimal Subtraction
17
MSB and LSB
18
Unsigned Integers
19
Signed Integers
Example:
00001010 = decimal 10
10001010 = decimal -10
20
One’s Complement
The one’s complement of an integer is obtained by
complementing each bit, that is, replace each 0 by a 1 and
each 1 by a 0.
21
2’s Complement
Negative integers are stored in computer using 2’s
complement.
To get a two’s complement by first finding the one’s
complement, and then by adding 1 to it.
Example
11110011 (one's complement of 12)
+ 00000001 (decimal 1)
11110100 (two's complement of 12)
22
Subtract as 2’s Complement Addition
Find the difference of 12 – 5 using complementation and
addition.
00000101 (decimal 5)
11111011 (2’s Complement of 5)
No Carry
23
Example
Find the difference of 5ABCh – 21FCh using
complementation and addition.
5ABCh = 0101 1010 1011 1100
21FCh = 0010 0001 1111 1100
1101 1110 0000 0100 (2’s Complement of 21FCh)
Discard
Carry
24
Decimal Interpretation
How to interpret the contents of a byte or word as a
signed and unsigned decimal integer?
Unsigned decimal interpretation
Simply just do a binary to decimal conversion or first convert
binary to hexadecimal and then convert hexadecimal to
decimal.
Signed decimal interpretation
If msb is zero then number is positive and signed decimal is
same as unsigned decimal.
If msb is one then number is negative, so call it -N. To find N,
just take the 2’s complement and then convert to decimal.
25
Example
Give unsigned and signed decimal interpretation FE0Ch.
Unsigned decimal interpretation
163 ∗ 15 + 162 ∗ 14 + 161 ∗ 0 + 160 ∗ 12 = 61440 +
3584 + 0 + 12 = 65036
Signed decimal interpretation
FE0Ch = 1111 1110 0000 1100 (msb is 1, so number is
negative).
To find N, get its 2’s complement
0000 0001 1111 0011 (1’s complement of FE0Ch)
+ 1
N = 0000 0001 1111 0100 = 01F4h = 500
So, -N = 500
26
Decimal Interpretation
For 16 – bit word, following relationships holds between
signed and unsigned decimal interpretation
From 0000h – 7FFFh, signed decimal = unsigned decimal
From 8000h – FFFFh, signed decimal = unsigned decimal –
65536.
Example:
Unsigned interpretation of FE0Ch is 65036.
Signed interpretation of FE0Ch = 65036 – 65536 = -500.
27
Binary, Decimal, and Hexadecimal Equivalents.
0000 0 0 1000 8 8
0001 1 1 1001 9 9
0010 2 2 1010 10 A
0011 3 3 1011 11 B
0100 4 4 1100 12 C
0101 5 5 1101 13 D
0110 6 6 1110 14 E
0111 7 7 1111 15 F
Character Representation
All data, characters must be coded in binary to be
processed by the computer.
ASCII:
American Standard Code for Information Interchange
Most popular character encoding scheme.
Uses 7 bit to code each character.
27 = 128 ASCII codes.
Single character Code = One Byte [7 bits: char code, 8 th bit set
to zero]
32 to 126 ASCII codes: printable
0 to 31 and 127 ASCII codes: Control characters
29
30
How to Convert?
If a byte contains the ASCII code of an uppercase letter,
what hex should be added to it to convert to lower case?
Solution: 20 h
Example: A (41h) a (61 h)
If a byte contains the ASCII code of a decimal digit, What
hex should be subtracted from the byte to convert it to
the numerical form of the characters?
Solution: 30 h
Example: 2 (32 h)
31
Character Storage
123
123 = 01111011
32
Computer Architecture &
Organization
2
The CPU
CPU
Brain of Computer; controls all operations
Uses Memory Circuits to store information
Uses I/O Circuits to communicate with I/O Devices
Executes programs stored in memory
System programs
Application programs
Instruction Set: Instructions performed by CPU
Two main components:
Execution Unit (EU)
Bus Interface Unit (BIU)
4
Execution Unit (EU)
Purpose: Execute instructions
Contains ALU (Arithmetic & Logic Unit)
To perform arithmetic (+, -, x,/) and logic (AND, OR, NOT)
operations.
The data for the operations are stored in circuits called
Registers.
A register is like a memory location except that it is referred
by a name not a number (address).
EU uses registers for:
Storing data.
Holding operands for ALU
To reflect result of a computation – FLAG register
5
Bus Interface Unit (BIU)
Facilitates communication between the EU and the memory or
I/O circuits.
Responsible for transmitting address, data and control signals
on the buses.
6
Internal Bus
The EU and BIU are connected by an internal bus and they
work together.
While EU is executing, the BIU fetches up to six bytes of the
next instruction and places them in the instruction queue.
Instruction Pre-fetch
Purpose: Speed up the processor
If the EU needs to communicate with memory or the
peripherals, the BIU suspends instruction pre-fetch and
performs the needed operations.
7
8
Intel 8086 Microprocessor Organization
Registers
Registers
Registers are high-speed storage locations inside the
microprocessor.
Designed to be accessed at much higher speed than
conventional memory.
Registers are classified according to the functions they perform.
General Types of Registers:
Data Registers: To hold data for an operation.
Address Registers:To hold the address of an instruction or data.
Status/Flag Register: keeps the current status of the processor or
result of an arithmetic operation.
10
8086 Internal registers 16 bits (2 bytes each)
12
Segment Registers
Store addresses of instruction and data in memory.
These values are used by the processor to access memory locations.
CS (Code): Defines the starting address of the section of memory
holding code.
DS (Data): Defines the section of memory that holds most of the data
used by programs.
ES (Extra): This is an additional data segment that is used by some of
the string instructions.
SS (Stack): It defines the area of the memory used for stack
13
Pointers and Index Registers
These can be accessed only as 16 bit registers.
IP - instruction pointer: Always points to next instruction to be
executed. IP register always works together with CS segment register
and it points to currently executing instruction.
SI - source index register: This is source index register which is used
to point to memory locations in the data segment addressed by DS. Thus
when we increment the contents of SI, we can easily access consecutive
memory locations.
DI - destination index register: This is destination index register
performs the same function as SI. There is a class of instructions called
string operations, that use DI to access the memory locations addressed
by ES.
SI and DI used in string movement instructions.
SP and BP are used to access data inside the stack segment
14
80386 Extended Registers
The 80386/80486 processor contain 32-bit registers which
greatly improve the efficiency of program that take advantage
of them.
EAX, EBX, ECX, EDX,
EFLAGS
EIP
EBP, ESP, ESI, EDI.
15
Memory
Bits, Bytes and Double words
byte byte
0 0 1 0 0 1 1 0 0 1 1 0 1 01 0
word
17
Common Prefixes
18
Memory
Information processed by the computer is stored in its
memory.
Program
Data
Not all accumulated information is needed by the CPU at the
same time
Therefore, it is more economical to use low-cost storage devices to
serve as a backup for storing the information that is not currently
used by CPU
Memory Operations:
Read (Fetch contents of a location)
Write (Store data at a location)
19
Memory Hierarchy
20
Contd..
The memory unit that directly communicate with CPU is
called the main memory
21
Contd..
22
Main Memory
Most of the main memory in a general purpose computer is
made up of RAM integrated circuits chips, but a portion of the
memory may be constructed with ROM chips
Memory Circuits:
RAM
Program Data and Instructions
Read and Write
ROM
Used for storing an initial program called bootstrap loader, which is
required to start the computer software operating when power is
turned off.
Only Read
23
Cache
A special very-high-speed memory called cache is used to
increase the speed of processing by making current programs
and data available to the CPU at a rapid rate.
To reduce memory access time thus program execution time.
24
Memory Organization
Memory is organized into a collection of bytes.
25
Contd..
Number of bits used in the address determines the number of
bytes that can be accessed by the processor.
26
Memory Segments
A memory segment is a block of 216 (or 64 K)
consecutive memory bytes.
Each segment has a number.
Within a segment, memory location is specified by an
offset. This is the number of bytes from the beginning of
the segment.
27
F0000
E0000
D0000
C0000
B0000
A0000 8000:FFFF
90000
One Segment
80000
70000 8000:0000
60000
50000
segment of f set
40000
30000
20000
10000
00000
28
Segment : Offset Address
Logical Address = Segment : Offset
16-bit segment, 16-bit offset
Physical Address = Segment * 10h + Offset
20-bit address
Example:
Logical Address = A4FB:4872
Physical Address = A4FB0h + 4872h = 0A9822h
29
Exercise
A memory location has a physical address 4A37Bh.
Compute:
30
Program Segments
A typical machine language program is loaded into
following different memory segments:
Code Segment
Data Segment
Stack Segment
Stack is a data structure used by processor to implement
procedure calls.
31
System Bus
What is a Bus?
A communication pathway connecting two or more devices
Often grouped
A number of channels in one bus
e.g. 32 bit data bus is 32 separate single bit channels
Address Bus
Control Bus
33
Data Bus
Data Bus
Carries data
Remember that there is no difference between “data” and
“instruction” at this level
Width is a key determinant of performance
8, 16, 32, 64 bit
34
Address bus
Identify the source or destination of data
e.g. CPU needs to read an instruction (data) from a given location
in memory
Address Bus width determines how much memory the
CPU can address directly.
e.g. 8080 has 16 bit address bus giving 64k address space
35
Control Bus
Control and timing information
Memory read/write signal
Interrupt request
Clock signals
36
Types of Transfer
Memory to Processor
Processor to Memory
I/O to Processor
Processor to I/O
I/O to and from Memory
37
Interconnection Structure
Memory
N words of equal length, each word having a unique address
Unit of Transfer (read/Write):Word
Operation: Read/Write indicated by Control Signal
Location of operation specified by an address
I/O Module
Two operations: read and write
May control other external devices
Port: interface between I/O module and device
Able to send interrupt signal to CPU
38
Contd..
CPU
Reads in instruction and data
Writes out data
Uses control signal to control all operations
Receives interrupt signal
39
Address
Data Read
Data Write
Interrupt Signals
40
Computer Architecture &
Organization
Processor Basics
2
Basic Operational Concepts
Machine Instruction Elements
Each instruction must have elements that contain the
information required by the CPU for execution.
These elements can be:
Operation code: Specifies the operation to be performed (e.g..
ADD, I/O). The operation is specified by a binary code, known as the
operation code, or opcode.
Source operand reference: The operation may involve one or
more source operands, that is, operands that are inputs for the
operation.
Result operand reference: The operation may produce a result.
Also called destination operand.
Next instruction reference: This tells the CPU where to fetch the
next instruction.
4
Instruction Representation
Within the computer, each instruction is represented by a
sequence of bits.
16 bits instruction
4 bit opcode, 6 bit operand 1, 6 bit operand 2
4 bit opcode, 12 bit operand
32 bits instruction
64 bits instruction
5
Contd..
Binary representations of machine instructions is difficult to
remember.
Use a symbolic representation of machine instructions.
Opcodes are represented by abbreviations, called mnemonics,
that indicate the operation. Common examples include:
6
Instruction Types
Data processing: Arithmetic and logic instructions
Data storage: Memory instructions
Data movement: I/O instructions
Transfer of Control
7
No. of Addresses in an Instruction
Three addresses
Operand 1, operand 2, result
Two addresses
Source
Destination
One addresses
Source or Destination
Zero address
Zero-address instructions are applicable to a special memory
organization, called a Stack. A stack is a last-in-first-out set of
locations.
8
Types of Operands
Machine instructions operate on data.
The most important general categories of data are:
Addresses
Numbers
Characters
Logical data
9
Basic Operations – Processor
Execute the software by fetching instruction from memory
Look for any external signal and react accordingly
Input signals from keyboard or mouse etc.
10
Processor Clock
Heart of any processor
Simple digital signals at equal time intervals
Alternate On Off states
All activity within the CPU is synchronized with the edges
(rising or falling) of this clock signal.
11
Program Counter (Binary Counter)
With every falling edge or rising edge (depending upon processor) of clock
signal, the counter is incremented by one.
Width varies from processor to processor
The contents of PC are used as target address for the memory area
Control Memory
Read
Unit (CU)
Read
PC Address
Memory address
Data Buffer Data
13
Contd..
Internal CPU Registers used in instruction cycle:
Program Counter (PC) = Address of instruction
Instruction Register (IR) = Instruction being executed
Accumulator (AC) = Temporary Storage
14
Computer Components: Top Level View Contd..
15
Detailed Steps
Address in the Program Counter register
Program Counter (PC) holds address of next instruction to fetch
16
Example Program Execution
17
Instruction Execution Cycle
PC Program (RAM)
I-1 I-2 I-3 I-4
fetch
op1
Data op2 registers I-1
(RAM) Instruction
Queue
decode
ALU
execute
18
Instruction Cycle State Diagram
19
Contd..
Instruction Fetch
Read instruction from memory into processor
Instruction Operation Decoding
Determine the type of operation to be performed and operand(s) to
be used.
Operand Address Calculation
If operation involves reference to an operand in memory or I/O, then
determine the address of operand.
Operand Fetch
Fetch from memory or read from I/O
Data Operation
Perform the operation
Operand Store
Write into memory or out to I/O if required
20