Mod 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 78

COMPUTER ORGANIZATION

& ARCHITECTURE
Sub. code:- 18EC35

SREENIVASA BABU M.O


Dept. of ECE
ASSISTANT PROFESSOR
RNSIT
MODULE -1

Basic Structure of
Computers
1.1 Computer Types
Modern computers can be divided roughly
into four general categories:
1. Embedded computers
2. Personal computers
3. Servers
4. Supercomputers
Embedded computers
• They are integrated into a larger device or
system in order to automatically monitor and
control a physical process or environment.
• They are used for a specific purpose rather
than for general processing tasks.
• Typical applications include industrial and
home automation, appliances,
telecommunication products, and vehicles.
Personal computers (PC)
• PCs are used in homes, educational institutions,
and business & engineering , primarily for
dedicated individual use.
• They support a variety of applications such as –
- general computation,
- document preparation,
- computer-aided design,
- audiovisual entertainment,
- interpersonal communication, and
- Internet browsing.
Different types of PCs
• Desktop computers serve general needs and
fit within a typical personal workspace.
• Workstation computers offer higher
computational capacity and more powerful
graphical display capabilities for engineering
and scientific work.
• Notebook computers is a personal computer
in a smaller lightweight package. They can
operate on batteries to provide mobility.
Servers
• They are large computers that are shared by a
potentially large number of users who access them
from some form of personal computer over a public
or private network.
• Such computers have large databases and provide
information processing for a government agency or
a commercial organization.
Supercomputers and Grid computers
• Supercomputers are used for the highly demanding
computations needed in weather forecasting,
engineering design and simulation, and scientific work.
• They have a high cost.
• Grid computers provide a more cost-effective
alternative.
• They combine a large number of personal computers
and disk storage units in a physically distributed high-
speed network, called a grid.
• By evenly distributing the computational workload
across the grid, it is possible to achieve high
performance on large applications.
Cloud computing.
• Cloud is a term used to describe data centers
available to many users over the Internet.
• Cloud computing is the on demand delivery of
computing services such as servers, storage,
databases, networking, softwares etc. over
the Internet on a pay-as-you-use basis.
• Amazon, Microsoft, Google, Oracle, vmware,
IBM, Alibaba..
1.2 Functional Units
• The input unit accepts information from human
operators using devices such as keyboards, or from
other computers
• The information received is stored in the computer’s
memory, either for later use or to be processed
immediately by the arithmetic and logic unit.
• The processing steps are specified by a program that is
also stored in the memory.
• Finally, the results are sent back to the outside world
through the output unit.
• All of these actions are coordinated by the control unit.
• An interconnection network provides the means for the
functional units to exchange information and
coordinate their actions.
Input Unit
• The most common input device is the keyboard.
• Many other kinds of input devices are the touchpad,
mouse, joystick, and trackball.
• These are often used as graphic input devices in
conjunction with displays.
• Microphones can be used to capture audio input which
is then sampled and converted into digital codes for
storage and processing.
• Similarly, cameras can be used to capture video input.
• Internet, can also provide input to a computer from
other computers and database servers.
Memory Unit
• The function of the memory unit is to store
programs and data.
• There are two classes of storage,
- primary e.g:- RAM, cache
- secondary. e.g:- magnetic disks, optical disks
(DVD and CD), and flash memory devices
Primary Memory
• Primary memory, also called main memory, is a fast
memory that operates at electronic speeds.
• Programs must be stored in this memory while they
are being executed.
• Memory consists of a large number of
semiconductor storage cells,.
• Each capable of storing one bit of information.
• These cells are rarely read or written individually.
Primary Memory
• Instead, they are handled in groups of fixed
size called words.
• The number of bits in each word is referred to
as the word length of the computer, typically
16, 32, or 64 bits.
• A distinct address is associated with each
word location.
• A particular word is accessed by specifying its
address.
Primary Memory
• Instructions and data can be written into or read
from the memory.
• A memory in which any location can be accessed
in a short and fixed amount of time after
specifying its address is called a random-access
memory (RAM).
• The time required to access one word is called
the memory access time(MAT).
• It typically ranges from a few nanoseconds (ns) to
about 100 ns for current RAM units.
Cache Memory
• A cache, is used to hold sections of a program
that are currently being executed, along with
any associated data.
• The cache is tightly coupled with the
processor and is usually contained on the
same integrated-circuit chip.
• The purpose of the cache is to facilitate high
instruction execution rates.
• At the start of program execution, the cache is
empty.
• All program instructions and any required data
are stored in the main memory.
• As execution proceeds, instructions are fetched
into the processor chip, and a copy of each is
placed in the cache.
• Now, suppose a number of instructions are
executed repeatedly as happens in a program
loop.
• If these instructions are available in the cache,
they can be fetched quickly
Secondary Storage
• Although primary memory is essential, it tends to be
expensive and does not retain information when
power is turned off.
• Thus additional, less expensive, permanent
secondary storage is used when large amounts of
data and many programs have to be stored.
• Access times for secondary storage are longer than
for primary memory.
• A wide variety of secondary storage devices
available magnetic disks, optical disks (DVD and CD),
and flash memory devices.
Arithmetic and Logic Unit
• Most computer operations are executed in the
arithmetic and logic unit (ALU) of the processor.
• Any arithmetic or logic operation, such as addition,
subtraction, multiplication, division, or comparison of
numbers, are performed by the ALU.
• When operands are brought into the processor, they
are stored in high-speed storage elements called
registers.
• Each register can store one word of data.
• Access times to registers are even shorter than access
times to the cache unit on the processor chip.
Output Unit
• Its function is to send processed results to the
outside world.
• A familiar example of such a device is a printer.
• Most printers employ either photocopying
techniques, as in laser printers, or ink jet streams.
• Such printers may generate output at speeds of
20 or more pages per minute.
• However, printers are mechanical devices, and as
such are quite slow compared to the electronic
speed of a processor.
Contd..
• Some units, such as graphic displays, provide
both an output function, and an input
function,
• Showing text and graphics, through touch
screen capability.
• The dual role of such units is the reason for
using the single name input/output (I/O) unit
in many cases.
Control Unit
• The memory, ALU and I/O units store and
process information and perform input and
output operations.
• The operation of these units must be
coordinated in some way.
• This is the responsibility of the control unit.
• Data transfers between the processor and the
memory are also managed by the control unit
Control Unit
• We usually think that control unit is a well-
defined, physically separate unit that interacts
with other parts of the computer.
• Much of the control circuitry is physically
distributed throughout the computer.
Summary
• The computer accepts information in the form
of programs and data through an input unit
and stores it in the memory.
• Information stored in the memory is fetched
into an ALU, where it is processed.
• Processed information leaves the computer
through an output unit.
• All activities in the computer are directed by
the control unit.
Memory

