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

Unit 1

This document provides a syllabus for the course 20CS3103 - Computer Organisation and Architecture. The objectives of the course are to learn the basic structure and operations of a computer, arithmetic and logic units, pipelining, parallelism, memory hierarchies and I/O communication. The syllabus covers 5 units - basic computer structure, arithmetic for computers, processor and control unit, parallelism, and memory and I/O systems. On completing the course, students should understand computer basics, design units, parallel architectures and memory systems.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

Unit 1

This document provides a syllabus for the course 20CS3103 - Computer Organisation and Architecture. The objectives of the course are to learn the basic structure and operations of a computer, arithmetic and logic units, pipelining, parallelism, memory hierarchies and I/O communication. The syllabus covers 5 units - basic computer structure, arithmetic for computers, processor and control unit, parallelism, and memory and I/O systems. On completing the course, students should understand computer basics, design units, parallel architectures and memory systems.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 109

20CS3103 - COMPUTER ORGANISATION

AND ARCHITECTURE
SYLLABUS
OBJECTIVES:
• To learn the basic structure and operations of a computer.
• To learn the arithmetic and logic unit and implementation of
fixed-point and floating point arithmetic unit.
• To learn the basics of pipelined execution.
• To understand parallelism and multi-core processors.
• To understand the memory hierarchies, cache memories and
virtual memories.
• To learn the different ways of communication with I/O devices.
SYLLABUS

UNIT I BASIC STRUCTURE OF A


COMPUTER SYSTEM

Functional Units – Basic Operational Concepts -


Performance – Instructions: Language of
the Computer – Operations, Operands –
Instruction representation – Logical operations –
decision making – MIPS Addressing.
SYLLABUS

UNIT II ARITHMETIC FOR COMPUTERS


Addition and Subtraction – Multiplication –
Division – Floating Point Representation –
Floating Point Operations – Subword Parallelism
SYLLABUS
UNIT III PROCESSOR AND CONTROL UNIT
A Basic MIPS implementation – Building a Datapath – Control
Implementation Scheme –
Pipelining – Pipelined datapath and control – Handling Data
Hazards & Control Hazards –
Exceptions.
SYLLABUS
UNIT IV PARALLELISIM

Parallel processing challenges – Flynn‘s classification – SISD,


MIMD, SIMD, SPMD, andVector Architectures - Hardware
multithreading – Multi-core processors and other Shared Memory
Multiprocessors - Introduction to Graphics Processing Units,
Clusters, WarehouseScale Computers and other Message-Passing
Multiprocessors.
SYLLABUS
UNIT V MEMORY & I/O SYSTEMS

Memory Hierarchy - memory technologies – cache memory –


measuring and improving cache performance – virtual memory,
TLB‘s – Accessing I/O Devices – Interrupts – Direct Memory
Access – Bus structure – Bus operation – Arbitration – Interface
circuits - USB
SYLLABUS
OUTCOMES:

On Completion of the course, the students should be able to:


 Understand the basics structure of computers, operations and
instructions.
 Design arithmetic and logic unit.
 Understand pipelined execution and design control unit.
 Understand parallel processing architectures.
 Understand the various memory systems and I/O communication.
SYLLABUS
TEXT BOOKS:

1. David A. Patterson and John L. Hennessy, Computer Organization


and Design: The Hardware/Software Interface, Fifth Edition,
Morgan Kaufmann / Elsevier, 2014.

2. Carl Hamacher, Zvonko Vranesic, Safwat Zaky and Naraig


Manjikian, Computer Organization and Embedded Systems, Sixth
Edition, Tata McGraw Hill, 2012.
INTRODUCTION
 Computer have become part and parcel of our daily
lives.

 It is required to understand how a computer works

 Computer Architecture
 How to integrate the components to build a computer
system to achieve level of performance.
INTRODUCTION
 Computer Architecture
 Computer architecture encompasses the specification of
an instruction set and the functional behavior of the
hardware units that implement the instructions.
Historical perspective
 constant quest of building automatic computing machines have
