n301 designing circuits

29
CSCI N301: CSCI N301: Fundamental Computer Fundamental Computer Science Concepts Science Concepts Copyright Copyright ©2004 ©2004 Department of Computer & Information Science Department of Computer & Information Science Designing Circuits Designing Circuits

Upload: gavhays

Post on 24-Jun-2015

1.396 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: N301 Designing Circuits

CSCI N301:CSCI N301: Fundamental Computer Fundamental Computer Science ConceptsScience Concepts

Copyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Designing CircuitsDesigning Circuits

Page 2: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

GoalsGoals

By the end of this lecture, you should By the end of this lecture, you should understand …understand …

• How to use the Sum-Of-Products to How to use the Sum-Of-Products to construct circuits. construct circuits.

• How to construct a basic, binary input How to construct a basic, binary input circuit.circuit.

• How to construct more complex circuits, How to construct more complex circuits, using three or more inputs.using three or more inputs.

Page 3: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Where We’ve BeenWhere We’ve Been

• We are developing an increasingly We are developing an increasingly complex model of computer operation.complex model of computer operation.

• We began with the switch and saw how We began with the switch and saw how we can use it encode information in we can use it encode information in digitized form.digitized form.

• We combined switches into gates and saw We combined switches into gates and saw how we can use Boolean logic process how we can use Boolean logic process binary information.binary information.

Page 4: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Where We’re GoingWhere We’re Going

• We will learn how to combine gates to We will learn how to combine gates to form circuits.form circuits.

• We are looking at a special kind of circuit – We are looking at a special kind of circuit – a a combinational circuitcombinational circuit – although from – although from here on out we simply refer to circuit.here on out we simply refer to circuit.

Page 5: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

What is a Circuit?What is a Circuit?

• A circuit is a combination of logic gates that A circuit is a combination of logic gates that changes a set of binary inputs into a set of changes a set of binary inputs into a set of binary outputs in which the values of the outputs binary outputs in which the values of the outputs depend only on the electrical current (high/low depend only on the electrical current (high/low voltage) values of the inputs.voltage) values of the inputs.

• By the way, there are also circuits that depend By the way, there are also circuits that depend also on the previous values of the inputs, but we also on the previous values of the inputs, but we won’t consider them in this class.won’t consider them in this class.

Page 6: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Circuit AnalysisCircuit Analysis

• Circuits depend on Boolean logic, which we introduced Circuits depend on Boolean logic, which we introduced last lecture.last lecture.

• Boolean notation allows us to create logical expressions Boolean notation allows us to create logical expressions using Boolean operators.using Boolean operators.

• For example:For example:

Examples of Boolean ExpressionsExamples of Boolean Expressions

Using Operator NamesUsing Operator Names Using SymbolsUsing Symbols

Q = (A OR B)Q = (A OR B) Q = (A + B)Q = (A + B)

Q = NOT ((A OR B) AND (NOT B))Q = NOT ((A OR B) AND (NOT B)) Q = ~ ((A + B) Q = ~ ((A + B) • (~B))• (~B))

Page 7: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Circuits & Boolean ExpressionsCircuits & Boolean Expressions

• You can express every Boolean expression You can express every Boolean expression using a circuit diagram.using a circuit diagram.

• Conversely, you can represent every circuit Conversely, you can represent every circuit diagram as a Boolean expression.diagram as a Boolean expression.

• Of course, we aren’t going after just any circuits Of course, we aren’t going after just any circuits here…. we want to develop the skills to here…. we want to develop the skills to construct and analyze circuits that can perform construct and analyze circuits that can perform the logic and arithmetic calculations that a the logic and arithmetic calculations that a computer requires to operate.computer requires to operate.

Page 8: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Constructing CircuitsConstructing Circuits

• We can use any one of several algorithms for We can use any one of several algorithms for constructing circuits, just like there were several constructing circuits, just like there were several different algorithms for modeling gates. different algorithms for modeling gates.

• We will use an algorithm called the We will use an algorithm called the sum-of-sum-of-products algorithmproducts algorithm to design our circuits. When to design our circuits. When using the sum-of-products algorithm, we move in using the sum-of-products algorithm, we move in a step-by-step process to build a circuit.a step-by-step process to build a circuit.

Page 9: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

The Four Steps for the The Four Steps for the Sum-Of-Products AlgorithmSum-Of-Products Algorithm

1.1. From a problem statement, construct a truth table that From a problem statement, construct a truth table that describes what the voltage output should be under describes what the voltage output should be under each possible combination of voltage inputs.each possible combination of voltage inputs.

2.2. From the truth table, identify those gate combinations From the truth table, identify those gate combinations that produce positive voltage output, and write sub that produce positive voltage output, and write sub expressions for those conditions.expressions for those conditions.

3.3. Combine the sub expressions (a.k.a. “Boolean terms”) Combine the sub expressions (a.k.a. “Boolean terms”) into a single Boolean expression.into a single Boolean expression.

