4 1 3 2 Instruction ALU Registers Memory Fetch and Decode - - PowerPoint PPT Presentation

4 1 3 2
SMART_READER_LITE
LIVE PREVIEW

4 1 3 2 Instruction ALU Registers Memory Fetch and Decode - - PowerPoint PPT Presentation

Processor: Data Path Components 4 1 3 2 Instruction ALU Registers Memory Fetch and Decode Building Blocks Processor datapath Microarchitecture Instruction Decoder Memory Arithmetic Logic Unit Adders Registers Multiplexers


slide-1
SLIDE 1

ALU

Processor: Data Path Components

Registers Memory

Instruction Fetch and Decode

1 3 2 4

slide-2
SLIDE 2

Building Blocks

Devices (transistors, etc.)

Digital Logic Microarchitecture

Gates Flip-Flops Latches Decoders Encoders Multiplexers Demultiplexers Arithmetic Logic Unit Registers Memory Processor datapath Adders Instruction Decoder

slide-3
SLIDE 3

Arithmetic Logic Unit (ALU)

Operand A Operand B Condition Codes

(sign, overflow, carry-out, zero)

Result Operation

Hardware unit for arithmetic and bitwise operations.

words

word

a few bits a few bits

1

ALU

slide-4
SLIDE 4

1-bit ALU for bitwise operations

Build an n-bit ALU from n 1-bit ALUs. Each bit i in the result is computed from the corresponding bit i in the two inputs.

MUX

A B

1

Operation Result Op A B Result 1 1 1 1 1 1 1 1 1 1 1 1

ex

slide-5
SLIDE 5

1-bit adder

A B Carry in Carry out Sum 1 1 1 1 1 1 1 1 1 1 1 1

+

A B Sum

Carry in Carry out

Build an n-bit adder from n 1-bit adders. Each bit i in the result is computed from the corresponding bit i in the two inputs and the carry out of bit i-1.

look inside during lab

ex

slide-6
SLIDE 6

n-bit ripple-carry adder

+

A0 B0 Sum0

Carry in

+

An-1 Bn-1 Sumn-1

Carry out

+

A1 B1 Sum1

+

A2 B2 Sum2

There are faster, more complicated ways too…

slide-7
SLIDE 7

1-bit ALU

a b

1 Operation Result 2

2

Carry in

+

Sum Carry out MUX

slide-8
SLIDE 8

n-bit ALU

with ripple carry

A0 B0

1

Result0

2

Carry in

+

Sum MUX

An-1 Bn-1

1

Resultn-1

2

+

Sum

Carry out

MUX

A1 B1

1

Result1

2

+

Sum MUX

Operation

… ....

2

slide-9
SLIDE 9

Adding subtraction

A B

1 Operation Result 2

2

Carry in

+

Sum Carry out

1

Invert B MUX

MUX Different than in SCO book.

slide-10
SLIDE 10

ALU Condition Codes (x86)

Extra ALU outputs describing properties of result. Zero Flag: 1 if result is 00...0 else 0 Sign Flag: sign bit of result Carry Flag: 1 if unsigned overflow else 0 carry-out bit of result Overflow Flag: 1 if signed overflow else 0

slide-11
SLIDE 11

Compute NAND, NOR, NOT A,

Set inputs as needed.

A B

1 Operation Result 2

2

Carry in

+

Sum Carry out

1

Invert B MUX

MUX

1

MUX

Invert A

ex

slide-12
SLIDE 12

Compute <, ==? Detect overflow?

Set inputs as needed, add minimal logic for overflow.

ex

A B

1 Operation Result 2

2

Carry in

+

Sum Carry out

1

Invert B MUX

MUX

1

MUX

Invert A

slide-13
SLIDE 13

n-bit ALU

1

Result0

2

+

MUX 1

Resultn-1

2

+

Carry out MUX 1

Result1

2

+

MUX

Operation

… ....

A1

1

B1

1

A0

1

B0

1

Negate B

An-1

1

Bn-1

1

....

Invert A

....

2

slide-14
SLIDE 14

Controlling the ALU

ALU control lines Function 0000 AND 0001 OR 0010 add 0110 subtract 1100 NOR Invert A Negate B Operation ID Operand A Operand B Result Control Lines Condition Codes

ALU