0% found this document useful (0 votes)
18 views

Computer Architecture & Organization

MSC 5th Semester notes

Uploaded by

Izhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Computer Architecture & Organization

MSC 5th Semester notes

Uploaded by

Izhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 111

Computer Architecture &

Organization

An Introduction

Instructor: Siddiqa Ajmal


Outline
 About this Course
 Basic Structure of Computer
 What is Computer Organization?

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

 Structure is the way in which components relate to each


other

5
Difference in Peripherals & Communication
Lines

 When data is received from or delivered by a device that is


directly connected to the computer, process is called Input-
Output (I/O).
 When data are moved over longer distance, to or from a
remote device, the process is known as Data
Communication.

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:

 CPU: controls the operation of the computer and performs its


data processing functions; often referred as processor.
 Main Memory: stores data
 I/O: moves data between the computer and its external
environment.
 System Interconnections: Mechanism for communication
among CPU, memory, and I/O.

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.

 Example: Architectural design issue whether a computer will


have multiply instruction or not.

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.

 It is possible to have same architecture but different


organizations.
 All computers in the Intel Pentium series have the same architecture.
 Each version of the Pentium has a different organization or
implementation.

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.

 A value of each digit in a number can be determined using


 The digit
 The position of the digit in the number
 The base of the number system (where base is defined as
the total number of digits available in the number system).

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.

 Converting Binary to Hexadecimal


 Begin at the rightmost 4 bits. If there are not 4 bits, pad 0s to the left until you hit 4.
Repeat the steps until all groups have been converted.

 Converting Octal to Binary


 Given an octal number, simply convert each digit to
it’s binary equivalent. Then, combine each 3 bit binary
number and that is the resulting answer.

 13Converting Binary to Octal


Binary Arithmetic Operations
 Addition
 Like decimal numbers, two numbers can be added by adding
each pair of digits together with carry propagation.

11001 647
+ 10011 + 537
101100 1184

Binary Addition Decimal Addition

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

Binary Subtraction Decimal Subtraction

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

 In computing, the most significant bit (msb) is the bit


position in a binary number having the greatest value. The
msb is sometimes referred to as the left-most bit.

 In computing, the least significant bit (lsb) is the bit


position in a binary integer giving the units value, that is,
determining whether the number is even or odd. The lsb
is sometimes referred to as the right-most bit.

18
Unsigned Integers

 An unsigned integer is an integer that represent a


magnitude, so it is never negative.

 Unsigned integers are appropriate for representing


quantities that can be never negative.

19
Signed Integers

 A signed integer can be positive or negative.


 The most significant bit is reserved for the sign:
 1 means negative and 0 means positive.

 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)

00001100 (decimal 12)


+ 11111011 (decimal -5)
00000111 (decimal 7)

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)

0101 1010 1011 1100 (Binary 5ABCh)


+ 1101 1110 0000 0100 (1’s Complement of 21FCh)
10011 1000 1100 0000

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.

Binary Decimal Hexadecimal Binary Decimal Hexadecimal

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

ASCII Representation of “123” and 123

'1' '2' '3'


"1 2 3" = 00110001 00110010 00110011

123
123 = 01111011

32
Computer Architecture &
Organization

3 – Register & Memory


Outline
 The Components of Microcomputer System
 The CPU
 Registers
 Memory
 Types: RAM, ROM, Cache
 Memory Organization & Segmentation
 System Bus
 Data, Address & Control

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)

AX, BX, CX and DX are two


bytes wide and each byte can
be accessed separately

These registers are used as


memory pointers.

6 status; 3 control ; 7 unused

Segment registers are used


as base address for a segment
11
General Purpose/Data Registers
 Following four registers are available to the programmer for general data
manipulation:
 AX (Accumulator): Used in arithmetic, logic and data transfer
instructions. Also required in multiplication, division and input/output
operations.
 BX (Base): It can hold a memory address that points to a variable.
 CX (Counter): Act as a counter for repeating or looping instructions.
These instructions automatically repeat and decrement CX and quit
when equals to 0.
 DX (Data): It has a special role in multiply and divide operations. Also
used in input/output operations.

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

❑ Each 1 or 0 is called a bit.


❑ Group of 4 bits = Nibble
❑ Group of 8 bits = Byte
❑ Group of 16 bits = Word
❑ Group of 32 bits = Double words

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

 Devices that provide backup storage are called auxiliary


memory

 The main memory occupies a central position by being able to


communicate directly with the CPU and with auxiliary
memory devices through an I/O processor

 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

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.

 Each byte is identified by a number – Address


 Number of bits in an address depends on the processor
 Example:- Intel 8086: 20-bit address, Intel 80286: 24-bit
address

 Data stored in a memory byte – Contents

25
Contd..
 Number of bits used in the address determines the number of
bytes that can be accessed by the processor.

 Example: If processor uses 20-bit address, it can access 220 =


1048576 bytes = 1 MB of memory

 Question: If processor uses 24-bit address, how many bytes


of memory can be accessed?

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:

a. The offset address if the segment number is 40FFh.


b. The segment number if the offset address is 123Bh.

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

CPU Memory I/O

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

Instructor: Siddiqa Ajmal


Outline
 Basic Operational Concepts
 Processor Clock
 Instruction Representation
 Instruction Cycle

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

Figure: A Simple Instruction Format

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.

Rising Edge Falling Edge

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

Data from Memory Memory


Microprocessor

Figure: Reading from memory


12
Basic Instruction Cycle
 Fetch → Decode → Execute
 Fetch
1. Fetch an instruction from memory
2. Decode the instruction to determine the operation
3. Fetch data from memory if necessary
 Execute
4. Perform the operation on the data
5. Store the result in memory if needed

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

 Fetch the instruction from the memory


 Increment the Program Counter
 Unless told otherwise

 Instruction loaded into Instruction Register (IR)


 Decode the type of instruction
 Fetch the operands
 Execute the instruction
 Store the results

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

store the output

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

You might also like