Digital Circuits, Number Systems

advertisement
3/12/2015
Logical Arguments (cont.)
Lecture 04a / Spring 2015
State University of New York, Korea
Instructor: Dr. Ilchul Yoon
Adapted from slides by Paul Fodor
Quine’s Method
— The following method can be used to determine whether a given
88
propositional formula is a tautology, a contradiction, or a
contingency.
Let p be a propositional formula.
— If p contains no variables, it can be simplified to T or F, and hence
is either a tautology or a contradiction.
— If p contains a variable, then
1. select a variable, say q,
2. simplify both p[q := T] and p[q := F], denoting the simplified
formulas by p1 and p2, respectively, and
3. apply the method recursively to p1 and p2.
— If p1 and p2 are both tautologies, so is p.
— If p1 and p2 are both contradictions, so is p.
— In all other cases, p is a contingency.
1
3/12/2015
Quine’s Method Example
(p ∧ ~q → r) ∧ (r → p ∨ q) ∧ (p → ~r) ∧ (p ∨ q ∨ r)
→q
We first select a variable, say q, and then consider the two
cases, q := T and q := F.
1. For q := T, the formula ...→T can be simplified to T.
2. For q := F,
(p ∧ ~F → r) ∧ (r → p ∨ F) ∧ (p → ~r) ∧ (p ∨ F ∨ r)
→F
≡ (p ∧ T → r) ∧ (r → p) ∧ (p → ~r) ∧ (p ∨ r) → F
≡ (p → r) ∧ (r → p) ∧ (p → ~r) ∧ (p ∨ r) → F
≡ ~[(p → r) ∧ (r → p) ∧ (p → ~r) ∧ (p ∨ r)]
89
Quine’s Method Example cont.
~[(p → r) ∧ (r → p) ∧ (p → ~r) ∧ (p ∨ r)]
We select the variable p
1. For p := T
~[(T → r) ∧ (r → T) ∧ (T → ~r) ∧ (T ∨ r)]
≡ ~[r ∧ T ∧ ~r ∧ T] ≡ ~[r ∧ ~r] ≡ ~F ≡ T
2. For p := F
~[(F → r) ∧ (r → F) ∧ (F → ~r) ∧ (F ∨ r)]
≡ ~[T ∧ ~r ∧ T ∧ r] ≡ ~[~r ∧ r] ≡ ~F ≡ T
— This completes the process. All formulas considered,
including the original formula, are tautologies.
90
2
3/12/2015
The Logic of Compound Statements
Application: Digital Logic Circuits
Lecture 04b / Spring 2015
State University of New York, Korea
Instructor: Dr. Ilchul Yoon
Adapted from slides by Paul Fodor
Application: Digital Logic Circuits
— Analogy between the operations of switching devices and the
operations of logical connectives
Binary digits (bits): we will use the symbols 1 and 0 instead of “on” (“closed” or True) and “off” (“open” or False)
92
3
3/12/2015
Black Boxes and Gates
— Combinations of signal bits (1’s and 0’s) can be transformed
into other combinations of signal bits (1’s and 0’s) by means
of various circuits
— An efficient method for designing
complicated circuits is to build
them by connecting less
complicated black box circuits:
NOT,AND-, and OR-gates.
93
94
4
3/12/2015
Combinational Circuits
— Rules for a Combinational Circuit:
— Never combine two input wires.
— A single input wire can be split partway and used as input for
two separate gates.
— An output wire can be used as input.
— No output of a gate can eventually feed back into that gate.
— Examples:
95
Determining Output for a Given Input
— Inputs: P = 0 and Q = 1
96
5
3/12/2015
Constructing the Input/Output Table for a Circuit
— List the four possible combinations of input signals, and find
the output for each by tracing through the circuit.
97
The Boolean Expression Corresponding to a Circuit
— Trace through the circuit from left to right:
— What is the result?
98
6
3/12/2015
The Boolean Expression Corresponding to a Circuit
The result is: exclusive OR
99
Recognizer
— A recognizer is a circuit that outputs a 1 for exactly one
particular combination of input signals and outputs 0’s for all
other combinations.
— Example:
100
7
3/12/2015
The Circuit Corresponding to a Boolean Expression
1. Write the input variables in a column on the left side of the diagram
2. Go from the right side of the diagram to the left, working from the
outermost part of the expression to the innermost part
— Example: (∼P ∧ Q) ∨ ∼Q
101
Find a Circuit That Corresponds to an
Input/Output Table
1. Construct a Boolean expression with the same truth table
— identify each row for which the output is 1 and construct an
and expression that produces a 1 for the exact combination of
input values for that row
P∧Q∧R
P∧ ∼Q ∧ R
P∧ ∼Q ∧ ∼R
Result: (P ∧ Q ∧ R) ∨ (P∧∼Q ∧ R) ∨ (P∧∼Q∧∼R)
disjunctive normal form
102
8
3/12/2015
Find a Circuit That Corresponds to an
Input/Output Table
2. Construct the circuit for:
(P ∧ Q ∧ R) ∨ (P∧ ∼Q ∧ R) ∨ (P∧ ∼Q∧ ∼R)
103
Equivalent Combinational Circuits
— Two digital logic circuits are equivalent if, and only if, their
input/output tables are identical.
104
9
3/12/2015
Simplifying Combinational Circuits
1. Find the Boolean expressions for each circuit.
2. Show that these expressions are logically equivalent.
((P ∧ ∼Q) ∨ (P ∧ Q)) ∧ Q
≡ (P ∧ (∼Q ∨ Q)) ∧ Q
≡ (P ∧ (Q ∨ ∼Q)) ∧ Q
≡ (P ∧ T) ∧ Q
≡P∧Q
by the distributive law
by the commutative law for ∨
by the negation law
by the identity law.
105
NAND and NOR Gates
— A NAND-gate is a single gate that acts like an AND-
gate followed by a NOT-gate
— it has the logical symbol: |
(called Sheffer stroke)
P | Q ≡ ∼(P ∧ Q)
— A NOR-gate is a single gate that acts like an OR-gate
followed by a NOT-gate
— it has the logical symbol: ↓
(called Peirce arrow)
P ↓ Q ≡ ∼(P ∨ Q)
106
10
3/12/2015
Rewriting Expressions Using the Sheffer Stroke
— Any Boolean expression is equivalent to one written entirely with
Sheffer strokes or entirely with Peirce arrows
∼P ≡ ∼(P ∧ P) by the idempotent law for ∧
≡P|P
by definition of |.
P ∨ Q ≡ ∼(∼(P ∨ Q)) by the double negative law
≡ ∼(∼P ∧ ∼Q) by De Morgan’s laws
≡ ∼((P | P) ∧ (Q | Q)) by the above ∼P≡P|P
≡ (P | P) | (Q | Q) by definition of |
107
The Logic of Compound Statements
Application: Number Systems & Circuits
Lecture 04c / Fall 2014
State University of New York, Korea
Instructor: Dr. Ilchul Yoon
Adapted from slides by Publisher
11
3/12/2015
Number Systems
— Decimal number system
— e.g., 5,049 = 5 – (1,000) + 0 – (100) + 4 – (10) + 9 – (1)
— Base 10
— Based on the fact that any positive integer can be written
uniquely as a sum of products of the form: d – 10n
— Using exponential notation
5,049 = 5 – 103 + 0 – 102 + 4 – 101 + 9 – 100.
109
Number Systems
— Binary number system
— Base 2
— Based on the fact that any positive integer can be written
uniquely as a sum of products of the form: d – 2n
— Using exponential notation
5,049 = 1 – 212 + 1– 29 + 1 – 28 + 1 – 27 + 1 – 25 +
1 – 24 + 1 – 23 + 1 – 20
A list of powers of 2
110
12
3/12/2015
Binary Number to Decimal Number
— Represent 1101012 in decimal notation.
— Solution:
111
Decimal Number to Binary Number
— Represent 209 in binary notation.
— Solution:
Most Significant Bit
Least Significant Bit
112
13
3/12/2015
Binary Addition
— Basic addition:
— Add 11012 and 1112 using binary notation.
— Solution:
113
Binary Subtraction
— An example in decimal number system
— Similar in binary number system
— Subtract 10112 from 110002 using binary notation.
114
14
3/12/2015
Circuits for Computer Addition
— How to design a circuit to produce the sum of two binary digits
P and Q ?
— Rely on the Boolean expressions and gate properties
— First, for two single-digit binary numbers,
Carry
Sum
115
Half Adder
— Find Boolean expressions for “sum” (digit value) and “carry”
— Carry = P ∧ Q
— Sum = P Å Q = (P ∨ Q) ∧ ∼ (P ∧ Q)
— The circuit corresponding to the carry and sum is called a
half-adder.
Circuit to Add P + Q, Where P and Q Are Binary Digits
116
15
3/12/2015
Full Adder
— A circuit that can add multi-digit binary numbers.
— May be necessary to consider “carry” in addition to P and Q
— P, Q, and R that results in a carry (or left-most digit) C and a
sum (or right-most digit) S.
117
Full Adder
OR
C
S
Circuit to Add P + Q + R, Where P, Q, and R Are Binary Digits
118
16
3/12/2015
Ripple Carry Adder
— A type of parallel adder
— For k-bit number addition, k-1 full-adders and 1 half-adder
are needed.
119
A Parallel Adder to Add PQR and STU to Obtain WXYZ
Negative and Hexadecimal Numbers
Lecture 04 / Fall 2014
State University of New York, Korea
Instructor: Dr. Ilchul Yoon
Adapted from slides by Publisher
17
3/12/2015
Representing Negative Numbers
— A fixed number of bits for representing integers on a
computer
— How can we know a bit sequence represents positive or
negative numbers?
— Two’s Complements
121
Representing Negative Numbers
— How to compute 2’s complements?
— Example for 8-bit representation
— The (28-1) - a part can be done by flipping all bits of a (this
number is called one’s complement.)
— Then, add 1 in binary notation.
122
18
3/12/2015
Example: Two’s Complement
— Find the 8-bit two’s complement of 19.
— Solution:
— Verifying the correctness of the solution
123
Representing Negative Numbers
— Observe that because
— the two’s complement of the two’s complement of a number is the
number itself, and therefore,
124
19
3/12/2015
Example: Two’s Complement
— What is the decimal representation for the integer with two’s
complement 10101001?
— Solution:
— Verifying the correctness of the solution
125
20
Download