computer architecture – an introduction

36
Computer Architecture – An Introduction CS2052 Computer Architecture Computer Science & Engineering University of Moratuwa Dilum Bandara [email protected]

Upload: dilum-bandara

Post on 13-Jun-2015

965 views

Category:

Engineering


6 download

DESCRIPTION

Overview on high-level design of internal components of a computer. Cover step-by-step execution of a program through ALU while accessing & updating registers

TRANSCRIPT

Page 1: Computer Architecture – An Introduction

Computer Architecture – An Introduction

CS2052 Computer ArchitectureComputer Science & Engineering

University of Moratuwa

Dilum [email protected]

Page 2: Computer Architecture – An Introduction

2

From Outside

Input

Output

ProcessorMemoryHard diskDVD ROMGraphics cardEthernet

Source: techwench.com

Page 3: Computer Architecture – An Introduction

3

Source: Daniel Zanetti, wikimedia.org

From Outside (Cont.)

Source: Amazon.com

Touch padTouch screenWireless

Screen sizeWeightBattery capacitySD Card slotSensors

Page 4: Computer Architecture – An Introduction

4

From Inside

Source: http://rays-place.net

Source: http://news.techgenie.com

Page 5: Computer Architecture – An Introduction

5

From Inside (Cont.)

Source: www.laptopaid.comSource: http://techgoesboom.com

Page 6: Computer Architecture – An Introduction

6

From Inside (Cont.)

iPhone 6

Page 7: Computer Architecture – An Introduction

7

What We Are Going To Study? How these internal components look like?

Top-down approach with schematics How do they fit together? How to program them? How to improve their performance?

Page 8: Computer Architecture – An Introduction

8

Very High-Level View of a Computer

CPU – execute instructions Memory – store program & data IO devices – receive inputs & produce outputs Bus – interconnects everything by transferring data

Central Processing Unit (CPU)

Main Memory

Input/output (IO) Devices

System Bus

Page 9: Computer Architecture – An Introduction

Blocks of a Microprocessor

9

Program Memory Instruction

Register

STACK Program CounterInstruction

Decoder

Timing, Control, & Register selection

Accumulator

RAM & Data

Registers

ALU

IO

IOFLAG &SpecialPurposeRegisters

Source: Makis Malliris & Sabir Ghauri, UWE

Page 10: Computer Architecture – An Introduction

10

Blocks of a Microprocessor (Cont.)

Literal Address

Operation

Program Memory

Instruction Register

STACK Program CounterInstruction

Decoder

Timing, Control and Register selection

Accumulator

RAM & Data

Registers

ALU

IO

IOFLAG &Special

FunctionRegisters

ClockReset Interrupts

Program Execution Section Register Processing Section

Set up Set upModify

Address

Internal data bus

Source: Makis Malliris & Sabir Ghauri, UWE

Page 11: Computer Architecture – An Introduction

11

Arithmetic & Logic Unit (ALU) Data processing

unit Arithmetic unit

Performs arithmetic operations

Logic unit Performs logical

operations

Accumulator

Source: Introduction to PIC Microcontroller – Part 1 by Khan Wahid

Page 12: Computer Architecture – An Introduction

12

Registers Type of memory located inside CPU Can hold a single piece of data

This data is useful in both data processing & control functionalities

Several types of CPU registers Program Counter (PC) Instruction Register (IR) Accumulator or working register Special purpose registers

Flag register General purpose registers

Page 13: Computer Architecture – An Introduction

13

Program Counter (PC)

Used to keep track of memory address of next instruction to be executed

When instructions are fetched, always instruction pointed by PC is fetched into CPU

Once the instruction is fetched, PC is updated to point to next instruction PC = PC + d

Page 14: Computer Architecture – An Introduction

14

Instruction Register (IR)

Once fetched, instructions are stored in IR for execution

Located closely to control unit which decodes the instruction

Page 15: Computer Architecture – An Introduction

15

Accumulator (A) / Working Register (W)

Results of arithmetic & logical operations always go to accumulator

Connected directly to output of ALU

Source: Introduction to PIC Microcontroller – Part 1 by Khan Wahid

Page 16: Computer Architecture – An Introduction

16

FLAG/STATUS Register Individual bits Indicate status of ALU operations

Source: www.plantation-productions.com/Webster/www.artofasm.com/Linux/HTML/RealArithmetic.html

Page 17: Computer Architecture – An Introduction

17

Internal Structure

A

E

D

C

B

ALU

Add

ress

Bus

Control Unit

IR

FLAG

ALU

PC

+1

Dat

a B

usC

TR

L B

us

Source : Dr. Chathura de Silva, CSE, UoM

Page 18: Computer Architecture – An Introduction

18

Sample Program

100: Load A,10101: Load B,15102: Add A,B103: STORE A,[20]

Load A,10

Load B,15

ADD A,B

STORE A,[20]

100

101

102

103

104

105

Program memory

18

19

20

21

Data memory

00

00

00

00

Page 19: Computer Architecture – An Introduction

19

Instruction Execution Sequence

1. Fetch next instruction from memory to IR

2. Change PC to point to next instruction

3. Determine type of instruction just fetched