MAR MDR
Control

PC R0

R1
Processor
IR

ALU
Rn - 1

n general purpose
registers

Basic Operational Concepts


Fi gure 1.2. Connecti ons between the processor and the memory.
• The Instruction Register (IR) holds the instruction that
is currently being executed.
• The Program Counter (PC)contains the memory
address of the next instruction to be fetched and
executed.
• MAR holds the address of the location to be accessed.
• MDR contains the data to be written into or read out
of the addressed location.
• There are general-purpose registers R0 to Rn−1, often
called processor registers.
• They serve a variety of functions, including holding
operands that have been loaded from the memory for
processing.
Basic operation
• Program resides in the memory
• Execution starts when PC is set to point to the first
instruction in the program.
• The contents of PC are transferred to MAR and a
read control signal is sent to the memory.
• After some time (MAT)the first instruction is
loaded into MDR.
• The contents of MDR are transferred to IR.
• If some operation has to be performed by ALU, it is
necessary to obtain the required operands.
• If an operand reside in the memory it has to be
fetched by sending its address to the MAR and CU
has to send a read control signal.
• Once it is read from memory into MDR, it is transferred to
the ALU.
• After one or more operands are fetched in this way, the
ALU can perform desired operation.
• If the result of the operation is to be stored in the
memory, the result is sent MDR.
• The address of the location where the result is to be
stored is sent to the MAR, and write cycle is initiated.
• In addition to transferring data b/w memory and
processor, the computer accepts data from input devices
and sends data to output devices.
• Finally the contents of PC is incremented so that PC points
to the next instruction.
• And the cycle repeats all over again.
Example program
Load R2, NUM1; get the 1st number
Load R3, NUM2; get the 2nd number

