31
Computer Architecture I Lecture Notes Dr. Ali Muhtaroğlu Fall 2009 METU Northern Cyprus Campus References: Patterson&Hennessy, “Computer Organization and Design” (3 rd Ed.), Kaufmann, 2007. Stallings, “Computer Organization & Architecture” (7 th Ed.), Pearson, 2006. Mano & Kime, “Logic and Computer Design Fundamentals”, 4th Ed., Prentice Hall, 2008. Brown & Vranesic, “Fund. Of Dig. Logic with VHDL Design” (2nd Ed.), McGraw Hill, 2005. Dr. Patterson’s and Dr. Mary Jane Irwin’s (Penn State) Lecture notes

Computer Architecture I Lecture Presentation 2

Embed Size (px)

DESCRIPTION

Computer Archıtecture Intro Notes 2

Citation preview

Page 1: Computer Architecture I Lecture Presentation 2

Computer Architecture I

Lecture Notes

Dr. Ali Muhtaroğlu

Fall 2009

METU Northern Cyprus Campus

References:

Patterson&Hennessy, “Computer Organization and Design” (3rd Ed.), Kaufmann, 2007.

Stallings, “Computer Organization & Architecture” (7th Ed.), Pearson, 2006.

Mano & Kime, “Logic and Computer Design Fundamentals”, 4th Ed., Prentice Hall, 2008.

Brown & Vranesic, “Fund. Of Dig. Logic with VHDL Design” (2nd Ed.), McGraw Hill, 2005.

Dr. Patterson’s and Dr. Mary Jane Irwin’s (Penn State) Lecture notes

Page 2: Computer Architecture I Lecture Presentation 2

The Computer Components and Program Concept

Lecture 3

2Ali Muhtaroğlu

Page 3: Computer Architecture I Lecture Presentation 2

Some Terminology: Structure and Function

3Ali Muhtaroğlu

• The computer is a hierarchical system, where each level ofthe hierarchy can be defined by the designer in terms of astructure and the function of components within thatstructure.

• Structure is the way in which components relate to eachother

• Function is the operation of individual components as part ofthe structure

Page 4: Computer Architecture I Lecture Presentation 2

Functional View

4Ali Muhtaroğlu

4 computer functions:

1. Data processing– The main purpose of a computer

2. Data storage– Short or long term memory

3. Data movement– Input/Output (I/O): Direct connection

– Data communications: Remote

4. Control− Orchestrates the operation of

functional parts

Page 5: Computer Architecture I Lecture Presentation 2

Functional View: Basic Computer Operations

5Ali Muhtaroğlu

a) Data Movement b) Storage

c) Processing from/tostorage

d) Processing en routebetween storage and I/O

Page 6: Computer Architecture I Lecture Presentation 2

Structural View : Top Level

6Ali Muhtaroğlu

Computer

Main Memory

InputOutput

SystemsInterconnection

Peripherals

Communicationlines

CentralProcessing Unit

Computer

Page 7: Computer Architecture I Lecture Presentation 2

Structural View : Central Processing Unit

7Ali Muhtaroğlu

Computer Arithmeticand Logic Unit

ControlUnit

Internal CPUInterconnection

Registers

CPU

I/O

Memory

SystemBus

CPU

Control Unit: Controls the operation of the CPU and hence the computer

Arithmetic and Logic Unit (ALU): Performs the computer’s data processing functions

Registers: Provide storage internal to the CPU

CPU interconnection: Provides for communication among the control unit, ALU, and

registers

Page 8: Computer Architecture I Lecture Presentation 2

Structural View : Control Unit

8Ali Muhtaroğlu

Below is one possible structure of control unit, which isimplemented using microprogramming – details to come later.

CPU

ControlMemory

Control Unit Registers and Decoders

SequencingLogic

ControlUnit

ALU

Registers

InternalBus

Control Unit

Page 9: Computer Architecture I Lecture Presentation 2

Hardwired Program Example

9Ali Muhtaroğlu

Logic: Timing Diagram:

• The logic constructed to solve a particular problem can bethought of as a hardware “program”. The solution issometimes referred to as hardwired program.

• This example has data and clock inputs, and an output toreport the data back.

• What are the advantages and disadvantages of this solution?

clk

IN1

IN2

IN3

IN4

R1

R2

R3

R4

R5

B

C

D

A

B

C

D

A

A-((B+C)-D)

OUT

clk

IN1 IN2

IN3

IN4

x+y

x y

x-y

x y

x-y

x y

R1 R2

R3

R4

R5

OUT

Page 10: Computer Architecture I Lecture Presentation 2

A more Generalized Solution

10Ali Muhtaroğlu

Logic:

• In this particular design, control signals (SEL1, SEL2, A/S) can be sequenced tosolve a variety of problems involving addition and subtraction.

• An instruction set can be defined to allow software sequencing of the controlsignals. e.g. ADDR1R2 : R3 R1+R2 ; SUBR1R3 : R3 R1-R3 … etc.

• Need hardware to interpret each instruction and generate the correct controlsignals i.e. Control Unit. Also need storage for instructions, and perhaps data i.e.Memory.

clk