4.4. Draw a circuit diagram that corresponds to the Boolean Draw a circuit diagram that corresponds to the Boolean expression.expression.

Page 10: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sub-of-Products ExampleSub-of-Products Example

• Problem Statement:Problem Statement:“Design a circuit that has two inputs (A, B) “Design a circuit that has two inputs (A, B) and one output, Q. Q = 1 iffand one output, Q. Q = 1 iff** both a and b both a and b are the same voltage.”are the same voltage.”

* - iff = “If and only if”* - iff = “If and only if”

Page 11: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sub-of-Products ExampleSub-of-Products Example

• How to read the problem:How to read the problem:– We two input lines coming into a circuit. One input line We two input lines coming into a circuit. One input line

is labeled A and the other input line is labeled B.is labeled A and the other input line is labeled B.– There is one output line, labeled Q.There is one output line, labeled Q.– The output voltage on Q is high if and only if both B The output voltage on Q is high if and only if both B

and B have high voltage, or both A and B have low and B have high voltage, or both A and B have low voltage (A and B have the same voltage).voltage (A and B have the same voltage).

– By inference, when A is high and B is low, or when A By inference, when A is high and B is low, or when A is low and B is high, the output line Q is low.is low and B is high, the output line Q is low.

Page 12: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sub-of-Products Example: Step 1Sub-of-Products Example: Step 1

• STEP 1: Construct a truth table to illustrate the STEP 1: Construct a truth table to illustrate the problem statement:problem statement:

INPUTSINPUTS OUTPUTOUTPUT

AA BB QQ

00 00

00 11

11 00

11 11

Page 13: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sub-of-Products Example: Step 2aSub-of-Products Example: Step 2a

• STEP 2a: Scan the table to determine when the Output STEP 2a: Scan the table to determine when the Output column is TRUE. Identify those instances:column is TRUE. Identify those instances:

INPUTSINPUTS OUTPUTOUTPUT

AA BB QQ

00 00 11

00 11 00

11 00 00

11 11 11

Page 14: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sum-of-Products Example: Step 2bSum-of-Products Example: Step 2b

• From the table we can identify 2 instances of From the table we can identify 2 instances of high output:high output:– Where both A and B were 0Where both A and B were 0– Where both A and B were 1Where both A and B were 1

• Now let’s create Boolean sub expressions for Now let’s create Boolean sub expressions for each instance (STEP 2b):each instance (STEP 2b):– ~A ~A •• ~B (NOT A AND NOT B) ~B (NOT A AND NOT B)– A A •• B (A AND B) B (A AND B)

Page 15: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sum-of-Products Example: Step 3Sum-of-Products Example: Step 3

• STEP THREE: Combine the Boolean sub-expressions STEP THREE: Combine the Boolean sub-expressions (or terms) into an overall expression.(or terms) into an overall expression.

• In our example, we are building an OR statement. We In our example, we are building an OR statement. We are saying Q can be high with one set of input conditions are saying Q can be high with one set of input conditions (~A (~A • ~B)• ~B), or using a second set of input conditions , or using a second set of input conditions (A (A • B).• B).

• Therefore, our expression will be connected with the OR Therefore, our expression will be connected with the OR operator. There are two terms – one for each high operator. There are two terms – one for each high voltage output.voltage output.

• Our single Boolean Expression is:Our single Boolean Expression is:Q = (~A Q = (~A • ~B)• ~B) + (A + (A • B)• B)

Page 16: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Sum-of-Products Example: Step 4Sum-of-Products Example: Step 4

• STEP FOUR: Build the circuit to represent our STEP FOUR: Build the circuit to represent our Boolean Expression.Boolean Expression.

QQ

AAAA

BBBB

Page 17: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Where We Were LimitedWhere We Were Limited

• The example we looked at took 2 inputs. The example we looked at took 2 inputs. But, of course, circuits are not limited to But, of course, circuits are not limited to just two inputs.just two inputs.

• We can extend our process to include We can extend our process to include nn inputs.inputs.

• Consider the following overall remarks Consider the following overall remarks regarding how we extend our model to regarding how we extend our model to build more complex circuits …build more complex circuits …

Page 18: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

General Rules/GuidelinesGeneral Rules/Guidelines

• When you add additional input lines, it becomes possible to see When you add additional input lines, it becomes possible to see some general patterns…some general patterns…

• In the step from problem statement to truth table, remember this:In the step from problem statement to truth table, remember this:– A problem with A problem with nn input lines will produce a truth table with input lines will produce a truth table with 22nn

elements (or rows)… for example, elements (or rows)… for example, 2 inputs lines2 inputs lines result in result in 4 4 possible voltage combinationspossible voltage combinations, while , while 3 input lines3 input lines result in result in 8 8 possible combinationspossible combinations..

• In the step from truth table to circuit drawing, remember this:In the step from truth table to circuit drawing, remember this:– We can combine various high sub-conditions joined by an OR We can combine various high sub-conditions joined by an OR

