computer architecture – an introduction

Post on 13-Jun-2015

965 Views

Category:

Engineering

6 Downloads

Preview:

Click to see full reader

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

Computer Architecture – An Introduction

CS2052 Computer ArchitectureComputer Science & Engineering

University of Moratuwa

Dilum BandaraDilum.Bandara@uom.lk

2

From Outside

Input

Output

ProcessorMemoryHard diskDVD ROMGraphics cardEthernet

Source: techwench.com

3

Source: Daniel Zanetti, wikimedia.org

From Outside (Cont.)

Source: Amazon.com

Touch padTouch screenWireless

Screen sizeWeightBattery capacitySD Card slotSensors

4

From Inside

Source: http://rays-place.net

Source: http://news.techgenie.com

5

From Inside (Cont.)

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

6

From Inside (Cont.)

iPhone 6

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?

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

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

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

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

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

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

14

Instruction Register (IR)

Once fetched, instructions are stored in IR for execution

Located closely to control unit which decodes the instruction

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

16

FLAG/STATUS Register Individual bits Indicate status of ALU operations

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

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

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

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

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

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

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

23

Sample Program (Cont.)

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

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

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

26

Sample Program (Cont.)

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

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

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

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

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

31

Programming Hierarchies

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

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

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

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

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

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

top related