Top Banner
Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic
39

Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Dec 17, 2015

Download

Documents

Clinton Henry
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Cosc 2150:Computer Organization

Chapter 3:Boolean Algebra and Digital Logic

Page 2: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Objectives

• Understand the relationship between Boolean logic and digital computer circuits.

• Learn how to design simple logic circuits.• Understand how digital circuits work

together to form complex computer systems.

Page 3: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Introduction

• In the latter part of the nineteenth century, George Boole incensed philosophers and mathematicians alike when he suggested that logical thought could be represented through mathematical equations.—How dare anyone suggest that human thought

could be encapsulated and manipulated like an algebraic formula?

• Computers, as we know them today, are implementations of Boole’s Laws of Thought.—John Atanasoff and Claude Shannon were

among the first to see this connection.

Page 4: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Introduction

• In the middle of the twentieth century, computers were commonly known as “thinking machines” and “electronic brains.”—Many people were fearful of them.

• Nowadays, we rarely ponder the relationship between electronic digital computers and human logic. Computers are accepted as part of our lives.—Many people, however, are still fearful of them.

• In this chapter, you will learn the simplicity that constitutes the essence of the machine.

Page 5: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Boolean Algebra

• Boolean algebra is a mathematical system for the manipulation of variables that can have one of two values.—In formal logic, these values are “true” and

“false.”—In digital systems, these values are “on” and

“off,” 1 and 0, or “high” and “low.”

• Boolean expressions are created by performing operations on Boolean variables.—Common Boolean operators include AND, OR,

and NOT.

Page 6: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• A Boolean operator can be completely described using a truth table.

• The truth table for the Boolean operators AND and OR are shown at the right.

• The AND operator is also known as a Boolean product. The OR operator is the Boolean sum.

Boolean Algebra

Page 7: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• The truth table for the Boolean NOT operator is shown at the right.

• The NOT operation is most often designated by an overbar. It is sometimes indicated by a prime mark ( ‘ ) or an “elbow” ().

Boolean Algebra

Page 8: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Boolean Algebra

• A Boolean function has:—At least one Boolean variable, —At least one Boolean operator, and —At least one input from the set {0,1}.

• It produces an output that is also a member of the set {0,1}.

Now you know why the binary numbering system is so handy in digital systems.

Page 9: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• The truth table for the Boolean function:

is shown at the right.

• To make evaluation of the Boolean function easier, the truth table contains extra (shaded) columns to hold evaluations of subparts of the function.

Boolean Algebra

Page 10: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• As with common arithmetic, Boolean operations have rules of precedence.

• The NOT operator has highest priority, followed by AND and then OR.

• This is how we chose the (shaded) function subparts in our table.

Boolean Algebra

Page 11: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Boolean Algebra

• Digital computers contain circuits that implement Boolean functions.

• The simpler that we can make a Boolean function, the smaller the circuit that will result.—Simpler circuits are cheaper to build, consume

less power, and run faster than complex circuits.

• For the purposes of this course, we will deal only with And, Or, and Not gates—While there are more interesting gates, such as

XOR, NOR, and NAND gates.

Page 12: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• The three simplest gates are the AND, OR, and NOT gates.

• They correspond directly to their respective Boolean operations, as you can see by their truth tables.

Logic Gates

Page 13: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Logic Gates

• There is one other graphical convention

• The NOT gate is sometimes reduced to a small circle attached to some other gate, so

Page 14: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Combinational Circuit

• A Combinational Circuit has no memory.

• Its outputs depend only on its inputs—not on a value stored inside the circuit—Each input (and each output) is either 1 or 0.

• To specify its behavior, we use a  truth table

• Example—Imagine a circuit with 3 inputs and 2 outputs.  —The outputs form a binary number  =  number

of incoming 1's

Page 15: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Combinational Circuit Example

Page 16: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• Combinational logic circuits give us many useful devices.

• One of the simplest is the half adder, which finds the sum of two bits.

• We can gain some insight as to the construction of a half adder by looking at its truth table, shown at the right.

Half Adder

Page 17: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• We can change our half adder into to a full adder by including gates for processing the carry bit.

• The truth table for a full adder is shown at the right.

Full Adder

Page 18: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Multiplexor

• A Multiplexor that allows us to choose one of two incoming bits.—S selects either A or B and sends its value on

to C.

—Left: A two input multiplexor—Right: implementation with gates

Page 19: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Multiplexor Exercise

• If A,B,S are 0,1,0,   —what are the AND gate outputs?  —the OR gate output?

                      

• Now change S to 1 and update the outputs accordingly.

Page 20: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

• This is what a 4-to-1 multiplexer looks like on the inside.

4-to-1 multiplexer

Page 21: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table

• Example:• A circuit with 3 inputs (A,B,C) and 3

outputs (D,E,F).• Output D is turned on

—when at least one input is on.

• Output E is turned on—when exactly two inputs are on.

• Output F is turned on—when all three inputs are on.

Page 22: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table (2)

• Truth Table

—D=1, when one input is on—E=1, when only two inputs are on—F=1, when all three inputs are on

Page 23: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table (3)

• To make a circuit that will compute these 3 outputs correctly, we start by creating an AND for each line of the truth table:

• This AND gate is turned on only when A is 0 (note the inverter), b is 1 and c is 1—Which corresponds to line 4 of the truth table

Page 24: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table (4)

• Now we need an OR gate for each output

• Now we connect some of the input AND's to some of the output OR's.

Page 25: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table (5)

 Before continuing, let finish the diagram for   Outputs D  (at least one input set to 1) and F (all 3 set to 1).

Page 26: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table (6)

• Notice that one of the AND gates (line one of the truth table) never got used.• Also F's OR has only one input.  

• We can eliminate these two gates to give

Page 27: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Building a circuit from a truth table (7)

The final circuit:

Page 28: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

An Adder for 2 bits

• A single column could be done by a circuit like this

Page 29: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

An Adder for 2 bits (2)

• Here is its truth table  

• EXERCISE:   fill in the missing data in the table below

Page 30: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

An Adder for 2 bits (3)

Now

Let’s com

plete the circuit

Page 31: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Wiring up a 4-bit Adder

Page 32: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Creating a simple ALU

• We start with a circuit that's similar to our adder.—3 data inputs

(a,b,CarryIn)—2 data outputs (Results,

CarryOut)—The box labeled + is

the full adder we did above.

• We also have 3 Control Signals: Ainvert, Binvert, Operation —We ignoring the less

Page 33: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Creating a simple ALU (2)

• Operation is a MUX—Allowing us to choose one of four inputs

• Exercise:—Ainvert and Binvert are 0, What happens—If Operation is 0?

—If operation is 1?

—If operation is 2?

Page 34: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Simple 32 bit ALU

Page 35: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Addition (unsigned)

Page 36: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Bitwise AND

Note, carryIn and carry out don’t contribute anything

Page 37: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Bitwise OR

We can also use Bitwise OR

Note: carryIn and carry out don’t contribute anything

Page 38: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

Lastly

• It can also do subtraction  —a31a30...a0 -

b31b30....b0—EXERCISE:  How?

—Recall subtraction is done with 2's complement

– 2's complement, flip all the bits and add 1

• So that's an ALU that can do Add, Subtract, AND, OR

Page 39: Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.

QA&