Computer Science 101

14
Computer Science Computer Science 101 101 Circuit Design Algorithm Circuit Design Algorithm

description

Computer Science 101. Circuit Design Algorithm. Circuit Design - The Problem. The problem is to design a circuit that accomplishes a specified task. What does this mean? What kind of task? We would like to specify The number of inputs to the circuit. The number of outputs. - PowerPoint PPT Presentation

Transcript of Computer Science 101

Page 1: Computer Science 101

Computer Science Computer Science 101101

Circuit Design AlgorithmCircuit Design Algorithm

Page 2: Computer Science 101

Circuit Design - The ProblemCircuit Design - The Problem The problem is to design a circuit that The problem is to design a circuit that

accomplishes a specified task.accomplishes a specified task.

What does this mean? What does this mean?

What kind of task?What kind of task?

We would like to specifyWe would like to specify• The number of inputs to the circuit.The number of inputs to the circuit.• The number of outputs.The number of outputs.• What value each output should have for each What value each output should have for each

setting of the inputs.setting of the inputs.

Page 3: Computer Science 101

Circuit Design - Circuit Design - ObservationsObservations

We can deal with one output at a We can deal with one output at a time. time.

The truth table is a good way to The truth table is a good way to organize the specifications.organize the specifications.

If we can come up with a Boolean If we can come up with a Boolean expression for the output, we’re home expression for the output, we’re home free.free.

Page 4: Computer Science 101

Circuit Design and Truth TableCircuit Design and Truth Table

The problem reduces to this:The problem reduces to this:• Given a truth table with all values for inputs.Given a truth table with all values for inputs.• And given a column of values for the output.And given a column of values for the output.• Find a Boolean expression that yields the Find a Boolean expression that yields the

specified column.specified column.

If we can do this, we can get the circuit from If we can do this, we can get the circuit from the Boolean expression.the Boolean expression.

We now develop an algorithm, the Sum of We now develop an algorithm, the Sum of Products algorithm, to find the expression.Products algorithm, to find the expression.

Page 5: Computer Science 101

Circuit Design - Typical Circuit Design - Typical ProblemProblem

A B C Output

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

Find Boolean Find Boolean expression for expression for the output.the output.

Note that this is a Note that this is a “Majority Rules” “Majority Rules” circuit.circuit.

The output The output reflects the reflects the majority input.majority input.

Page 6: Computer Science 101

Circuit Design - First CaseCircuit Design - First Case

A B C Output

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 0

Consider case where Consider case where output column has output column has only one 1.only one 1.

Want expression Want expression which is true whenwhich is true when• A is false _A is false _

(A true) and (A true) and• B is true andB is true and• C is true C is true

__ ABC does the trick. ABC does the trick.

Page 7: Computer Science 101

Sum of Products Algorithm-Sum of Products Algorithm- Single 1Single 1

Note row in which the 1 occurs.Note row in which the 1 occurs.

Make a product of all the input Make a product of all the input variables.variables.

Put a bar over each variable that Put a bar over each variable that has a value of 0 in this row.has a value of 0 in this row.

Page 8: Computer Science 101

Sum of Products - Single 1Sum of Products - Single 1

A B C Output

0 0 0 0

0 0 1 0

0 1 0 0

0 1 1 1

1 0 0 0

1 0 1 0

1 1 0 0

1 1 1 0

Note row where Note row where the 1 occurs.the 1 occurs.

Make product of Make product of all variables.all variables.

ABC ABC Put bar over Put bar over

variables with 0 variables with 0 value.value. _ _ ABC ABC

Page 9: Computer Science 101

Sum of Products - General Sum of Products - General CaseCase

A B C Output

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 0

Want BE that is Want BE that is true if true if • __

ABC is true OR ABC is true OR• __

ABC is true OR ABC is true OR• __

ABC is true ABC is true _ _ _ _ _ _

ABC+ABC+ABC ABC+ABC+ABC

Page 10: Computer Science 101

Sum of Products AlgorithmSum of Products Algorithm

Identify each row of the output that has Identify each row of the output that has a 1.a 1.

For each such rowFor each such row• Make a product of all the input variables.Make a product of all the input variables.• Put bar over each variable with a 0 in this Put bar over each variable with a 0 in this

row.row.

Make a sum of all of these product Make a sum of all of these product terms.terms.

Page 11: Computer Science 101

Sum of Products - ExampleSum of Products - Example

Problem: Design a logic circuit withProblem: Design a logic circuit with• 3 input lines, 1 output line3 input lines, 1 output line• Anytime we change the value of any one of Anytime we change the value of any one of

the inputs, the output value changes.the inputs, the output value changes.• Think of a single light bulb controlled by three Think of a single light bulb controlled by three

light switches that work independently.light switches that work independently.

Note: Once we set the output for one set Note: Once we set the output for one set of inputs, the rest is determined.of inputs, the rest is determined.

We’ll start with all inputs 0 giving output We’ll start with all inputs 0 giving output 0.0.

Page 12: Computer Science 101

Example continuedExample continued

A B C Output

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 0

1 0 0 1

1 0 1 0

1 1 0 0

1 1 1 1

1’s in output 1’s in output give _ _ _ give _ _ _ _ _ABC + ABCABC + ABC _ _ _ _+ ABC + ABC+ ABC + ABC

Page 13: Computer Science 101

Circuit for the exampleCircuit for the exampleA

B

Boolean Expression

_ _ _ _ _ _

ABC+ABC+ABC+ABC

C

Page 14: Computer Science 101