Add R4, R2, R3; add the two numbers


Store R4, LOCA; store the result in memory
Interrupts
• Normal execution may be pre-empted if some devices
require urgent servicing.
• For example, a monitoring device in a computer-
controlled industrial process may detect a dangerous
condition.
• In order to respond immediately, execution of the
current program must be suspended.
• To cause this, the device raises an interrupt signal,
which is a request for service by the processor.
• The processor provides the requested service by
executing a program called an interrupt-service routine.
Bus structures
• Bus is a group lines or wires that transfers
information from one unit to the other.
i.e. data, address and control signal
• When a word of data is transferred between
units, all bits are transferred in parallel
i.e. the bits are transferred simultaneously
over many wires.
• The simplest way to interconnect all units is to
use a single bus.
Input Output Memory Processor

Figure 1.3. Single-bus structure.

Single bus
• Only two units can actively use the bus at any
given time, since bus can be used for only one
transfer at a time.
• Advantages of using single bus are low cost and
flexibility in attaching peripheral devices.
• Multiple buses achieve more concurrency in
operations.
i.e. two or more transfers carried out at the
same time
• This leads to better performance but at an
increased cost.
Buffer registers
• Devices connected to a bus vary widely in their speed of
operation.
e.g: - Keyboards and printers slow, Magnetic or optical disks are
considerably fast and Memory & processor are fastest devices.
• All these devices must communicate with each other over
a bus, an efficient mechanism to smooth out the
differences in speed is necessary.
• A common approach is to include buffer registers with
devices to hold information during transfers.
e.g:- Transfer of encoded characters from processor to printer
• Buffer registers smooth out timing differences among
processors, memory and I/O devices.
Software
1. System Software: is a collection of programs needed
to perform basic functions for computer usage.
Basic functions
– Receiving and interpreting user commands.
– Managing the storage and retrieval of files in secondary
storage devices.
– Controlling I/O units to receive input data and produce
output results.
– Translating programs from source form by user into object
form of machine instructions.
– Linking and running user-written application programs
with existing standard library routines
2. Application Software: are end-user programs
which specifies a mathematical or data processing
operations etc.
• These are usually written in a HLL such as C,C++,
Java, Python, Visual Basic….
• A program translates the HLL into a machine
language program called Compiler.
• Another program is used for entering & editing
application program called Text editor.
• We also have Debuggers, Linkers, Interpreters..
• Integrated development environment(IDE) – a
single software application which consists of all
these.
Operating system
Definition:
It a large program or collection of programs
used to control
– the sharing of various computer resources
– interaction among various computer units
as they execute application programs.
OS (contd…)
The OS programs perform the various tasks to
assign computer resources to individual
application programs.
They are as follows
– Assigning memory & magnetic disk space to
program and data files.
– Moving data between memory and disk units
– Handling I/O operations
Basics of OS
• Example: - A system with one processor, one
disk, and one printer. The application program
has been compiled from HLL into a MLL and
stored on the disk.
First step is to transfer this file to memory.
When the transfer is complete, execution starts

Let us Assume that part of the program’s task


involves reading a data file from the disk into the
memory, performing some computation on the
data, and printing the results
User Program and OS Routine Sharing
of the Processor
Multiprogramming or Multitasking
Performance
• The most important measure of a computer is
how quickly it can execute programs.
• Three factors affect performance:
 Hardware design
 Instruction set
 Compiler

Elapsed time:- is a measure of the performance of the


entire computer system.
It is the total time required to execute a program in
previous figure.
Performance
Processor time to execute a program depends on the
hardware involved in the execution of individual
machine instructions.

Main Cache
memory memory Processor

Bus

Figure 1.5. The processor cache.


