Download presentation
Presentation is loading. Please wait.
Published byPrimrose Hines Modified over 8 years ago
1
XOR Operator A short digression… … to introduce another Boolean operation: exclusive- OR (XOR) ABA + B 000 011 101 110 XOR
2
XOR Operator Also referred to as an “odd” function since it returns a 1 only when an odd number of 1’s are input ABCA+B+C 0000 0011 0101 0110 1001 1010 1100 1111
3
Simplification Using the axioms to “prove” that a simplified version of a circuit is equivalent to the complex version takes a special kind of person… –…of which I’m not one Fortunately, there’s another way…
4
Karnaugh Maps Also known as K-Map Recall that an expression can be written in the form F(A,B,C) = Σ(0,2,4,5,6) Which means the functional value is 1 at binary input patterns 0, 2, 4, 5, 6 and 0 at all other input patterns –What does the truth table look like?
5
K-Maps F(A,B,C) = Σ(0,2,4,5,6) is called a “sum of minterms” representation The expression for such a representation is F(A,B,C) = A’B’C’ + A’BC’ + AB’C’ + AB’C + ABC’ We could simplify this via the axioms, right? (assuming we were that special kind of person) It’s painful!!!
6
K-Maps A K-Map is a grid (map) where each square corresponds to a minterm 0132 4578 12131514 891110 AB CD 00 01 11 10 00011110 01 32 0 1 10 A B 01 10 A 0132 4578 A 0 1 00011110 BC Note the ordering here is Gray code, not binary
7
K-Maps Notice how neighboring squares (minterms) differ by a single bit…this is the key to the whole thing –Consider minterms 1 and 3 1: A’B’C 3: A’BC –If we were to OR these together (A’B’C + A’BC) would simplify to A’C via the axioms
8
K-Maps Great, now what do we do with them? Place 1’s on the squares that correspond to minterms in the truth table Place 0’s on all other squares Group adjacent 1’s into the largest group whose size is a power of 2 –See example
9
K-Maps Notes: –Adjacencies wrap top-to-bottom and left-to- right –1’s can be part of more than one group –When you are grouping adjacent squares you’re essentially applying axiom 4 (x + x’ = 1) so the variable that is being “spanned” can be removed from the minterm
10
K-Maps We’ll do more of this next time so continue reading in Chapter 1
11
Assignment #4 Implement the method BooleanOperator in the given class public class BooleanOperator { static final int AND = 0; static final int OR = 1; static final int NOT = 2; static final int NAND = 3; static final int NOR = 4; static final int XOR = 5; static String BooleanOperator (String _lhs, String _rhs, int _oper) { String result = new String(); // -- YOUR CODE TO ASSIGN SOMETHING TO result GOES HERE return result; }
12
Assignment #4 The method should perform as follows –_lhs is a string of 0’s and 1’s corresponding to the left hand side of a Boolean operation –_rhs is a string of 0’s and 1’s corresponding to the right hand side of a Boolean operation –_oper specifies the Boolean operation to be performed The method should perform the specified operation on each of the “bit-pairs” in the two strings
13
Assignment #4 For example… …should return the string “0001” The other operators should work in a similar manner returning the appropriate bit patterns in the string The NOT operation should return the inverse of the _lhs operand (ignore the _rhs operand) If _lhs and _rhs are not the same length, your method should pad the shorter one with ‘0’s in the MSBs prior to performing the operation –i.e. _lhs = “11”, _rhs = “1” becomes _lhs = “11”, _rhs = “01” String result = BooleanOperator.BooleanOperator(“0011”, “0101”, BooleanOperator.AND);
14
Assignment #4 Create a test class (e.g. TestBoolean.java) to test your code by –Print out truth tables for each of the operators –Answer questions 1-1 and 1-2 on page 37 of the text. –Note that you may have to “chain” operations i.e. ABC must be done in two steps (AB)C which is allowed by the axioms
15
Assignment #4 Also, do problems 1-3, 1-4, 1-5, 1-6, and 1-7 on page 37 of the text –You won’t be using your program on these problems
16
Assignment #4 Turn in –A print out of your BooleanOperator.java –A print out of your TestBoolean.java –A print out of a screen shot of your results –Your answers to problems 1-3 through 1-7 Due next lecture (Tuesday)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.