driven the development of computers.
 Initial efforts: mechanical devices like pulleys, levers, gears.

 During World War 2: mechanical relays were used to perform


computation.

 Vacuum tubes: first electronic computer called ENIAC was developed.

 Semiconductor transistors developed: the journey of miniaturization


begun.

 SSI MSI LSI VLSI ULSI


PASCALINE (1944)
 Mechanical calculator invented by B.Pascal

 Could add and subtract two numbers, and multiply


and division by repetition.
Babbage engine
 First automatic computing engine was designed by
Charles babbage in the 19th century but he could not
build it.

 The complete babbage engine was build in 2002.

 8000 parts

 Weighted 5 tons.

 11 feet in length
Babbage engine
ENIAC
 ENIAC - Electrical Numerical Integrated and
Calculator.

 Developed by University of Pennsylvania.

 Used 18,000 vacuum tubes and weighted 30 tons,


and 30 feet cross 50 feet.
ENIAC
Harvard Mark 1
 Built at the University of Harvard in 1944, with
support from IBM

 Used mechanical relays to represent the data.

 It weighted 35 tons, and required 500 miles of


wiring.
Harvard mark 1
IBM system 360
 Very popular mainframe computer of the 60s and
70s.

 Introduced many advanced architectural concepts


that appeared in microprocessor.
IBM System / 360
Intel core i9
 Introduced in May 2017.

 high number of cores, high power draw, high thermal


output, and high performance

 Desktop processors

 Skylake-X, Coffee Lake-S, Cascade Lake-X, Comet


Lake-S.

 Mobile Processors, Coffee Lake-H


Evolution of the types of computer
Computer Types
 Digital computers have evolved into many different
types that vary widely in size, cost, computational power, and
intended use.

 Divide into four categories,

1. Embedded computers

2. Personal computers

3. Servers and Enterprise systems

4. Supercomputers and Grid computers


Embedded computers
 Integrated into a larger device or system in order to
automatically monitor and control a physical process or
environment.

 Used for a specific purpose.

 Applications include industrial and home automation,


appliances, telecommunication products, and vehicles.
Personal computers
 Used in homes, educational institutions, and business and engineering office settings,
and individual use.

 Applications such as general computation, document preparation, computer-aided


design, audiovisual entertainment, interpersonal communication, and Internet browsing.

 Classification in PC

 Desktop computers - general needs and personal workspace.

 Workstation computers - higher computational capacity and more powerful graphical


display capabilities for engineering and scientific work.

 Portable and Notebook computers - provide the basic features of a personal computer
in a smaller lightweight package.
Servers and Enterprise systems
 Large computers capable of share large number of
users and it can be access from PC over a public or
private network.

 It host large database.


Supercomputers and Grid computers
 It offer the highest performance.

 Most expensive and physically the largest category of computers.

 Supercomputers are used for the high computations needed in weather


forecasting, engineering design and simulation, and scientific work.

 High cost.

 Grid computers provide a more cost-effective alternative.

 Combine a large number of personal computers and disk storage units in a


physically distributed high-speed network, called a grid, managed as a
coordinated computing resource.
Functional Units
 Five main parts

 Input

 Memory

 Arithmetic and logic

 Output

 Control units
Functional Units
 Five main parts

 Input

 Memory

 Arithmetic and logic

 Output

 Control units
Functional Units
Information Handled by a
Computer
 Instructions/machine instructions

 Govern the transfer of information within a computer as well as between


the computer and its I/O devices

 Specify the arithmetic and logic operations to be performed

 Program

 Data

 Used as operands by the instructions

 Source program

 Encoded in binary code – 0 and 1


INPUT UNIT
 Accept information through input devices.

 Common input device is keyboard

 Key is pressed the letter or number is translated to binary code


and transmitted to processor.

 Other input devices are touchpad, mouse, joystick, and trackball.

 Microphone capture audio input

 Cameras capture video input


Memory Unit
 Store programs and data.

 Two classes
 Primary Storage

 Secondary Storage
