1 / 16

XOR Operator

XOR. XOR Operator. A short digression… … to introduce another Boolean operation: exclusive-OR (XOR). XOR Operator. Also referred to as an “odd” function since it returns a 1 only when an odd number of 1’s are input. Simplification.

Download Presentation

XOR Operator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XOR XOR Operator • A short digression… • … to introduce another Boolean operation: exclusive-OR (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

  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. BC B A A A 0 1 0 1 00 01 11 10 0 1 0 0 1 0 1 3 2 0 1 3 2 4 5 7 8 1 CD AB 00 01 11 10 0 1 3 2 00 01 4 5 7 8 11 12 13 15 14 10 8 9 11 10 K-Maps • A K-Map is a grid (map) where each square corresponds to a minterm 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)

More Related