Design a 4-bit ALU that implements the following set of complement...

Post on 28-Mar-2020

9 views 0 download

Transcript of Design a 4-bit ALU that implements the following set of complement...

• Design a 4-bit ALU that implements the following set of operations with only the following components (assume 2’s complement number representation, no need to implement overflow circuit)

– 1-bit Full-Adders (FA)

– 2-input AND/OR/XOR gates

– Inverters

– 2:1 MUX

0

0

0

0

1

1

1

1

1

1

1

1

0

0

0

0

1

0

1

0

1

0

1

0

Add

Subtract

Increment

Decrement

Multiply by 2

Divide by 2

Function Name

Bitwise-AND

Bitwise-OR

A + B

A – B

A + 1

A – 1

A * 2

A / 2

F =

A AND B

A OR B

M2 M1 M0

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

A * 2 = left-shift

e.g. 3 * 2 = “011” * 2 = “110” = 6

A / 2 = right-shift

e.g. 3 / 2 = “011” / 2 = “001” = 1

0 1

MUX

Fi

M2

0 1

MUX M1

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

A * 2 = left-shift

e.g. 3 * 2 = “011” * 2 = “110” = 6

A / 2 = right-shift

e.g. 3 / 2 = “011” / 2 = “001” = 1

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

Bi

NOT(Bi)

“0”

“1”

C0

0

1

1

0

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

Bi

NOT(Bi)

“0”

“1”

C0

0

1

1

0

0 1

MUX M1

Bi M0

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

Bi

NOT(Bi)

“0”

“1”

C0

0

1

1

0

0 1

MUX M1

Bi M0

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

Bi

NOT(Bi)

“0”

“1”

C0

0

1

1

0

0 1

MUX M1

Bi M0

M0

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

Bi

NOT(Bi)

“0”

“1”

C0

0

1

1

0

0 1

MUX M1

Bi M0

M0

M2

0

0

0

0

1

1

0

0

M1 M0

1

0

1

0

Add

Subtract

Increment

Decrement

Function Name

A + B

A – B

A + 1

A – 1

F =

1

1

1

1

1

1

0

0 1

0

1

0

Multiply by 2

Divide by 2

Bitwise-AND

Bitwise-OR

A * 2

A / 2

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

Bi

NOT(Bi)

“0”

“1”

C0

0

1

1

0

0 1

MUX M1

Bi M0

M0

M1 M0

C0

M2

0

0

0

0

M1 M0 Function Name F =

1

1

1

1

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

0 1

MUX M1

Bi M0

M0

M1 M0

C0

M2

0

0

0

0

M1 M0 Function Name F =

1

1

1

1

1

1 1

0 Bitwise-AND

Bitwise-OR

A AND B

A OR B

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

0 1

MUX M1

Bi M0

M0

M1 M0

C0

M2

0

0

0

0

M1 M0 Function Name F =

1

1

1

1

0 1 Divide by 2 A / 2

0 1

MUX

Fi

M2

0 1

MUX M1

0 1

MUX M0

Ai-1 Ai+1

0 1

MUX

Ai Bi

M0

Ai Bi

FA Ci Ci+1

Ai

0 1

MUX M1

Bi M0

M0

M1 M0

C0

1 0 0 Multiply by 2 A * 2