Memory Unit
 Primary Memory

 Main memory

 Fast

 Programs must be stored in memory while they are being executed

 Large number of semiconductor storage cells

 Processed in words

 Address

 RAM and memory access time

 Memory hierarchy – cache, main memory


Memory Unit
 Cache Memory

 Adjunct to the main memory, a smaller, faster RAM unit, called a cache.

 Hold sections of a program that are currently being executed.

 Start of program execution, the cache is empty.

 Number of instructions are executed repeatedly as happens in a program


loop.

 Primary memory - expensive and does not retain information when


power is turned off.
Memory Unit
 Secondary Memory

 less expensive, permanent secondary storage is used when large


amounts of data and many programs have to be stored, particularly for
information that is accessed infrequently.
Hold sections of a program that are currently being executed.

 Access times for secondary storage are longer than for primary
memory.

 magnetic disks, optical disks (DVD and CD), and flash memory
devices.
Arithmetic and Logic Unit
 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.

 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 - laser printers, or ink jet streams.

 Such printers may generate output at speeds of 20


or more pages per minute.
Control Unit
 All computer operations are controlled by the control unit.

 The timing signals that govern the I/O transfers are also generated by the control unit.

 Control unit is usually distributed throughout the machine instead of standing alone.

 Operations of a computer:
 Accept information in the form of programs and data through an input unit and store it in the
memory

 Fetch the information stored in the memory, under program control, into an ALU, where the
information is processed

 Output the processed information through an output unit

 Control all activities inside the machine through a control unit


Basic Operational Concepts
 Program stored in the memory.

 Individual instructions are brought from the memory into the processor which
executes operation.

 Data to be used as instruction operands are also stored in the memory.

 Instruction

Load R2, LOC

• Reads the contents of a memory location and loads them into processor register
R2.

• The original contents of location LOC are preserved register R2 are overwritten.
Basic Operational Concepts
 After operands have been loaded from memory into processor
registers, arithmetic or logic operations can be performed on
them.

 For example, the instruction

 Add R4, R2, R3


adds the contents of registers R2 and R3, then places their
sum into register R4.
Basic Operational Concepts
 They can be transferred to the memory using instructions such
as
Store R4, LOC

 operand in register R4 to memory location LOC.

 The original contents of location LOC are overwritten.

 R4 are preserved.

 Load and Store instructions, transfers between the memory and


the processor
Basic Operational Concepts
 Special purpose register

 IR

 PC

 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.
Basic Operational Concepts
 General-purpose registers R0 through Rn-1, often
called processor registers.

 The processor-memory interface is a circuit which


manages the transfer of data between the main
memory and the processor.

 Read control signal. (word read from memory)

 Write control signal. (word written into memory)


Performance
 The most important measure of the performance of a computer is
how quickly it can execute
programs.

 The speed with which a computer executes programs is affected by


 Instruction set

 Hardware

 Software

 Operating system
Defining Performance
 If you were running a program on two different desktop computers,

 How you find which one faster?

 So our interest is to reduce response time (the time between the


start and completion of a task)

 Also known as execution time.

 The total time required for the computer to complete a task,


including disk accesses, memory accesses, I/O activities, operating
system overhead, CPU execution time, and so on.
Defining Performance
 Throughput or Bandwidth

 The total amount of work done in a given time

 To maximize performance, we want to minimize response time or


execution time for some task.

 Relate performance and execution time for a computer X:


Defining Performance
 We will use the phrase “X is n times faster than Y”—or
equivalently “X is n times as fast as Y”—to mean

If X is n times as fast as Y, then the execution time on Y is n


times as long as it is on X:
Example
 If computer A runs a program in 10 seconds and computer B runs
the same program in 15 seconds, how much faster is A than B?

Ans 1.5
Measuring Performance
 Time is the measure of computer performance: the computer that
performs the same amount of work in the least time is the fastest.

 Computers are often shared, however, and a processor may work


on several programs simultaneously.

 Hence, we often want to distinguish between the elapsed time


and the time over which the processor is working on our behalf.

 CPU execution time or simply CPU time, is the time the CPU