Performance
• The processor and a relatively small cache
memory can be fabricated on a single
integrated circuit chip.
– Speed
– Cost
– Memory management
Processor Clock
• Processor operations are controlled by a timing signal
called a clock.
• Clock defines regular time interval called clock cycles.
• To execute an instruction, it divides the action to be
performed into a sequence of basic steps.
• Each step is completed in one clock cycle.
• Let the length P of one clock cycle, its inverse is the
clock rate, R=1/P measured in cycles per sec.
• 500 million cycles/sec = 500MHz, clock period2 ns
• 1250 million cycles/sec = 1.25GHz, clock period0.8 ns
Basic Performance Equation
• T – processor time required to execute a program that has
been prepared in high-level language
• N – number of actual machine language instructions needed
to complete the execution (note: loop)
• S – average number of basic steps needed to execute one
machine instruction. Each step completes in one clock cycle
• R – clock rate.

N S
T
R

How to improve T?
Memory Locations, Addresses
n bits

• Memory consists of first word


many millions of second word
storage cells, each of
which can store 1 bit.

• Data is usually •
accessed in n-bit •
groups.
i th word
• Where n is called word
length.
• Modern computers •

have word length •
typically in the range
16 or 64 bits. last word

Figure 2.5. Memory words.


Memory Location, Addresses
• 32-bit word length example
32 bits

b31 b30 b1 b0




Sign bit: b31= 0 for positive numbers
b31= 1 for negative numbers

(a) A signed integer

8 bits 8 bits 8 bits 8 bits

ASCII ASCII ASCII ASCII


character character character character

(b) Four characters


Memory addressing
• The 2k addresses constitute the address space
of the computer.
• It is customary to use numbers from 0 to 2k -1,
where k is the number of address bits.
• E.g:- 24-bit address generates an address
space of 224 (16,777,216) locations i.e. 16MB.
• 20-bit address 220 (1,048,576) i.e. 1 MB.
• 32-bit address  232 (4,294,967,296)i.e. 4GB
Byte addressability
• Bit = 1 or 0 , Byte= 8-bits, Word= 16 - 64 bits.
• It is impractical to assign distinct addresses to
individual bit locations in memory.
• Instead Byte locations are assigned addresses
0,1,2,3,4,…………………………
• If the word length of the machine is 32 bits,
successive words are located at 0,4,8,……….
With each word consisting of 4 bytes.
Big-Endian and Little-Endian Assignments
Big-Endian: Lower byte addresses are used for the most significant bytes of the word
Little-Endian: Opposite ordering , lower byte addresses are used for the least
significant bytes of the word

Word
address Byte address Byte address

0 0 1 2 3 0 3 2 1 0

4 4 5 6 7 4 7 6 5 4

• •
• •
• •

k k k k k k k k k k
2 -4 2 -4 2 -3 2- 2 2 - 1 2 - 4 2- 1 2 - 2 2 -3 2 -4

(a) Big-endian assignment (b) Little-endian assignment

Figure 2.7. Byte and word addressing.


Word alignment
– Words are said to be aligned in memory if they
begin at a byte address that is a multiple of the
number of bytes in a word.
• 16-bit word: Word addresses: 0, 2, 4,….
• 32-bit word: Word addresses: 0, 4, 8,….
• 64-bit word: Word addresses: 0, 8,16,….
– There is no reason why words cannot begin at an
arbitrary address.
– In that case, words are said to have unaligned
addresses.
Memory Operation
• The two basic operations involving the memory
and the processor are:
– Load (or Read or Fetch)
 Copy the content. The memory content doesn’t change.
 Processor sends Address of the desired location to memory.
 Registers can be used
– Store (or Write)
 Overwrite the content in memory
 Processor sends Address of the desired location and Data to be written in
that location to memory.
 Registers can be used
