1 an arithmetic logic unit computes arithmetic or logic function we designed a two function...

3
1 An arithmetic logic unit computes arithmetic or logic function We designed a two function arithmetic unit to perform ADD/SUB We can add two logical function to it, AND and OR A four function ALU will have two bits to specify function 00 (Add), 01 (Sub), 10 (AND), 11 (OR) Then the following set up will work A four function ALU Result ADD A B MUX Select 2 bits SUB A B AND A B OR A B 0 0 0 1 1

Upload: carmel-hill

Post on 13-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 An arithmetic logic unit computes arithmetic or logic function We designed a two function arithmetic unit to perform ADD/SUB We can add two logical function

1

• An arithmetic logic unit computes arithmetic or logic function• We designed a two function arithmetic unit to perform ADD/SUB• We can add two logical function to it, AND and OR• A four function ALU will have two bits to specify function

– 00 (Add), 01 (Sub), 10 (AND), 11 (OR)• Then the following set up will work

A four function ALU

Result

ADDAB

MUX

Select 2 bits

SUBAB

ANDAB

ORAB

00

01

10

11

Page 2: 1 An arithmetic logic unit computes arithmetic or logic function We designed a two function arithmetic unit to perform ADD/SUB We can add two logical function

2

• The previous design is not very efficient as it uses an adder and subtract circuit

• We can design an add/subtract unit as discussed earlier• Then we can design a logical unit (AND and OR) separately• Then select appropriate output as result• What are the control signals, Add/Sub, Select0, and Select1?

An alternate design of four function ALU

MUXResult

ADD/SUBAB

MUX

Select1

ANDAB

ORAB

0

10

1

Select0

Add/sub

Page 3: 1 An arithmetic logic unit computes arithmetic or logic function We designed a two function arithmetic unit to perform ADD/SUB We can add two logical function

3

• In micro-controllers, ALU units have many function• 16 arithmetic, 16 logic functions are common• A 5 bit code decides what function is required• This is part of an operation code in an instruction• Selection of operands is also specified as part of instruction• In actual instruction execution, operands A and B are first

selected from different registers • Then different functions are computed• Finally, a result based on operation code is selected• This sequence is repeated for every instruction

Operation codes