4. If instruction needs data from memory, determine where it is

5. Fetch data if needed into register

6. Execute instruction

7. Go to step 1 & continue with next instruction

Page 20: Computer Architecture – An Introduction

20

Before execution of 1st fetch cycle

A

E

D

C

B

ALU

Add

ress

Bus

Control Unit

IR

FLAG

ALU

100

+1

Dat

a B

usC

TR

L B

us

Source: Dr. Chathura de Silva, CSE, UoM

Page 21: Computer Architecture – An Introduction

21

After 1st fetch cycle …

A

E

D

C

B

ALU

Add

ress

Bus

Control Unit

Load A,10

FLAG

ALU

101

+1

Dat

a B

usC

TR

L B

us

Page 22: Computer Architecture – An Introduction

22

After 1st instruction cycle …

10

E

D

C

B

ALU

Add

ress

Bus

Control Unit

Load A,10

FLAG

ALU

101

+1

Dat

a B

usC

TR

L B

us

Page 23: Computer Architecture – An Introduction

23

Sample Program (Cont.)

100: Load A,10101: Load B,15102: Add A,B

Page 24: Computer Architecture – An Introduction

24

After 2nd fetch cycle …

A

E

D

C

B

ALU

Add

ress

Bus

Control Unit

Load B,15

FLAG

ALU

102

+1

Dat

a B

usC

TR

L B

us

Page 25: Computer Architecture – An Introduction

25

After 2nd instruction cycle …

10

E

D

C

15

ALU

Add

ress

Bus

Control Unit

Load B,15

FLAG

ALU

102

+1

Dat

a B

usC

TR

L B

us

Page 26: Computer Architecture – An Introduction

26

Sample Program (Cont.)

100: Load A,10101: Load B,15102: Add A,B

Page 27: Computer Architecture – An Introduction

27

After 3rd fetch cycle …

10

E

D

C

15

ALU

Add

ress

Bus

Control Unit

ADD A,B

FLAG

ALU

103

+1

Dat

a B

usC

TR

L B

us

Page 28: Computer Architecture – An Introduction

28

After 3rd instruction cycle …

25

E

D

C

15

ALU

Add

ress

Bus

Control Unit

ADD A,B

FLAG

ALU

103

+1

Dat

a B

usC

TR

L B

us

Page 29: Computer Architecture – An Introduction

29

Architectural Differences Length of microprocessors’ data word

4, 8, 16, 32, 64, & 128 bit Speed of instruction execution

Clock rate & processor speed Size of direct addressable memory CPU architecture Instruction set Number & types of registers Support circuits Compatibility with existing software & hardware

development systems

Page 30: Computer Architecture – An Introduction

Microprocessor vs. Microcontroller Microprocessor – CPU & various IO functions are packed

as separate ICs Microcontroller – Most IO functions are integrated into

same package with CPU

30

Microprocessor

Clock

Program Memory

Data Storage

I/O

I/O

I/O

MicroprocessorCore

Program Memory

Real-time Clock

I/O

I/O

I/OData

Storage

Page 31: Computer Architecture – An Introduction

31

Programming Hierarchies

Source: Introduction to PIC Microcontroller – Part 1 by Khan Wahid

Page 32: Computer Architecture – An Introduction

Programming Language Levels Machine code (40s-50s)

0001000000111000 0001001000110100 0101110000000000 0001110000000000 0001001000110101

Hex notation (50s-60s) 1038 1234 5C00 1E00 1235

32Source: http://mentalfloss.com/article/53160/meet-refrigerator-ladies-who-programmed-eniac

Page 33: Computer Architecture – An Introduction

Programming Language Levels (Cont.) Assembler

Machine code (60s-70s).define const = 6num1: .byte [1]num2: .byte [2]move.b num1,d0addq.b #const,d0move.b d0,num2

High-level languages C code fragment (70s-80s)

#define const 6int num1, num2;num2 = num1 + const;

33

Page 34: Computer Architecture – An Introduction

34

When is Assembler Appropriate? Parts of a program where absolute speed is

critical More effective use of CPU registers & instruction set Can produce code that runs faster than that produced

by a compiler There may be no other way to access a

particular feature of hardware Compiler might not provide library functions to access

IO ports or to disable/enable interrupts Compiler might not take advantage of CPU special

instructions BCD arithmetic, binary-ASCII conversion, table lookups, high

speed copying of entire blocks of data

Page 35: Computer Architecture – An Introduction

35

Building Digital Solutions to Computational Problems

· Labs & design project· Product specs

· Algorithms, RTL, etc.· Flowcharts· State transition diagrams

· Logic equations· Circuit schematics· Verilog or VHDL code· Assembler· C, C++

· TTL Gates (AND, OR, XOR ... )· Programmable Logic· Custom ASICs· FPGAs· MCs, DSPs

Page 36: Computer Architecture – An Introduction

36

Real-World Performance Metrics

Commercial digital designs seek the most appropriate trade-offs for the target application

Time-to-market is also very important

Cost

Commodity Products

Speed

Scientific Computing,Simulation

Energy

Portable Devices

Capacity

Multimedia, Scientific Computing,

Simulation