Instructions and Instruction
Sequencing
A computer must have instructions capable of
Performing 4 types of operations.
• Data transfers between the memory and the
processor registers
• Arithmetic and logic operations on data
• Program sequencing and control
• I/O transfers
Register Transfer Notation (RTN)
• Identify a location by a symbolic name standing
for its hardware binary address (LOC, R0,…)
• Contents of a location are denoted by placing
square brackets around the name of the location
R1←[LOC], R3 ←[R1]+[R2])
• Note:
1. RHS of an RTN expression always denote a value
2. LHS is name of the location where the value is to
be placed, overwriting the old contents
Assembly Language Notation
• This Notation represent machine instructions
and programs.
Move LOC, R1 ; R1←[LOC]
Add R1, R2, R3 ; R3 ←[R1]+[R2]
Instruction Formats
• Three-Address Instructions
– ADD R1, R2, R3 R3 [R1] + [R2]
• Two-Address Instructions
– ADD R1, R2 R1 ← R1 + R2
• One-Address Instructions
– ADD M AC ← AC + M[AR]
• Zero-Address Instructions
– ADD TOS ← TOS + (TOS – 1)
– PUSH
– POP

Opcode Operand(s) or Address(es)


Instruction Formats
1. Three-Address Instruction

General format:
Operation Source1, Source2,Destination

Example: Perform C  [A] +[B]


1. ADD A, B, C ; C ← M[A] + M[B]
Instruction Formats
2. Two-Address Instruction
General format:
Operation Source, Destination

Example: Perform C  [A] +[B]


1. MOV C,B ; B  M[C]
2. ADD A,C ; C ← M[A] + M[C]
Instruction Formats
3. One-Address Instruction
General format:
Operation Source

Example: Perform C  [A] +[B]


1. LOAD A ; AC M[A]
2. ADD B ; AC ← AC + M[B]
3. Store C ; C  AC
Instruction Execution and Straight-Line
Sequencing Assumptions:
Address Contents - One memory operand
per instruction
Begin execution here i Move A,R0
3-instruction
- 32-bit word length
i+4 Add B,R0 program
segment
- Memory is byte
i+8 Move R0,C addressable
- Full memory address
can be directly specified
in a single-word instruction
A

-Address of 1st instruction


Data for
must be placed in PC
B
the program - PC  [PC] + 4
- this is called St. Line-
sequencing
C
Two-phase procedure
-Instruction fetch
-Instruction execute
Figure 2.8. A program for C  [A] + [B].
i Move NUM1,R0
i+4 Add NUM2,R0
i+8 Add NUM3,R0




i + 4n - 4 Add NUMn,R0
i + 4n Move R0,SUM




SUM
NUM1
NUM2




NUMn

Figure 2.9. A straight-line program for adding n numbers.


Move N,R1
Clear R0
Branching LOOP
Determine address of
"Next" number and add
Program "Next" number to R0
loop
Decrement R1
Branch>0 LOOP
Branch target
Move R0,SUM

Conditional branch



SUM
N n
NUM1
NUM2



Figure 2.10. Using a loop to add n numbers. •
NUMn
Condition Codes
• The processor keeps track of information about results
of various operation in individual bits called Condition
code flags.
• Individual flag bits are set to 1 or cleared to 0,
depending on the outcome of the operation performed.
• These flags are on a special register called Condition
code register / status register
• N (negative) 1 if the result is –ve, 0 otherwise
• Z (zero) 1 if the result is zero, 0 otherwise
• V (overflow) 1 if there is overflow, 0 otherwise
• C (carry) 1 if there is carry out, 0 otherwise
Example
• Given A: 01110000
A: 0 1 1 1 0 0 0 0 + (B ): 00010100
B: 0 0 0 1 0 1 0 0 10011100
perform A + B
C=0 Z=0
S=1
V=0
FLOATING POINT NUMBERS
• Representation for non-integral numbers
- Including very small and very large numbers
• Like scientific notation
–2.34 × 1056 normalized
+0.002 × 10–4 not normalized
+987.02 × 109 not normalized
• In decimal
±X1. X2 X3 X4 X5 X6 X7 × 10 ± Y1Y2
• In binary
±1.xxxxxxx2 × 2yyyy
• Note: when the decimal point is placed to the right of 1st
significant digit(non-zero), the number is said to be normalized.
IEEE Standard for floating point
numbers
SINGLE-PRECISION RANGE
• Exponents 00000000 and 11111111 are reserved
• Smallest value
• Exponent: 00000001 actual exponent = 1 – 127 = –126
• Fraction: 000…00 significand = 1.0
±1.0 × 2–126 ≈ ±1.2 × 10–38
• Largest value
• Exponent: 11111110 actual exponent = 254 – 127 = +127
• Fraction: 111…11 significand ≈ 2.0
±2.0 × 2+127 ≈ ±3.4 × 10+38
DOUBLE-PRECISION RANGE
• Exponents 0000…00 and 1111…11 are reserved
• Smallest value
• Exponent: 00000000001 actual exponent = 1 – 1023
= –1022
• Fraction: 000…00 significand = 1.0
±1.0 × 2–1022 ≈ ±2.2 × 10–308
• Largest value
• Exponent: 11111111110 actual exponent = 2046 –
1023 = +1023
• Fraction: 111…11 significand ≈ 2.0
±2.0 × 2+1023 ≈ ±1.8 × 10+308
Arithmetic operations
• 3 major representations:
Sign and magnitude
One’s complement
Two’s complement
• Assumptions:
4-bit machine word
16 different values can be represented
Roughly half are positive, half are negative
Binary, Signed-Integer Representations
Page 28 B Values represented

