Tutorial: Wednesday Week 3

1 / 19

# Tutorial: Wednesday Week 3 - PowerPoint PPT Presentation

Tutorial: Wednesday Week 3. Hand in on Monday, Do the questions for tutorials 1 &amp; 2 at the back of the course notes (answers to tutorial 3 will be published on-line). Addition &amp; Subtraction. Addition. B. A. B. A. B. A. 2. 2. 1. 1. 0. 0. C. = 1. IN. B. A. C. B. A. C. B.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Tutorial: Wednesday Week 3' - MikeCarlo

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Tutorial: Wednesday Week 3
• Hand in on Monday,
• Do the questions for tutorials 1 & 2 at the back of the course notes
• (answers to tutorial 3 will be published on-line)

B

A

B

A

B

A

2

2

1

1

0

0

C

= 1

IN

B

A

C

B

A

C

B

A

C

IN

IN

IN

Subtraction

C

C

C

SUM

SUM

SUM

OUT

OUT

OUT

Q

Q

Q

2

1

0

• Both the addition and subtraction circuits are based around the parallel adder (using either ripple carry or carry-look-ahead).
• A and B are inputted directly to the adder
• CIN = 0
• For subtraction:
• A is inputted directly
• All the bits of B are complemented
• CIN = 1

ACTION

When this signal is high, do action.

ACTION

When this signal is low, do action.

When this signal is high, do action 1; when it’s low, do action 2.

ACTION1 / ACTION2

When this signal is high, subtract; when it’s low, add.

Notation
• To clarify a notational issue regarding the labelling of digital signals.
Arithmetic Logic Units
• An Arithmetic Logic Unit (ALU) is a general purpose device capable of various arithmetic and logical operations.
• The adder/subtractor circuit is an example of a simple ALU.
• It is capable of two operations, decided by a single control input.
• More elaborate ALUs are capable of numerous different operations, depending on the state of a control input word.
Logical Operations
• As the name suggests, ALUs perform both arithmetic and logical operations.
• AND, OR, XOR etc.
• These operations are performed in a ‘bit-wise’ fashion.
• I.e. Output bit Qn depends only on the input bits An and Bn.
Bitwise Logic Examples

If A = 1010 and B = 1001:

A AND B = 1000

A OR B = 1011

A XOR B = 0011

A NAND B = 0111

A NOR B = 0100

S

A

B

X

0

0

0

0

0

0

1

0

0

1

0

0

0

1

1

1

1

0

0

0

1

0

1

1

1

1

0

1

1

1

1

1

Logical Operations
• For a single bit, imagine a logic gate that can be programmed to act either as an AND or an OR gate…

X

A

B

AND/OR Select (S)

2-Bit Simple ALU

AND/OR

A0

B0

X0

A1

B1

X1

Practical ALUs
• A practical ALU can perform several different operations on two multiple bit input words, A and B.
• The operation is selected by a control input word, S.
• Like the ADD/SUB and AND/OR circuits, the contents of all ALUs are just a big block of combinational logic.
• Take, for example, the 74F382 ALU integrated circuit…
74F382
• Two 4-bit input words, A and B, plus carry-in.
• One 4-bit output, F, plus carry-out.
• 3-bit control input word, S, eight possible permutations.

S2

S1

S0

Operation

0

0

0

Clear

0

0

1

B minus A

0

1

0

A minus B

0

1

1

A plus B

1

0

0

A XOR B

1

0

1

A AND B

1

1

0

A OR B

1

1

1

Set

74F382 Operations

(All output bits set to zero)

(bit-wise logical operations)

(All output bits set to one)

Example Operations
• (5)10 - (3)10 or (0101)2 - (0011)2
• (0101)2 XOR (0011)2
ALU limitations
• Being just logic, ALUs require all the inputs to be present at once.
• They have no memory. We’ll look at adding some next time.

A

B

S

F

ALU

• Neither people or computers like having to press lots of buttons at once.
• We’d both prefer a system that could remember inputs…

Memory

Memory

A

B

S

F

ALU

Summary
• It is reasonably straightforward to modify the adder circuit to perform either addition or subtraction (depending on a control input).
• This forms a simple ALU.
• Practical ALUs are capable of a wide variety of arithmetic and logical operations.
• The operation is selected by a control input selection word, S.
• Despite their complexity, they are only logic.