spends computing for this task
Measuring Performance
 CPU time can be further divided into the CPU time spent
in the program, called user CPU time, and the CPU time
spent in the operating system performing tasks on behalf of
the program, called system CPU time.

 Use the term system performance to refer to elapsed time


on an unloaded system

 CPU performance to refer to user CPU time.


Measuring Performance
 To improve performance time is not only the constraint and other metrics
is how fast the hardware can perform basic functions.

 All computers are constructed using a clock that determines when events
take place in the hardware.

 These discrete time intervals are called clock cycles (or ticks, clock ticks,
clock periods, clocks, cycles)

 Designers refer to the length of a clock period both as the time for a
complete clock cycle (e.g., 250 picoseconds, or 250 ps) and as the clock
rate (e.g., 4 gigahertz, or 4 GHz), which is the inverse of the clock period.
CPU Performance and Its Factors

 CPU execution time for a program =


CPU clock cycles for a program X Clock cycle
time

 Clock rate:
Instruction Performance
 CPU clock cycles = Instructions for a program X
Average clock cycles per instruction

 Te term clock cycles per instruction, which is the average


number of clock cycles each instruction takes to execute, is
often abbreviated as CPI.
The Classic CPU Performance Equation

 CPU time = Instruction count X CPI X Clock cycle time

 since the clock rate is the inverse of clock cycle time:


Instructions: Language of the Computer

 To command a computer’s hardware, you must


speak its language.

 The words of a computer’s language are called


instructions.

 Its vocabulary is called an instruction set.


Operations of the Computer Hardware
 Every computer must be able to perform arithmetic.

 Every computer must be able to perform arithmetic.

add a, b, c

 Instructs a computer to add the two variables b and c and to put


their sum in a.

 Each MIPS arithmetic instruction performs only one operation


and must always have exactly three variables.
Operations of the Computer Hardware

 For example, suppose we want to place the sum of


four variables b, c, d, and e into variable a.

 add a, b, c # The sum of b and c is placed in a

 add a, a, d # The sum of b, c, and d is now in a

 add a, a, e # The sum of b, c, d, and e is now in a


Operations of the Computer Hardware

 Requiring every instruction to have exactly three


operands, no more and no less.

 Design Principle 1: Simplicity favors regularity


Operations of the Computer Hardware

 high-level programming language:

 a = b + c;

 d = a – e;

 The translation from C to MIPS assembly language


instructions is performed by the compiler.

 add a, b, c

 sub d, a, e
Operations of the Computer Hardware

 A somewhat complex statement contains the five


variables f, g, h, i, and j:

 f = (g + h) – (i + j);

 What might a C compiler produce?


Operands of the Computer Hardware

 A limited number of special locations built directly


in hardware called registers.

 Registers are primitives used in hardware design

 The size of a register in the MIPS architecture is 32


bits;

 Groups of 32 bits - word


Operands of the Computer Hardware
 Registers is the limited number of registers, typically 32 on
current computers.

 The reason for the limit of 32 registers may be found in the


second of our three underlying design principles of hardware
technology:

 Design Principle 2: Smaller is faster.

 A very large number of registers may increase the clock cycle


time
Operands of the Computer Hardware

 Simply write instructions using numbers for registers,


from 0 to 31,

 The MIPS convention is to use two-character names


following a dollar sign to represent a register.

 we will use $s0, $s1, . . . for registers that correspond to


variables in C

 $t0, $t1, . . . for temporary registers


Operands of the Computer Hardware

 f = (g + h) – (i + j);

 Th e variables f, g, h, i, and j are assigned to the


registers $s0, $s1, $s2, $s3, and $s4, respectively.

 What is the compiled MIPS code?


Operands of the Computer Hardware

 add $t0,$s1,$s2 # register $t0 contains g + h add


$t1,$s3,$s4 # register $t1 contains i + j sub
$s0,$t0,$t1 # f gets $t0 – $t1, which is (g +
h)–(i + j)
Representing Instructions in the Computer

 Instructions are kept in the computer as a series of


high and low electronic signals and may be
represented as numbers.

 Each piece of an instruction can be considered as