Sign and
b 3 b 2 b1 b 0 magnitude 1's complement 2's complement

0 1 1 1 +7 +7 + 7
0 1 1 0 +6 +6 + 6
0 1 0 1 +5 +5 + 5
0 1 0 0 +4 +4 + 4
0 0 1 1 +3 +3 + 3
0 0 1 0 +2 +2 + 2
0 0 0 1 +1 +1 + 1
0 0 0 0 +0 +0 + 0
1 0 0 0 - 0 -7 - 8
1 0 0 1 - 1 -6 - 7
1 0 1 0 - 2 -5 - 6
1 0 1 1 - 3 -4 - 5
1 1 0 0 - 4 -3 - 4
1 1 0 1 - 5 -2 - 3
1 1 1 0 - 6 - 1 - 2
1 1 1 1 - 7 -0 - 1

Figure 2.1. Binary, signed-integer representations.


Two’s Complement Representation

-1 +0
-2 11 11 00 00 +1
11 10 00 01
-3 +2 +
like 1's comp 11 01 00 10
except shifted -4 11 00 00 11 +3 0 100 = + 4
one position
clockwise -5 10 11 01 00 +4 1 100 = - 4
10 10 01 01
-6 +5 -
10 01 01 10
-7 10 00 01 11 +6
-8 +7

• Only one representation for 0


• One more negative number than positive number
Addition and Subtraction – 2’s Complement

4 0100 -4 1100
+3 0011 + (-3) 1101
If carry-in to the high
order bit = 7 0111 -7 11001
carry-out then ignore
carry

if carry-in differs from 4 0100 -4 1100


carry-out then overflow
-3 1101 +3 0011
1 10001 -1 1111

Simpler addition scheme makes twos complement the most common


choice for integer number systems within digital systems
2’s-Complement Add and Subtract
(a)
Operations
0010 ( + 2) (b) 0100 ( + 4)
+ 0011 ( + 3) + 1010 (- 6)
Page 31
0101 ( + 5) 1110 (- 2)
(c) 1011 (- 5) (d) 0111 ( + 7)
+ 1110 (- 2) + 1101 ( - 3)
1001 (- 7) 0100 ( + 4)
(e) 1101 (- 3) 1101
- 1001 (- 7) + 0111
0100 ( + 4)
(f) 0010 ( + 2) 0010
- 0100 ( + 4) + 1100
1110 ( - 2)
(g) 0110 ( + 6) 0110
- 0011 ( + 3) + 1101
0011 ( + 3)
(h) 1001 ( - 7) 1001
- 1011 (- 5) + 0101
1110 ( - 2)
(i) 1001 (- 7) 1001
- 0001 ( + 1) + 1111
1000 ( - 8)
(j) 0010 ( + 2) 0010
- 1101 ( - 3) + 0011
0101 ( + 5)

Figure 2.4. 2's-complement Add and Subtract operations.

You might also like