IN1 IN2

ADD:x+y

SUB:x-y

x y

A(0)/S(1)

OUT

SEL1 SEL2

R1 R2

R3

0 1 0 1

Page 11: Computer Architecture I Lecture Presentation 2

A more Generalized Solution

11Ali Muhtaroğlu

Logic:

• In this particular design, control signals (SEL1, SEL2, A/S) can be sequenced tosolve a variety of problems involving addition and subtraction.

• An instruction set can be defined to allow software sequencing of the controlsignals. e.g. ADDR1R2 : R3 R1+R2 ; SUBR1R3 : R3 R1-R3 … etc.

• Need hardware to interpret each instruction and generate the correct controlsignals i.e. Control Unit. Also need storage for instructions, and perhaps data i.e.Memory.

clk

IN1 IN2

ADD:x+y

SUB:x-y

x y

A(0)/S(1)

OUT

SEL1 SEL2

R1 R2

R3

0 1 0 1

How do we do the same

operation with this

hardware?

A-((B+C)-D)

Page 12: Computer Architecture I Lecture Presentation 2

A more Generalized Solution

12Ali Muhtaroğlu

Logic: Timing Diagram:

• In this particular design, control signals (SEL1, SEL2, A/S) can be sequenced tosolve a variety of problems involving addition and subtraction.

• An instruction set can be defined to allow software sequencing of the controlsignals. e.g. ADDR1R2 : R3 R1+R2 ; SUBR1R3 : R3 R1-R3 … etc.

• Need hardware to interpret each instruction and generate the correct controlsignals i.e. Control Unit. Also need storage for instructions, and perhaps data i.e.Memory.

clk

IN1 IN2

ADD:x+y

SUB:x-y

x y

A(0)/S(1)

OUT

SEL1 SEL2

R1 R2

R3

0 1 0 1

clk

IN1

IN2

SEL1

SEL2

R1

R2

R3

B A

C D

B A

C D

OUT1 OUT2

A/S

(B+C) (B+C)-D

OUT3

A-((B+C)-D)

Page 13: Computer Architecture I Lecture Presentation 2

A more Generalized Solution

13Ali Muhtaroğlu

Logic: Timing Diagram:

• In this particular design, control signals (SEL1, SEL2, A/S) can be sequenced tosolve a variety of problems involving addition and subtraction.

• An instruction set can be defined to allow software sequencing of the controlsignals. e.g. ADDR1R2 : R3 R1+R2 ; SUBR1R3 : R3 R1-R3 … etc.

• Need hardware to interpret each instruction and generate the correct controlsignals i.e. Control Unit. Also need storage for instructions, and perhaps data i.e.Memory.

• What are the advantages and disadvantages of this solution?

clk

IN1 IN2

ADD:x+y

SUB:x-y

x y

A(0)/S(1)

OUT

SEL1 SEL2

R1 R2

R3

0 1 0 1

clk

IN1

IN2

SEL1

SEL2

R1

R2

R3

B A

C D

B A

C D

OUT1 OUT2

A/S

(B+C) (B+C)-D

OUT3

A-((B+C)-D)

Page 14: Computer Architecture I Lecture Presentation 2

Program Concept

14Ali Muhtaroğlu

Sequence of arithmetic and logic functions

Data Results

Programming in Hardware:

• Inflexible

General-purpose arithmetic and logic functions

Data Results

Instruction Interpreter

Instructioncodes

Programming in software:

• General purpose hardware cando different tasks, given correctcontrol of signals.

• Instead of rewiring, supply anew set of control signals

Page 15: Computer Architecture I Lecture Presentation 2

15Ali Muhtaroğlu

What is a program?

• A sequence of steps

• For each step, an arithmetic or logical (or simple movement)operation is done

• For each operation, a different set of control signals is needed

Page 16: Computer Architecture I Lecture Presentation 2

Function of Control Unit

16Ali Muhtaroğlu

• For each operation a unique code is provided

– e.g. ADD, MOVE

• A hardware segment accepts the code and issues the control signals

• We have a computer!

What is a program?

• A sequence of steps

• For each step, an arithmetic or logical (or simple movement)operation is done

• For each operation, a different set of control signals is needed

Page 17: Computer Architecture I Lecture Presentation 2

17Ali Muhtaroğlu

Computer Components

• The Control Unit and the Arithmetic and Logic Unit constitute the Central Processing Unit

• Data and instructions need to get into the system and results out

– Input/output

• Temporary storage of code and results is needed

– Main memory

Page 18: Computer Architecture I Lecture Presentation 2

18Ali Muhtaroğlu

Computer Components: Top Level View

* Assumes Isolated I/O (vs. Memory Mapped I/O)

Page 19: Computer Architecture I Lecture Presentation 2

19Ali Muhtaroğlu

Instruction Cycle

• Two steps (three steps if you also count Decode):

– Fetch

– (Decode)

– Execute

• Fetch/(Decode)/Execute cycle will continue till the machine is turned off, an error has occurred, or a HALT (or similar) instruction has been encountered.

Page 20: Computer Architecture I Lecture Presentation 2

20Ali Muhtaroğlu