using an AND gate. To better manage the spacing required to using an AND gate. To better manage the spacing required to include the or gates and input lines, experienced students include the or gates and input lines, experienced students sometimes draw their circuits from right to left.sometimes draw their circuits from right to left.

Page 19: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Let’s Do One!Let’s Do One!

• Consider the following problem statement. Consider the following problem statement. Analyze it using the 4 step, Sum of Analyze it using the 4 step, Sum of Products Algorithm to produce a circuit.Products Algorithm to produce a circuit.

• Problem Statement: Problem Statement: “Design a circuit that “Design a circuit that takes 3 inputs, and outputs a high value takes 3 inputs, and outputs a high value IFF exactly two of the inputs are high.”IFF exactly two of the inputs are high.”

Page 20: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Problem SolutionProblem Solution

• Step One: Create truth tableStep One: Create truth tableINPUTSINPUTS OUTPUTSOUTPUTS

AA BB CC QQ

00 00 00

00 00 11

00 11 00

00 11 11

11 00 00

11 00 11

11 11 00

11 11 11

Page 21: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Problem SolutionProblem Solution

• Step One: Create truth tableStep One: Create truth tableINPUTSINPUTS OUTPUTSOUTPUTS

AA BB CC QQ

00 00 00

00 00 11

00 11 00

00 11 11

11 00 00

11 00 11

11 11 00

11 11 11

Page 22: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Problem SolutionProblem Solution• Step Two: Step Two: Scan the table to determine when the Output column is TRUE. Scan the table to determine when the Output column is TRUE.

Identify those instances:Identify those instances:

INPUTSINPUTS OUTPUTSOUTPUTS

AA BB CC QQ

00 00 00 00

00 00 11 00

00 11 00 00

00 11 11 11

11 00 00 00

11 00 11 11

11 11 00 11

11 11 11 00

Page 23: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Problem SolutionProblem Solution

•Step Three: Create Boolean expressionStep Three: Create Boolean expression

Q = (~A * B * C) + Q = (~A * B * C) +

(A * ~B * C) + (A * ~B * C) +

(A * B * ~C)(A * B * ~C)

Page 24: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Problem Solution: Step 4Problem Solution: Step 4

• STEP FOUR: Build the circuit to represent our STEP FOUR: Build the circuit to represent our Boolean Expression.Boolean Expression.

Click Button for the xLogicCircuits AppletClick Button for the xLogicCircuits Applet

Page 25: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Simplifying Boolean ExpressionsSimplifying Boolean Expressions

• When you look at complicated input When you look at complicated input combinations which result in Boolean combinations which result in Boolean expressions with many terms, you can expressions with many terms, you can save a lot of time by using some save a lot of time by using some simplification rules. These rules allow you simplification rules. These rules allow you to reduce and combine terms.to reduce and combine terms.

• You can find a summary of these simple You can find a summary of these simple Boolean rules on the next slide …Boolean rules on the next slide …

Page 26: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Boolean AxiomsBoolean Axioms

• TRUE * P = PTRUE * P = P• FALSE * P = FALSEFALSE * P = FALSE• FALSE + P = PFALSE + P = P• TRUE + P = TRUETRUE + P = TRUE• P + Q = Q + PP + Q = Q + P• P * Q = Q * PP * Q = Q * P

• (P + Q) +R = P + (Q + R)(P + Q) +R = P + (Q + R)• (P * R) * Q = P * (R * Q)(P * R) * Q = P * (R * Q)• P * ~P = FALSEP * ~P = FALSE• P + P = PP + P = P• P * P = PP * P = P

Page 27: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

De Morgan’s LawsDe Morgan’s Laws

• In addition to the preceding axioms, a In addition to the preceding axioms, a mathematician named de Morgan first provided mathematician named de Morgan first provided proof of the following laws:proof of the following laws:– ~(P * Q) = ~P + ~Q~(P * Q) = ~P + ~Q– ~(P + Q)= ~P * ~Q~(P + Q)= ~P * ~Q

• In your next lab assignment, you will confirm In your next lab assignment, you will confirm de Morgan’s Laws. You can easily do the lab by de Morgan’s Laws. You can easily do the lab by constructing a truth table with inputs for P, Q, constructing a truth table with inputs for P, Q, P*Q, ~(P*Q), ~P, ~Q, and ~P+~Q.P*Q, ~(P*Q), ~P, ~Q, and ~P+~Q.

Page 28: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Where We Are GoingWhere We Are Going

• Now that you have some understanding of Now that you have some understanding of how to build a general circuit, we will look how to build a general circuit, we will look at some specific ones.at some specific ones.

• Next time, we’ll consider circuits that play Next time, we’ll consider circuits that play particularly important roles in computer particularly important roles in computer operation: adders and Arithmetic Logic operation: adders and Arithmetic Logic Unit processing.Unit processing.

Page 29: N301 Designing Circuits

N301: Fundamental Computer Science ConceptsN301: Fundamental Computer Science ConceptsCopyright Copyright ©2004 ©2004 Department of Computer & Information ScienceDepartment of Computer & Information Science

Questions?Questions?