Computer Hardware What goes on inside?. Deeper.

Post on 21-Dec-2015

223 views 2 download

Tags:

Transcript of Computer Hardware What goes on inside?. Deeper.

Computer Hardware

What goes on inside?

Deeper

Deeper

Not that deep

A simple Computer

CentralProcessing

Unit

CPU

Performs all calculations and decisions

Add, Subtract, …>, <, ==decide what to donext

A simple Computer

CentralProcessing

Unit

CPU

Memory

Stores most information

Memory is a large array of integers

0 1231 2342 123 3414 -235 31246 127 42318 29 -2310 011 70212 3613 102314 -6915 937216 3617 1269318 619 -69

Memory - array of integers

• How does it store text?

• How does it store images?

• How does it store audio?

• How does it store a program?

0 1231 2342 123 3414 -235 31246 127 42318 29 -2310 011 70212 3613 102314 -6915 937216 3617 1269318 619 -69

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Wires that pass the index of the location in memory thatthe CPU wants to get or change

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Wires that pass the index of the location in memory thatthe CPU wants to get or change

010010

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Number of wires = number of bitsNumber of bits = range of possible indexes

= total possible memory

010010

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Twice as much memory adds how many more address wires?

1 more

010010

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Data

Wires that pass numbers from CPU to Memoryor from Memory to CPU

A simple Computer

CentralProcessing

Unit

CPU

Memory

RAM

Address

Data

RAM - Random Access Memory is the main memory of a computer.

The size of RAM is the length of the array

How to represent a program in memory

• Program is a series of simple instructions– Each instruction is an integer

• CPU – Goes to a location in memory– Gets an instruction– Does what the instruction says– Moves to the next instruction

• Does this millions of times per second

A simple fake computer

CPU

Program Counter - address (index) of the next

instruction

Registersprivate memory for the CPU

Every instruction has a number

OpCodes 0 - Halt1 - Load2 - Store3 - Add4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

Instruction Format:

Digit 1 OpCode

Digit 2 Register

Digit 3-4 Memory Address

OpCodes 0 - Halt1 - Load2 - Store3 - Add4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

Instruction Format:

Digit 1 OpCode

Digit 2 Register

Digit 3-4 Memory Address

OpCodes 0 - Halt1 - Load2 - Store

3 - Add4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

3 1 10

Instruction Format:

Digit 1 OpCode

Digit 2 Register

Digit 3-4 Memory Address

OpCodes 0 - Halt1 - Load2 - Store

3 - Add4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

3 1 100 751 -3302 423 13

Reg[1]=Reg[1]+Mem[10]

Instruction Format:

Digit 1 OpCode

Digit 2 Register

Digit 3-4 Memory Address

OpCodes 0 - Halt1 - Load2 - Store

3 - Add4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

3 1 100 751 -3302 423 13

?

Instruction Format:

Digit 1 OpCode

Digit 2 Register

Digit 3-4 Memory Address

OpCodes 0 - Halt1 - Load2 - Store3 - Add4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

4 2 30

Reg[2]=Reg[2]-Mem[30]

Instruction Format:

Digit 1 OpCode

Digit 2 Register

Digit 3-4 Memory Address

OpCodes 0 - Halt1 - Load2 - Store3 - Add

4 - Subtract5 - Divide6 - Multiply7 - Is Greater Than 0?8 - Goto9 - Branch If Greater Than 0!

4 2 30

A simple program

1 0 07

Load location 7 into register 0

Reg[0]=Mem[7]PC = PC+1

A simple program

1 2 08

Load location 8 into register 2

Reg[2]=Mem[8]PC = PC+1

A simple program

3 0 07

Add location 7 to register 0

Reg[0]=Reg[0]+Mem[7]PC = PC+1

A simple program

8 2 00

GOTO the address stored in register 2

PC = Reg[2]

A simple program

3 0 07

Add location 7 to register 0

Reg[0]=Reg[0]+Mem[7]PC=PC+1

A simple program

8 2 00

GOTO the address stored in register 2

PC = Reg[2]

A simple program

3 0 07

Add location 7 to register 0

Reg[0]=Reg[0]+Mem[7]PC=PC+1

Clock speed of a processor

• Number of instructions per second that can be performed

• 100 MHz = 100 Million times per second

• 1.5 GHz = 1.5 Billion instructions per second

So what is a program?

• A file of bytes

• Operating system copies the file into memory – When select the program from Start menu– When you double click on the program

• Operating system sets PC to address of first byte of the program in memory

• Program begins to run

Programs and Data

Program (instructions)

Data

What is the difference?

If the PC points to itthen it is an instruction

Review

• CPU - Central Processing Unit– Does calculating and deciding

• Memory - RAM– Stores data and programs– Array of integers– Size of RAM = the length of this array

Review

• Program– List of instructions

– Each instruction is an integer that the CPU decodes

– Program counter (PC) is the address of the next instruction

• Copy program from file into memory– Set PC to start of the program