27
J. Michael Moore Computer Processing CSCE 110

J. Michael Moore Computer Processing CSCE 110. J. Michael Moore ProcessorInputOutput Memory Storage

  • View
    223

  • Download
    4

Embed Size (px)

Citation preview

J. Michael Moore

Computer Processing

CSCE 110

J. Michael Moore

ProcessorInput Output

Memory

Storage

J. Michael Moore

Processor

a.k.a. Central Processing Unit (CPU)

arithmetic/logic unit(ALU)

registers control unit

performs operations on data

(e.g. addition, multiplication)

special memory cellsthat hold data used by ALU

and are even faster than cache

•figures out what the ALU should

do next•transfers data

between main memory and registers

J. Michael Moore

Processing Bits

• Boolean Logic

• Applied to circuits

J. Michael Moore

Logical AND

Truth tableX Y X AND Y

False False False

False True False

True False False

True True True

Logic gate

Truth tableX Y X AND Y

0 0 0

0 1 0

1 0 0

1 1 1

J. Michael Moore

Logical AND: An Example

T T F F T F

AND F T F T T F

F T F F T F

J. Michael Moore

Logical OR Truth table

X Y X OR Y

False False False

False True True

True False True

True True True

Truth table

X Y X OR Y

0 0 0

0 1 1

1 0 1

1 1 1

Logic gate

J. Michael Moore

Logical OR: An Example

T T F F T F

OR F T F T T F

T T F T T F

J. Michael Moore

Logical NOT Truth table

X Not X

False True

True False

Logic gate

Truth table

X Not X

0 1

1 0

J. Michael Moore

Logical NOT: An Example

T T F F T F

NOT F F T T F T

J. Michael Moore

Logical NANDTruth table

X Y X AND Y X NAND Y

False False False True

False True False True

True False False True

True True True False

Logic gate

Truth table

X Y X AND Y X NAND Y

0 0 0 1

0 1 0 1

1 0 0 1

1 1 1 0

J. Michael Moore

Logical NAND: An Example

T T F F T F

AND F T F T T F

F T F F T F

NAND T F T T F T

J. Michael Moore

Logic gate

Logical NORTruth table

X Y X OR Y X NOR Y

False False False True

False True True False

True False True False

True True True False

Truth table

X Y X OR Y X NOR Y

0 0 0 1

0 1 1 0

1 0 1 0

1 1 1 0

J. Michael Moore

Logical NOR: An Example

T T F F T F

OR F T F T T F

T T F T T F

NOR F F T F F T

J. Michael Moore

Logical Exclusive OR (XOR) Truth table

X Y X XOR Y

False False False

False True True

True False True

True True False

Logic gate

Truth table

X Y X XOR Y

0 0 0

0 1 1

1 0 1

1 1 0

J. Michael Moore

Logical XOR: An Example

T T F F T F

XOR F T F T T F

T F F T F F

http://fac-staff.seattleu.edu/quinnm/web/education/JavaApplets/applets/BinaryLogicOperators.html

J. Michael Moore

Adder

• Half Adder

• Full Adder

• Ripple Carry Adder

J. Michael Moore

ProcessorInput Output

Memory

Storage

J. Michael Moore

• Ex: to add the number held in address 3 and the number held in address 6 and put the result in address 10, the control unit– copies data in main memory address 3 into register 1

LOAD 3, 1– copies data in main memory address 6 into register 4

LOAD 6, 4– tells ALU to add contents of registers 1 and 4 and put the result

in register 3ADD 1, 4, 3

– copies data in register 3 into main memory address 10STORE 3, 10

How a Program is Executed

J. Michael Moore

How a Program is Executed

• LOAD, ADD, and STORE are machine instructions– operation: what action to do (e.g. ADD)– operand: what is affected

(e.g. register 3)

• How does the control unit know which instruction is next?– The Program

J. Michael Moore

How a Program is Stored

• Program: list of machine instructions using some agreed upon coding conventions. For example:

first byte second byte

instruction

thirdoperand

secondoperand

firstoperand

operationcode

J. Michael Moore

How a Program is Stored

• Suppose the opcode for ADD is 0010• Then ADD 1, 4, 3 would be encoded as:

0 0 1 0 0 0 1 0 1 0 0 0 0 1 10

first byte second byte

instruction

thirdoperand

secondoperand

firstoperand

operationcode

• Program is stored the same way data is stored.

J. Michael Moore

How a Program is Executed

• The control unit has– instruction register: holds current instruction

to be executed– program counter: holds address of next

instruction in the program to be fetched from memory

J. Michael Moore

How a Program is Executed

• Program counter tells where the computer is in the program. Usually, the next instruction to execute is the next instruction in memory.

• Sometimes we want to jump to another instruction (e.g., an ‘if’ statement or ‘while’ loop). More instructions:– unconditional JUMP: always jump to the address

given– conditional JUMP: only jump if a certain condition is

true (e.g., some register equals 0 or two registers equal each other)

– Instruction to stop executing instructions: HALT

J. Michael Moore

Machine Cycle

• Fetch next instruction, as indicated by the program counter (PC), and increment the PC

• Decode the bit pattern in the instruction register (IR) - figure out which circuitry needs to be activated to perform the specified instruction

• Execute the specified instruction, by activating the ALU to do the right thing. If a JUMP, this may cause the PC to be altered

• Typical speeds: 10 to 100 million instructions per second (MIPS)

J. Michael Moore

ArchitectureCPU

Control Unit ALU

R4

R3

R2

R1

IR

PC

BUS

Memory

0 2 31 4

9998979695

...... ...

FirstInstruction

SecondInstruction

ThirdInstruction

Data

J. Michael Moore

PC:

IR:

R4:

R3:

R2:

R1:

Memory:...

12-13: LOAD 108, 3

14-15: LOAD 109, 4

16-17: ADD 3, 4, 1

18-19: STORE 1, 110

20-21: HALT ...

...

...

108:

109:

110:

Assembly Language Example

12

35

77

112

77

35

44

LOAD

14161820

LOAD ADD STORE HALT

112

22