an individual number.
Representing Instructions in the Computer

 In MIPS assembly language, registers $s0 to $s7 map


onto registers 16 to 23

 Registers $t0 to $t7 map onto registers 8 to 15.

 Hence, $s0 means register 16, $s1 means register 17,


$s2 means register 18, . . . ,

 $t0 means register 8, $t1 means register 9, and so on


Representing Instructions in the Computer

 Translating a MIPS Assembly Instruction into a


Machine Instruction

 add $t0,$s1,$s2

 The decimal representation is


0 17 18 8 0 32

 Each of these segments of an instruction is called a


field.
Representing Instructions in the
Computer
 The first and last fields (containing 0 and 32 in this
case) perform addition.
 The second field source operation (17 = $s1)
 Third field another source operation (18=$s2)
 Fourth field receive the addition values 8=$t1
 The fifth field is unused in this instruction, so it is
set to 0.
Representing Instructions in the
Computer
 Binary representation

 This layout of the instruction is called the instruction


format.
 To distinguish it from assembly language, we call the
numeric version of instructions machine language and
a sequence of such instructions machine code.
Representing Instructions in the
Computer
 Almost all computer data sizes are multiples of 4,
hexadecimal (base 16) numbers are popular.
Representing Instructions in the
Computer
 Convert hexadecimal to binary
eca8 6420
Representing Instructions in the
Computer
 Convert binary to hexadecimal
0001 0011 0101 0111 1001 1011 1101 1111two
Representing Instructions in the
Computer
 MIPS fields
 MIPS fields are given names to make them easier
to discuss:
Representing Instructions in the
Computer
 op: Basic operation of the instruction, traditionally called
the opcode.
 rs: The first register source operand.
 rt: The second register source operand.
 rd: The register destination operand. It gets the result of the
operation.
 shamt: Shift amount
 funct: Function code for each operation.
Representing Instructions in the
Computer
 Requiring different kinds of instruction formats for
different kinds of instructions.
 R-type (for register) or R-format.
 A second type of instruction format is called I-type
(for immediate) or I-format
Representing Instructions in the
Computer
 lw $t0,32($s3)
 19 (for $s3) is placed in the rs field
 8 (for $t0) is placed in the rt field,
 32 is placed in the address field.
Representing Instructions in the
Computer
Representing Instructions in the
Computer
 Example;
 what the programmer writes to what the computer
executes
 If $t1 has the base of the array A and $s2
corresponds to h, the assignment statement
 A[300] = h + A[300];
Representing Instructions in the
Computer
 lw $t0,1200($t1)
 add $t0,$s2,$t0
 sw $t0,1200($t1)
Logical Operations
 It was useful to operate on fields of bits within a
word or even on individual bits.
Shift
 The first class of such operations is called shifts.
 They move all the bits in a word to the left or right,
filling the emptied bits with 0s.
 For example, if register $s0 contained
0000 0000 0000 0000 0000 0000 0000 1001two = 9ten
 instruction to shift left by 4
0000 0000 0000 0000 0000 0000 1001 0000 two = 144ten
Shift
 The actual name of the two MIPS shift instructions are
called shift left logical (sll) and shift right logical (srl).
 Assuming that the original value was in register $s0
and the result should go in register $t2:
sll $t2,$s0,4 # reg $t2 = reg $s0 << 4 bits
AND
 A logical bit by-bit operation with two operands that calculates a 1 only
if there is a 1 in both operands.
 For example, if register $t2 contains
0000 0000 0000 0000 0000 1101 1100 0000two
and register $t1 contains
0000 0000 0000 0000 0011 1100 0000 0000two
 executing the MIPS instruction
and $t0,$t1,$t2
 register $t0 would be
0000 0000 0000 0000 0000 1100 0000 0000two
OR
 A logical bit-by bit operation with two operands that calculates a
1 if there is a 1 in either operand.
 For example, if register $t2 contains
0000 0000 0000 0000 0000 1101 1100 0000two
and register $t1 contains
0000 0000 0000 0000 0011 1100 0000 0000two
 executing the MIPS instruction