Fetch Cycle• Program Counter (PC) holds address of next instruction to fetch

• Processor fetches instruction from memory location pointed to by PC

• Increment PC

– Unless told otherwise

• Instruction loaded into Instruction Register (IR)

• Processor interprets (decodes) instruction and performs required actions

Execute Cycle• Processor-memory

– data transfer between CPU and main memory

• Processor I/O

– Data transfer between CPU and I/O module

• Data processing

– Some arithmetic or logical operation on data

• Control

– Alteration of sequence of operations e.g. jump

• Combination of above

Page 21: Computer Architecture I Lecture Presentation 2

21Ali Muhtaroğlu

Example: Hypothetical Machine

Opcode Address

0 3 4 15

Instruction Format:

Magnitude

0 15

Integer Format:

Page 22: Computer Architecture I Lecture Presentation 2

22Ali Muhtaroğlu

Example: Hypothetical Machine

Opcode Address

0 3 4 15

Instruction Format:

Magnitude

0 15

Integer Format:

Program Counter (PC) = Address of instruction

Instruction Register (IR) = Instruction being executed

Accumulator (AC) = Temporary storage

Internal CPU Registers:

Page 23: Computer Architecture I Lecture Presentation 2

23Ali Muhtaroğlu

Example: Hypothetical Machine

Opcode Address

0 3 4 15

Instruction Format:

Magnitude

0 15

Integer Format:

Program Counter (PC) = Address of instruction

Instruction Register (IR) = Instruction being executed

Accumulator (AC) = Temporary storage

Internal CPU Registers:

0001 = Load AC from memory

0010 = Store AC to memory

0101 = Add to AC from memory (result goes back to AC)

Partial list of opcodes:

Page 24: Computer Architecture I Lecture Presentation 2

24Ali Muhtaroğlu

Example: Hypothetical Machine

Opcode Address

0 3 4 15

Instruction Format:

Magnitude

0 15

Integer Format:

Program Counter (PC) = Address of instruction

Instruction Register (IR) = Instruction being executed

Accumulator (AC) = Temporary storage

Internal CPU Registers:

0001 = Load AC from memory

0010 = Store AC to memory

0101 = Add to AC from memory (result goes back to AC)

Partial list of opcodes:

Note: There can be 24 different opcodes

212=4096 memory words are directly accessible by the instruction.

Page 25: Computer Architecture I Lecture Presentation 2

25Ali Muhtaroğlu

Example Program Execution

Micro-Operation:

Fetch 1st Instruction

MAR & MBR data

transfers are not shown

(ignored for now.)

Opcode List:

0001 = Load AC from

memory

0010 = Store AC to

memory

0101 = Add to AC from

memory

Page 26: Computer Architecture I Lecture Presentation 2

26Ali Muhtaroğlu

Example Program Execution

Micro-Operation:

Fetch 1st Instruction

Decode and Execute

MAR & MBR data

transfers are not shown

(ignored for now.)

Opcode List:

0001 = Load AC from

memory

0010 = Store AC to

memory

0101 = Add to AC from

memory

Page 27: Computer Architecture I Lecture Presentation 2

27Ali Muhtaroğlu

Example Program Execution

Micro-Operation:

Fetch 1st Instruction

Decode and Execute

Fetch 2nd Instruction

MAR & MBR data

transfers are not shown

(ignored for now.)

Opcode List:

0001 = Load AC from

memory

0010 = Store AC to

memory

0101 = Add to AC from

memory

Page 28: Computer Architecture I Lecture Presentation 2

28Ali Muhtaroğlu

Example Program Execution

Micro-Operation:

Fetch 1st Instruction

Decode and Execute

Fetch 2nd Instruction

Decode and Execute

MAR & MBR data

transfers are not shown

(ignored for now.)

Opcode List:

0001 = Load AC from

memory

0010 = Store AC to

memory

0101 = Add to AC from

memory

Page 29: Computer Architecture I Lecture Presentation 2

29Ali Muhtaroğlu

Example Program Execution

Micro-Operation:

Fetch 1st Instruction

Decode and Execute

Fetch 2nd Instruction

Decode and Execute

Fetch 3rd Instruction

MAR & MBR data

transfers are not shown

(ignored for now.)

Opcode List:

0001 = Load AC from

memory

0010 = Store AC to

memory

0101 = Add to AC from

memory

Page 30: Computer Architecture I Lecture Presentation 2

30Ali Muhtaroğlu

Example Program Execution

Micro-Operation:

Fetch 1st Instruction

Decode and Execute

Fetch 2nd Instruction

Decode and Execute

Fetch 3rd Instruction

Decode and Execute

Opcode List:

0001 = Load AC from

memory

0010 = Store AC to

memory

0101 = Add to AC from

memory

MAR & MBR data

transfers are not shown

(ignored for now.)

Page 31: Computer Architecture I Lecture Presentation 2

31Ali Muhtaroğlu

Instruction Cycle State Diagram

This diagram incorporates the most flexible machine type where there may be

multiple operands in a single instructoin referencing the memory for multiple

data reads or writes.

Processor and

Memory or I/O

Data exchange

Internal

Processor

Operations