UNIT1
COMPUTER ORGANIZATION AND
ARCHITECTURE(CSEN2011)
Prof Srinivas Prasad
1
Text/Reference Books
TextBooks:
1. M. Morris Mano, Computer System
Architecture, 3/e, Pearson education,
2008
References:
1. Carl Hamacher, Zvonko Vranesic,
Safwat Zaky, Computer Organization,5/e,
McGraw Hill,2001
2. John P. Hayes, Computer Architecture
and Organization, 3/e, McGraw Hill,
1998.
3. William Stallings, Computer
Organization and Architecture, 6/e,
Pearson PHI, 2012.
2
2
– Computer performance has been
increasing phenomenally over the last
five decades.
– Brought out by Moore’s Law:
● Transistors per square inch roughly double
every eighteen months.
– Moore’s law is not exactly a law:
● But, has held good for nearly 50 years.
3
Classification of Software
● Two broad categories:
1. Application Software
● Used to solve a specific problem.
● Editor, financial accounting, weather
forecasting, etc.
2. System Software
● Helps in running other programs.
● Compiler, operating system, etc.
4
4
Software
● A set of instructions that tells the computer
what to do
● Two main types of software
– Application software(Application Software
includes programs that do real work for user)
– System software(controls the hardware so that
application software can perform a task)
5
System Software
Application Software
5
Computer Languages
● Machine Language
– Expressed in binary.
– Directly understood by the computer.
– Not portable; varies from one
machine type to another.
● Program written for one type of machine
will not run on another.
– Difficult to use in writing programs.
6
6
Assembly Language
● Mnemonic form of machine language.
– Easier to use as compared to machine language.
● For example, use “ADD” instead of “10110100”.
– Not portable (like machine language).
– Requires a translator program called assembler.
Assembly Machine
language Assembler language
program program
7
7
Contd.
● Assembly language is also
difficult to use in writing
programs.
– Requires many instructions to solve
a problem.
● Example: Find the average of
three numbers.
MOV A,X ; A=X
ADD A,Y ; A=A+Y In C,
ADD A,Z ; A=A+Z
DIV A,3 ; A=A/3 RES = (X + Y + Z) / 3
MOV RES,A ; RES = A
8
High-Level Language
● Machine language and assembly language are called low-level languages.
– They are closer to the machine.
– Difficult to use.
● High-level languages are easier to use.
– They are closer to the programmer.
– Examples:
● Fortran, Cobol, C, C++, Java.
– Requires an elaborate process of translation.
● Using a software called compiler.
– They are portable across platforms.
9
What is a Computer?
It is a machine which can accept data, process them,
and output results.
Central
Input Processing Output
Device Unit Device
(CPU)
Inside
Main Memory
the Box
Storage (Hard disk)
Programming and Data Structures 10
10
● Input Device
– Keyboard, Mouse, Scanner, Digital Camera
● Output Device
– Monitor, Printer
● Storage Peripherals
– Magnetic Disks: hard disk, floppy disk
● Allows direct access
– Optical Disks: CDROM, CD-RW, DVD
● Allows direct access
– Flash Memory: pen drives
● Allows direct access
– Magnetic Tape: DAT
● Only sequential access
11
11
Basics of Bus
12
Structure - Top Level
Peripherals Computer
Central Main
Processing Memory
Unit
Computer
Systems
Interconnection
Input
Output
Communication
lines
13
Structure - The CPU
CPU
Computer Arithmetic
Registers and
I/O
Login Unit
System CPU
Bus
Internal CPU
Memory Interconnection
Control
Unit
14
Structure - The Control Unit
Control Unit
CPU
Sequencing
ALU Login
Control
Internal
Unit
Bus
Control Unit
Registers Registers and
Decoders
Control
Memory
15
Von Neumann architecture
16
How does a computer work?
● Main difference with a calculator.
– Stored program concept.
● What is a program?
– Set of instructions for carrying out a specific task.
● Where are programs stored?
– In secondary memory, when first created.
– Brought into main memory, during execution.
● Question: How are numbers stored internally ?
17
17
Digital Computers use Binary
Numbers!
● A digital computer is built out of tiny
electronic switches.
– For ease of manufacturing and reliability,
switches can be in one of two states, ON
and OFF.
– Switch can represent 0 and 1 (a digit in
the binary number system).
● A computer works based on the binary
number system. 18
18
Number System :: The Basics
● We are accustomed to using the so-called decimal number
system.
– Ten digits :: 0,1,2,3,4,5,6,7,8,9
– Every digit position has a weight which is a power of 10
(Called PV).
● Example:
– 234 = 2 x 102 + 3 x 101 + 4 x 100
250.67 = 2 x 102 + 5 x 101 + 0 x 100 +
6 x 10-1 + 7 x 10-2
19
19
Common Number Systems
Used by Used in
System Base Symbols humans? computers?
Decimal Yes No
10 0, 1, … 9
Binary No
2 0, 1 Yes
Octal No
8 0, 1, … 7 No
Hexa- No
decimal 16 0, 1, … 9, No
A, B, … F
20
Architecture vs. Organization
● Architecture:
– Also known as Instruction Set Architecture
(ISA)
– Programmer visible part of a processor:
instruction set, registers, addressing modes,
etc.
● Organization:
– High-level design: How many caches? How
many arithmetic and logic units? What type
of pipelining, control design, etc.
– Sometimes known as micro-architecture. 21
Basic building blocks of a CPU
22
Cont…
23
Basic processor architecture
Address of the memory
location to be accessed
Memory
Address of the next Data to be read into or
instruction to be fetched read out of the current
and executed. location
MAR/AR MDR/DR
Control
PC R0
R1 General purpose
IR registers
ALU
Instruction that is R(n-1)
currently being
-
n general purpose
executed registers Processor
24
24
Register Transfer and Micro
operations
25
REGISTER TRANSFER AND MICROOPERATIONS
• Register Transfer Language
• Register Transfer
• Bus and Memory Transfers
• Arithmetic Microoperations
• Logic Microoperations
• Shift Microoperations
• Arithmetic Logic Shift Unit
26
SIMPLE DIGITAL SYSTEMS
● Combinational and sequential circuits can be used to create simple
digital systems.
● These are the low-level building blocks of a digital computer.
● Simple digital systems are frequently characterized in terms of
– the registers they contain, and
– the operations that they perform.
● Typically,
– What operations are performed on the data in the registers
– What information is passed between registers
27
Register Transfer Language
MICROOPERATIONS (1)
● The operations on the data in registers are called
microoperations.
● The functions built into registers are examples of
microoperations
– Shift
– Load
– Clear
– Increment
– …
28
Register Transfer Language
MICROOPERATION (2)
An elementary operation performed (during
one clock pulse), on the information stored
in one or more registers
Registers ALU
(R) (f)
R f(R, R)
f: shift, load, clear, increment, add, subtract, complement,
and, or, xor, … 29
Register Transfer Language
ORGANIZATION OF A DIGITAL SYSTEM
• Definition of the (internal) organization of a computer
- Set of registers and their functions
- Microoperations set
Set of allowable microoperations provided
by the organization of the computer
- Control signals that initiate the sequence of
microoperations (to perform the functions)
30
Register Transfer Language
REGISTER TRANSFER LEVEL
● Viewing a computer, or any digital system, in this way is
called the register transfer level
● This is because we’re focusing on
– The system’s registers
– The data transformations in them, and
– The data transfers between them.
31
Register Transfer Language
REGISTER TRANSFER LANGUAGE
● Rather than specifying a digital system in words, a specific
notation is used, register transfer language
● For any function of the computer, the register transfer
language can be used to describe the (sequence of)
microoperations
● Register transfer language(In
symbolic notation, it
is used to describe the micro-operations
transfer among registers.)
– A symbolic language
– A convenient tool for describing the internal organization of digital
computers
32
– Can also be used to facilitate the design process of digital systems.
Register Transfer Language
DESIGNATION OF REGISTERS
● Registers are designated by capital letters, sometimes
followed by numbers (e.g., A, R13, IR)
● Often the names indicate function:
– MAR - memory address register
– PC - program counter
– IR - instruction register
● Registers and their contents can be viewed and represented in
various ways
– A register can be viewed as a single entity:
MAR
– Registers may also be represented showing the bits of data they contain33
Register Transfer Language
DESIGNATION OF REGISTERS
• Designation of a register
- a register
- portion of a register
- a bit of a register
• Common ways of drawing the block diagram of a register
Register Showing individual bits
R1 7 6 5 4 3 2 1 0
15 0 15 8 7 0
R2 PC(H) PC(L)
Numbering of bits Subfields
34
Register Transfer
REGISTER TRANSFER
● Copying the contents of one register to another is a register
transfer
● A register transfer is indicated as
R2 R1
– In this case the contents of register R2 are copied (loaded) into
register R1
– A simultaneous transfer of all bits from the source R1 to the
destination register R2, during one clock pulse
– Note that this is a non-destructive; i.e. the contents of R1 are not
altered by copying (loading) them to R2
35
Register Transfer
REGISTER TRANSFER
● A register transfer such as
R3 R5
Implies that the digital system has
– the data lines from the source register (R5) to the destination
register (R3)
– Parallel load in the destination register (R3)
– Control lines to perform the action
36
Register Transfer
CONTROL FUNCTIONS
● Often actions need to only occur if a certain condition is true
● This is similar to an “if” statement in a programming language
● In digital systems, this is often done via a control signal, called
a control function
– If the signal is 1, the action takes place
● This is represented as:
P: R2 R1
Which means “if P = 1, then load the contents of register R1 into
register R2”, i.e., if (P = 1) then (R2 R1)
37
Register Transfer
HARDWARE IMPLEMENTATION OF CONTROLLED TRANSFERS
Implementation of controlled transfer
P: R2 R1
Block diagram Control P Load
R2 Clock
Circuit
n
R1
Timing diagram t t+1
Clock
Load
Transfer occurs here
• The same clock controls the circuits that generate the control function
and the destination register
• Registers are assumed to use positive-edge-triggered flip-flops
38
Register Transfer
SIMULTANEOUS OPERATIONS
● If two or more operations are to occur
simultaneously, they are separated with commas
P: R3 R5, MAR IR
● Here, if the control function P = 1, load the
contents of R5 into R3, and at the same time
(clock), load the contents of register IR into
register MAR
39
Register Transfer
BASIC SYMBOLS FOR REGISTER TRANSFERS
Symbols Description Examples
Capital letters Denotes a register MAR, R2
& numerals
Parentheses () Denotes a part of a register R2(0-7), R2(L)
Arrow Denotes transfer of information R2 R1
Colon : Denotes termination of control function P:
Comma , Separates two micro-operations A B, B A
40
41
Bus and Memory Transfers
MEMORY TRANSFERS
Memory Read
AR
unit Write
DR
Memory read micro-op: DR M ( DR M[AR] )
Memory write micro-op: M DR ( M[AR] DR )
Summary of Register Transfer Microoperations
A B Transfer content of reg. B into reg. A
AR DR(N) Transfer content of N bits portion of reg. DR into reg. AR
A constant Transfer a binary constant into reg. A
ABUS R1, Transfer content of R1 into bus A and, at the same time,
R2 ABUS transfer content of bus A into R2
AR Address register
DR Data register
M[AR] Memory word specified by reg. AR
DR M[AR] Memory read operation: transfers content of
memory word specified by AR into DR
M[AR] DR Memory write operation: transfers content of
DR into memory word specified by AR
42
Bus and Memory Transfers
BUS AND MEMORY TRANSFER
Bus is a path(of a group of wires) over which information is transferred,
from any of several sources to any of several destinations.
From a register to bus: BUS <- R
Register A Register B Register C Register D
Bus lines
From bus to a register : R <- BUS
Bus lines
Load
Reg. R0 Reg. R1 Reg. R2 Reg. R3
D 0 D1 D 2 D 3
z E (enable)
Select 2x4
w
Decoder
43
44
45
46
Arithmetic Microoperations
ARITHMETIC MICROOPERATIONS
Four types of microoperations
- Register transfer microoperations
- Arithmetic microoperations
- Logic microoperations
- Shift microoperations
* Summary of Arithmetic Micro-Operations
R3 R1 + R2 Contents of R1 plus R2 transferred to R3
R3 R1 - R2 Contents of R1 minus R2 transferred to R3
R2 R2’ Complement the contents of R2
R2 R2’+ 1 2's complement the contents of R2 (negate)
R3 R1 + R2’+ 1 subtraction
R1 R1 + 1 Increment
R1 R1 - 1 Decrement
47
48
49
50
51
52
53
54
55
Logic Micro-operations
56
57
Register Transfer and Micro-operations 58
Applications of Logic Microoperations
Logic microoperations can be used to manipulate individual bits or a
portions of a word in a register
Consider the data in a register A. In another register, B, is bit data that
will be used to modify the contents of A
Selective-set AA+B
Selective-complement AAB
Selective-clear A A • B’
Mask (Delete) AA•B
Clear/Compare AAB
Insert A (A • B) + C
58
CSE 211
Register Transfer & -operations Logic Microoperations
SELECTIVE SET
● In a selective set operation, the bit pattern in B is
used to set certain bits in A
1100 At
1010 B
1110 At+1 (A A + B)
● If a bit in B is set to 1, that same position in A gets set
to 1, otherwise that bit in A keeps its previous value
59
Register Transfer & -operations Logic Microoperations
SELECTIVE COMPLEMENT
● In a selective complement operation, the bit pattern in B is used
to complement certain bits in A
1100 At
1010 B
0110 At+1 (A A B)
● If a bit in B is set to 1, that same position in A gets complemented
from its original value, otherwise it is unchanged
60
Register Transfer & -operations Logic Microoperations
SELECTIVE CLEAR
● In a selective clear operation, the bit pattern in B
is used to clear certain bits in A
1100 At
1010 B
0100 At+1 (A A B’)
● If a bit in B is set to 1, that same position in A
gets set to 0, otherwise it is unchanged
61
Register Transfer & -operations Logic Microoperations
MASK OPERATION
● In a mask operation, the bit pattern in B is used
to clear certain bits in A
1100 At
1010 B
1000 At+1 (A A B)
● If a bit in B is set to 0, that same position in A
gets set to 0, otherwise it is unchanged
62
Register Transfer & -operations Logic Microoperations
CLEAR OPERATION
● In a clear operation, if the bits in the same
position in A and B are the same, they are cleared
in A, otherwise they are set in A
1100 At
1010 B
0110 At+1 (A A B)
63
Register Transfer & -operations Logic Microoperations
INSERT OPERATION
● An insert operation is used to introduce a specific bit pattern into A register, leaving the other bit
positions unchanged
● This is done as
– A mask operation to clear the desired bit positions,
followed by
– An OR operation to introduce the new bits into the
desired positions
– Example
● Suppose you wanted to introduce 1010 into the low order
four bits of A: 1101 1000 1011 0001A (Original)
1101 1000 1011 1010 A (Desired)
● 1101 1000 1011 0001 A (Original)
1111 1111 1111 0000 Mask
1101 1000 1011 0000 A (Intermediate)
0000 0000 0000 1010 Added bits
1101 1000 1011 1010 A (Desired)
64
Register Transfer and Micro-operations 65
Shift Microoperations
• There are three types of shifts
– Logical shift
– Circular shift
– Arithmetic shift
• What differentiates them is the information that goes into the serial input
• A right shift operation
Serial
input
• A left shift operation
Serial
input
65
CSE 211
Register Transfer and Micro-operations 66
Logical Shift
• In a logical shift the serial input to the shift is a 0.
• A right logical shift operation:
0
• A left logical shift operation:
0
• In a Register Transfer Language, the following notation is used
– shl for a logical shift left
– shr for a logical shift right
– Examples:
• R2 shr R2
• R3 shl R3 66
CSE 211
Register Transfer and Micro-operations 67
Circular Shift
• In a circular shift the serial input is the bit that is shifted out of the other
end of the register.
• A right circular shift operation:
• A left circular shift operation:
• In a RTL, the following notation is used
– cil for a circular shift left
– cir for a circular shift right
– Examples:
• R2 cir R2
• R3 cil R3
67
CSE 211
Register Transfer and Micro-operations 68
Arithmetic Shift
• An arithmetic shift is meant for signed binary numbers (integer)
• An arithmetic left shift multiplies a signed number by two
• An arithmetic right shift divides a signed number by two
• Sign bit : 0 for positive and 1 for negative
• The main distinction of an arithmetic shift is that it must keep the sign of
the number the same as it performs the multiplication or division
• A right arithmetic shift operation:
sign
bit
• A left arithmetic shift operation: 0
sign
bit
68
CSE 211
Register Transfer and Micro-operations 69
Arithmetic Shift
• An left arithmetic shift operation must be checked for the overflow
0
sign
bit
Before the shift, if the leftmost two
V bits differ, the shift will result in an
overflow
• In a RTL, the following notation is used
– ashl for an arithmetic shift left
– ashr for an arithmetic shift right
– Examples:
» R2 ashr R2
» R3 ashl R3
69
CSE 211
Register Transfer and Micro-operations 70
Arithmetic Logic and Shift Unit
S3
S2 C
i
S1
S0
D
Arithmetic i
Circuit
Select
0 4x1
C i+1 F
1 i
MUX S3 S2 S1 S0 Cin Operation
2 0 0 0 0 0 F=A
3 0 0 0 0 1 F=A+1
0 0 0 1 0 F=A+B
E 0 0 0 1 1 F=A+B+1
Logic i 0 0 1 0 0 F = A + B’
Bi 0 0 1 0 1 F = A + B’+ 1
Circuit 0 0 1 1 0 F=A-1
A 0 0 1 1 1 F=A
i
0 1 0 0 X F=AB
shr
A 0 1 0 1 X F = A B
i-1 0 1 1 0 X F=AB
shl
A 0 1 1 1 X F = A’
i+1
1 0 X X X F = shr A
1 1 X X X F = shl A 70
CSE 211
References
!. M. Morris Mano, Computer System Architecture, 3/e,
Pearson education, 2008
References:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, Computer
Organization,5/e, McGraw Hill,2001
2. John P. Hayes, Computer Architecture and Organization,
3/e, McGraw Hill, 1998.
3. William Stallings, Computer Organization and
Architecture, 6/e, Pearson PHI, 2012.
71