+ All Categories
Home > Documents > M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline...

M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline...

Date post: 07-Mar-2018
Category:
Upload: vomien
View: 219 times
Download: 1 times
Share this document with a friend
67
M3 – ALU Design
Transcript
Page 1: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

M3 – ALU Design

Page 2: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Module Outline

● Integer Arithmetic– Adder, Subtractor, Multiplier, Divider

● Arithmetic and Logical Unit Design– ALU Design in SystemC

Page 3: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Arithmetic Logic Unit

● Arithmetic operations● Logic operations● Comparison (Equal)

+ - * /==!=

& | ^

Arithmetic and Logic Unit

Control Signal

A

BOutput

Page 4: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU

● Start with the simplest operations.

Page 5: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU

● Start with the simplest operations.– AND, OR

– Control signal

Page 6: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU

● Start with the simplest operations.– AND, OR

– Control signal

● Incrementally add functionality and control

Page 7: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU

● Start with the simplest operations.– AND, OR

– Control signal

● Incrementally add functionality and control● Start with a 1-bit ALU

Page 8: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU

● Start with the simplest operations.– AND, OR

– Control signal

● Incrementally add functionality and control● Start with a 1-bit ALU● Modify design for a n-bit ALU

Page 9: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Basic ALU Design

AND, OR

Page 10: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Basic ALU Design

Include a Full AdderInclude a Full Adder

Page 11: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Basic ALU Design

ADDER, AND, OR

Page 12: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Basic ALU Design

ADDER, AND, ORSubtraction?Subtraction?

Page 13: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Adder/Subtractor

+

0

S=a+b

Cout

a

b

Page 14: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Adder/Subtractor

+ -

0 1

S=a+b

Cout C

out

a

b

a

bS=a-b

Page 15: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Adder/Subtractor

+ -

0 1

S=a+b

Cout C

out

a

b

a

bS=a-b

-b = b + 1-b = b + 1

Page 16: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU DesignA±B, AND, ORA±B, AND, OR

A–B: Binvert = 1; CarryIn = 1.A+B: Binvert = 0; CarryIn = 0.

A–B: Binvert = 1; CarryIn = 1.A+B: Binvert = 0; CarryIn = 0.

Page 17: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU DesignA±B, AND, ORA±B, AND, OR

NAND, NOR?NAND, NOR?A–B: Binvert = 1; CarryIn = 1.A+B: Binvert = 0; CarryIn = 0.

A–B: Binvert = 1; CarryIn = 1.A+B: Binvert = 0; CarryIn = 0.

Page 18: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

NAND, NOR, NOT

A NAND B = (A AND B)

= A OR B

A NAND B = (A AND B)

= A OR BA NOR B = (A OR B)

= A AND B

A NOR B = (A OR B)

= A AND B

Page 19: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

a NAND b: Ainvert=1;Binvert=1;Op=1a NAND b: Ainvert=1;Binvert=1;Op=1

Page 20: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

A±B, AND, OR, NOR, NAND

Page 21: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

SLT?SLT?

Page 22: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Set Less Than

● Set a status bit if (a < b)● If (a<b); (a-b) is -ve● Calculate (a-b). Observe sign bit of the result

Page 23: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

slt(a,b): Binvert=1; CarryIn=1; Operation=3;

Page 24: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

A±B, AND, OR, NOR, NAND, SLT

Page 25: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

Overflow?Overflow?A±B, AND, OR, NOR, NAND, SLT

Page 26: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

A±B, AND, OR, NOR, NAND,SLT, Overflow detection

Page 27: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Design

1-bit ALU

Ainvert

Binvert

CarryIn

Operation

a

b

Sum

Set

Overflow

CarryOut

Less

Page 28: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

32-bit ALU

Zero detection?Zero detection?

Page 29: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

32-bitALU

Page 30: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU

Page 31: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND

OR

ADD

SUB

NAND

NOR

SLT

Page 32: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND 0 0 0 00

OR

ADD

SUB

NAND

NOR

SLT

Page 33: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND 0 0 0 00

OR 0 0 0 01

ADD

SUB

NAND

NOR

SLT

Page 34: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND 0 0 0 00

OR 0 0 0 01

ADD 0 0 0 10

SUB 0 1 1 10

NAND

NOR

SLT

Page 35: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND 0 0 0 00

OR 0 0 0 01

ADD 0 0 0 10

SUB 0 1 1 10

NAND 1 1 0 01

NOR 1 1 0 00

SLT

Page 36: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND 0 0 0 00

OR 0 0 0 01

ADD 0 0 0 10

SUB 0 1 1 10

NAND 1 1 0 01

NOR 1 1 0 00

SLT 0 1 1 11

Page 37: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Ainvert Binvert CarryIn Operation

AND 0 0 0 00

OR 0 0 0 01

ADD 0 0 0 10

SUB 0 1 1 10

NAND 1 1 0 01

NOR 1 1 0 00

SLT 0 1 1 11

Ignore the effect of CarryIn during NAND and NOR execution. Binvert == CarryIn.

Page 38: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

ABOp

AND 0000

OR 0001

ADD 0010

SUB 0110

NAND 1101

NOR 1100

SLT 0111

Page 39: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control

+ - * /==!=

& | ^

Arithmetic and Logic Unit

Control Signal

A

BOutput

ALUCONTROL

ALUCONTROL

Instruction

Page 40: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

AND

Page 41: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Instructions using the ALU

● Arithmetic and Logic Instructions– R-type and I-type

● Memory transfer instructions– Effective address calculation

– I-type

● Branch instructions (BEQ)– For Zero detection

– I-type

Page 42: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