or $t0,$t1,$t2
 0000 0000 0000 0000 0011 1101 1100 0000two
NOT
 A logical bit-bybit operation with one operand that
inverts the bits; that is, it replaces every 1 with a 0,
and every 0 with a 1.
NOR
 A logical bit-by bit operation with two operands
that calculates the NOT of the OR of the two
operands. Tat is, it calculates a 1 only if there is a 0
in both operands.
 nor $t0,$t1,$t3
 1111 1111 1111 1111 1100 0011 1111 1111two
Instructions for Making Decisions
 Decision making is commonly represented in
programming languages using the if statement,
sometimes combined with go to statements and
labels.
 Similar to an if statement with a go to.
Instructions for Making Decisions
 The first instruction is
beq register1, register2, L1
 This instruction means go to the statement labelled L1 if
the value in register1 equals the value in register2.
 The mnemonic beq stands for branch if equal.
 The second instruction is
bne register1, register2, L1
 branch if not equal
Instructions for Making Decisions
 Compiling if-then-else into Conditional Branches
 if (i == j) f = g + h; else f = g – h;
bne $s3,$s4,Else
add $s0,$s1,$s2
Else:sub $s0,$s1,$s2
Exit:
Loops
 iterating a computation—found in loops
 Here is a traditional loop in C:
while (save[i] == k)
i += 1;

 Assume that i and k correspond to registers $s3 and $s5


and the base of the array save is in $s6.
 What is the MIPS assembly code corresponding to this
C segment?
Loops
 Loop: sll $t1,$s3,2 # Temp reg $t1 = i * 4
 To get the address of save[i]
 add $t1,$t1,$s6 # $t1 = address of save[i]
 lw $t0,0($t1) # Temp reg $t0 = save[i]
 The next instruction performs the loop test,
 bne $t0,$s5, Exit # go to Exit if save[i] ≠ k
 addi $s3,$s3,1 #i=i+1
 j Loop # go to Loop
Exit:
MIPS Addressing Mode
 What is addressing modes?
 They specify the mechanism by which the
operands data can be located.
MIPS Addressing Mode
 Various addressing modes
 Immediate
 Direct
 Indirect
 Register
 Register Indirect
 Indexed
 Stack
 Relative
 Autoincrement
 Autodecrement
MIPS Addressing Mode
 Immediate
 where the operand is a constant within the
instruction itself.
 Example
 addi #25
 addi $s1,$s2,#42;
MIPS Addressing Mode
 Direct
 The instruction contain fields that holds memory
address of the operand.
 Example
 add $s1,206A;

OPCODE OPERAND ADDRESS


MIPS Addressing Mode
OPCODE OPERAND ADDRESS

Operand
MIPS Addressing Mode
 Indirect
 The instruction contain fields that holds memory
address which turns holds memory address of the
of the operand.
 Ex
 add $s0,(206A)
MIPS Addressing Mode
OPCODE OPERAND ADDRESS

206A

Operand
MIPS Addressing Mode
 Register addressing
 The operand held in a register and instruction
specifies register number.
 Ex
 add $s0,$s1,$s2
MIPS Addressing Mode
OPCODE Register no

Register bank

operand
MIPS Addressing Mode
 Register indirect addressing
 The instruction specifies a register and register
holds the memory address
 Ex
 add $s0,$s1,($s2)
MIPS Addressing Mode
OPCODE Register no

Register bank

206A
memory

operand
MIPS Addressing Mode
 Relative addressing
 The instruction specifies an offset of displacement
which is added to the pc to get an effective address.
MIPS Addressing Mode
 Indexed addressing
 The instruction specifies an offset of displacement
which is added to the index register to get an
effective address.
 Ex load $s2,1050($s3)
 $s2=mem[1050+$s3]
MIPS Addressing Mode
 Indexed addressing
 The instruction specifies an offset of displacement
which is added to the index register to get an
effective address.
 Ex load $s2,1050($s3)
 $s2=mem[1050+$s3]

You might also like