37
Computer Hardware What goes on inside?

Computer Hardware What goes on inside?. Deeper

  • View
    223

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Computer Hardware What goes on inside?. Deeper

Computer Hardware

What goes on inside?

Page 2: Computer Hardware What goes on inside?. Deeper
Page 3: Computer Hardware What goes on inside?. Deeper

Deeper

Page 4: Computer Hardware What goes on inside?. Deeper

Deeper

Page 5: Computer Hardware What goes on inside?. Deeper

Not that deep

Page 6: Computer Hardware What goes on inside?. Deeper

A simple Computer

CentralProcessing

Unit

CPU

Performs all calculations and decisions

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

Page 7: Computer Hardware What goes on inside?. Deeper

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

Page 8: Computer Hardware What goes on inside?. Deeper

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

Page 9: Computer Hardware What goes on inside?. Deeper

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

Page 10: Computer Hardware What goes on inside?. Deeper

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

Page 11: Computer Hardware What goes on inside?. Deeper

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

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

= total possible memory

010010

Page 12: Computer Hardware What goes on inside?. Deeper

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Twice as much memory adds how many more address wires?

1 more

010010

Page 13: Computer Hardware What goes on inside?. Deeper

A simple Computer

CentralProcessing

Unit

CPU

Memory

Address

Data

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

Page 14: Computer Hardware What goes on inside?. Deeper

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

Page 15: Computer Hardware What goes on inside?. Deeper

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

Page 16: Computer Hardware What goes on inside?. Deeper

A simple fake computer

CPU

Page 17: Computer Hardware What goes on inside?. Deeper

Program Counter - address (index) of the next

instruction

Page 18: Computer Hardware What goes on inside?. Deeper

Registersprivate memory for the CPU

Page 19: Computer Hardware What goes on inside?. Deeper

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!

Page 20: Computer Hardware What goes on inside?. Deeper

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!

Page 21: Computer Hardware What goes on inside?. Deeper

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

Page 22: Computer Hardware What goes on inside?. Deeper

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

Page 23: Computer Hardware What goes on inside?. Deeper

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

Page 24: Computer Hardware What goes on inside?. Deeper

?

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

Page 25: Computer Hardware What goes on inside?. Deeper

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

Page 26: Computer Hardware What goes on inside?. Deeper

A simple program

1 0 07

Load location 7 into register 0

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

Page 27: Computer Hardware What goes on inside?. Deeper

A simple program

1 2 08

Load location 8 into register 2

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

Page 28: Computer Hardware What goes on inside?. Deeper

A simple program

3 0 07

Add location 7 to register 0

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

Page 29: Computer Hardware What goes on inside?. Deeper

A simple program

8 2 00

GOTO the address stored in register 2

PC = Reg[2]

Page 30: Computer Hardware What goes on inside?. Deeper

A simple program

3 0 07

Add location 7 to register 0

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

Page 31: Computer Hardware What goes on inside?. Deeper

A simple program

8 2 00

GOTO the address stored in register 2

PC = Reg[2]

Page 32: Computer Hardware What goes on inside?. Deeper

A simple program

3 0 07

Add location 7 to register 0

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

Page 33: Computer Hardware What goes on inside?. Deeper

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

Page 34: Computer Hardware What goes on inside?. Deeper

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

Page 35: Computer Hardware What goes on inside?. Deeper

Programs and Data

Program (instructions)

Data

What is the difference?

If the PC points to itthen it is an instruction

Page 36: Computer Hardware What goes on inside?. Deeper

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

Page 37: Computer Hardware What goes on inside?. Deeper

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