ABOp

AND 0000

OR 0001

ADD 0010

SUB 0110

NAND 1101

NOR 1100

SLT 0111

Which control signals forLW, SW, BEQ?

Which control signals forLW, SW, BEQ?

Page 43: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU – Control Signals

Input to ALU CU Output Control SignalsABOp

AND 0000

OR 0001

ADD, LW, SW 0010

SUB, BEQ 0110

NAND 1101

NOR 1100

SLT 0111

Page 44: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

0x00221824

ALU !ALU !

Page 45: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

ALU !ALU !

6 bits 5 bits 5 bits 5 bits 6 bits5 bits

op rs rt rd shamt funct

OP rd, rs, rt

Page 46: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

ALU !ALU !

6 bits 5 bits 5 bits 5 bits 6 bits5 bits

0x0

AND R3,R1,R2

1 2 3 0 0x26

Page 47: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND (R-type)

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

0x26

ALU !ALU !

Page 48: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW

SW

BEQ

ALU instruction

ALU Immediate

Page 49: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW

SW

BEQ

ALU instruction

ALU Immediate

Main Control UnitIdentifies the instruction

Main Control UnitIdentifies the instruction Inputs to the ALU CUInputs to the ALU CU Output of ALU CUOutput of ALU CU

Page 50: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW add I-type Invalid 0010

SW

BEQ

ALU instruction

ALU Immediate

Main Control UnitIdentifies the instruction

Main Control UnitIdentifies the instruction Inputs to the ALU CUInputs to the ALU CU Output of ALU CUOutput of ALU CU

Page 51: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW add I-type Invalid 0010

SW add I-type Invalid 0010

BEQ

ALU instruction

ALU Immediate

Main Control UnitIdentifies the instruction

Main Control UnitIdentifies the instruction Inputs to the ALU CUInputs to the ALU CU Output of ALU CUOutput of ALU CU

Page 52: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW add I-type Invalid 0010

SW add I-type Invalid 0010

BEQ sub I-type Invalid 0110

ALU instruction

ALU Immediate

Main Control UnitIdentifies the instruction

Main Control UnitIdentifies the instruction Inputs to the ALU CUInputs to the ALU CU Output of ALU CUOutput of ALU CU

Page 53: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW add I-type Invalid 0010

SW add I-type Invalid 0010

BEQ sub I-type Invalid 0110

ALU instruction As in instruction R-type Unique per instruction

As per instruction

ALU Immediate

Main Control UnitIdentifies the instruction

Main Control UnitIdentifies the instruction Inputs to the ALU CUInputs to the ALU CU Output of ALU CUOutput of ALU CU

Page 54: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Instruction ALU action Type Funct field Control Signal

LW add I-type Invalid 0010

SW add I-type Invalid 0010

BEQ sub I-type Invalid 0110

ALU instruction As in instruction R-type Unique per instruction

As per instruction

ALU Immediate As in instruction I-type Invalid As in instruction

Main Control UnitIdentifies the instruction

Main Control UnitIdentifies the instruction Inputs to the ALU CUInputs to the ALU CU Output of ALU CUOutput of ALU CU

Page 55: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Page 56: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Truth Table of the ALU CU

Page 57: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control Unit

Page 58: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Module Outline

● Integer Arithmetic– Adder, Subtractor, Multiplier, Divider

● Arithmetic and Logical Unit Design– ALU Design in SystemC

Page 59: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

Backup

Page 60: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

ALU !ALU !

6 bits 5 bits 5 bits 5 bits 6 bits5 bits

op rs rt rd shamt funct

OP rd, rs, rt

Page 61: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

ALU !ALU !

6 bits 5 bits 5 bits 5 bits 6 bits5 bits

0x0

AND R3,R1,R2

1 2 3 0 0x26

Page 62: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – AND Instruction

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x00221824

0x0/0x26

ALU !ALU !

Page 63: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control

+ - * /==!=

& | ^

0000

A

B

Output

ALUCONTROL

ALUCONTROL

Op/Funct

Page 64: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Instructions

● ALU instructions (R type), Memory Transfer (effective address calculation), Branches (BEQ)

● R-type

● I-type

6 bits 5 bits 5 bits 5 bits 6 bits5 bits

op rs rt rd shamt funct

6 bits 5 bits 5 bits 16 bits

op rs rt immediate

op: Opcode (class of instruction). Eg. ALUfunct: Which subunit of the ALU to activate?

OP rt, rs, IMM

OP rd, rs, rt

Page 65: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Instructions

● ALU instructions (R type), Memory Transfer (effective address calculation), Branches (BEQ)

● Identified by Opcode fields and Funct fields

Page 66: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Instructions

● ALU instructions (R type), Memory Transfer (effective address calculation), Branches (BEQ)

● R-type

● I-type

6 bits 5 bits 5 bits 5 bits 6 bits5 bits

op rs rt rd shamt funct

6 bits 5 bits 5 bits 16 bits

op rs rt immediate

op: Opcode (class of instruction). Eg. ALUfunct: Which subunit of the ALU to activate?

OP rt, rs, IMM

OP rd, rs, rt

Page 67: M3 – ALU Design - bt.nitk.ac.inbt.nitk.ac.in/c/17b/co200/notes/M3-2.ALU-Design.pdfModule Outline Integer Arithmetic – Adder, Subtractor, Multiplier, Divider Arithmetic and Logical

ALU Control – LW (I-type)

+ - * /==!=

& | ^

0000

A

B

A & B

ALUCONTROL

ALUCONTROL

MAINCONTROL UNIT

MAINCONTROL UNIT

0x8C220404

LW

ALU !ALU !


Recommended