Computer Science

Exclusive or Operation

The exclusive or operation, often denoted as XOR, is a logical operation that outputs true only when the number of true inputs is odd. In computer science, XOR is commonly used in programming for tasks such as data encryption, error detection, and toggling bits. It is a fundamental concept in Boolean algebra and plays a crucial role in digital logic circuits.

Written by Perlego with AI-assistance

7 Key excerpts on "Exclusive or Operation"

Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.
  • Electronics in easy steps

    ...If both inputs are at a 1 then the output stays at a 0. In other words, the output is a 1 when only one of the inputs is exclusively a 1, hence eXclusive OR. You can see this exclusive function from the truth table. Input A Input B Output XOR Gate 0 0 0 0 1 1 1 0 1 1 1 0 The basic XOR gate only has two inputs. There are exclusive OR gates with more than two inputs, but how they will function depends on their implementation. In most cases, an XOR gate will output a 1 if an odd number of its inputs are a 1. However, you can see that this behavior doesn’t follow the strict definition of XOR, which states that only one input must be exclusively a 1. The logic symbol is used to denote XOR in algebraic expressions. If no XOR chips are to hand then an XOR gate circuit can be made from four NAND gates – the so called universal gate. The circuit for this is shown below. Why not work out the truth table for this, and prove that it does function as an XOR? XOR gate – output is 1 if ONLY one input is 1. You can build any logic circuit or function using only NAND gates. XNOR Gate The XNOR gate was designed for use when the opposite output was required from an XOR gate. This saved adding an extra NOT gate to the output of an XOR, and hence increasing the gate count. The XNOR gate This gate performs a NOT XOR function in a single circuit. The truth table for the XNOR gate is shown here. Input A Input B Output XNOR Gate 0 0 1 0 1 0 1 0 0 1 1 1 The input pattern remains the same as for the XOR gate, but the output is the opposite. When both inputs are a 0 or a 1, the output is now a 1. For the other two input combinations, where a XOR gate would give a 1 at the output, the XNOR gate gives a 0. Logically speaking, this gate is not an XOR gate! The XNOR function can also be constructed using five NOR gates...

  • Digital Logic Design
    • Brian Holdsworth, Clive Woods(Authors)
    • 2002(Publication Date)
    • Newnes
      (Publisher)

    ...OR is written as A OR B or as A + B. Thus A + B = 1 if A = 1 or B = 1 or A = B = 1. In addition to the above basic operations, one other function, the Exclusive-OR, is required for arithmetic-related operations. XOR. The Exclusive-OR of two variables is 1 if either of them but not both is 1. The XOR operation is written as A XOR B or as A B. Thus A B = 1 if A = 1 and B = 0 or if A = 0 and B = 1. 2.3 Derived Boolean operations The following Boolean operations are derived from the three basic operations by complementing or inverting those operations: XNOR. Exclusive NOR = NOT of (A XOR B) or, which is sometimes referred to as the coincidence function and is written A B. 2.4 Boolean functions A Boolean function consists of a number of Boolean variables joined by the Boolean connectives AND and OR. For example The dual of a function is obtained by changing the AND operations to OR operations and vice versa, and simultaneously changing any 1’s to 0’s and vice versa. Thus the dual of the function f = (AB + CD +) is given by Two functions are equivalent providing they have the same value (1 or 0) for each of the possible combinations of the variables. Two functions are complementary if one function equals 1 when the other function equals 0 and vice versa. The complement of a function can be found by complementing each literal in the dual of that function. Thus the complement of f (A, B, C, D) = AB + CD + is In evaluating Boolean equations AND operations are performed before OR operations unless the OR operation is enclosed within brackets. 2.5 Truth tables A truth table provides the basic method of describing a Boolean function. It contains a row for every combination of the variables and prescribes the value of the function (0 or 1) for each of these combinations. For the 3-variable function f (A, B, C) whose truth table appears in Figure 2.1, there are 2 3 combinations and the value of the function for each of these combinations is listed in the right hand column...

  • Electronic Logic Circuits
    • J. Gibson(Author)
    • 2013(Publication Date)
    • Routledge
      (Publisher)

    ...Such a circuit is called an exclusive-OR gate (because it excludes the case that both inputs are 1) and unlike the normal OR gate it is only defined as a circuit with two inputs. The truth table for the exclusive-OR gate is shown as Table 2.14. Table 2.14 The exclusive-OR function is often indicated by the symbol in equations. Hence, R = A B Although the exclusive-OR function is only defined for two inputs, an equation such as X = A B C D is exact because the same result is obtained whichever order the exclusive-OR operations are performed in. That is (A B) (C D) gives exactly the same result as ((A B) C) D. These multiple-input systems are not called exclusive-OR gates; this name is only applied to the two-input gate. Fig. 2.9 EXCLUSIVE-OR gate symbols Some of the circuit symbols for exclusive-OR gates are shown in Fig. 2.9. The exclusive-OR function is available as an integrated circuit but it is also easily constructed from the standard functions. For example, it can be shown that using NAND gates and these NAND gate logic circuits are shown in Fig. 2.10. Fig. 2.10 NAND gate implementations of the EXCLUSIVE-OR function 2.8 Logic circuit analysis Those readers who are familiar with linear electronic circuit analysis will be aware that the analysis process is difficult. In the case of combinational logic circuits, analysis is a trivial (although tedious) task. The aim of any circuit analysis is to start from a circuit diagram and to obtain an exact description of the behaviour of the circuit; when the circuit is a combinational logic one the result of an analysis will be either a Boolean expression or a truth table. To perform the analysis it is sufficient to work systematically through the circuit from the inputs to the outputs, determining the output of every gate. Example 2.4 Fig. 2.11 Analyse the circuit behaviour of the combinational logic system shown in Fig...

  • Digital Design
    eBook - ePub

    Digital Design

    Basic Concepts and Principles

    • Mohammad A. Karim, Xinghao Chen(Authors)
    • 2017(Publication Date)
    • CRC Press
      (Publisher)

    ...NOR is thus identical to the OR function that has its output inverted. The NOR function is realizable by combining an OR gate and a NOT gate. Figure 2.5 shows the truth table, logic symbol, and equivalent logic for the two-input NOR functions. It will also be shown later that NOR of a given set of inputs is the same as first realizing NOT of the inputs and then having these inverted inputs processed with an AND function. Figure 2.5 Two-input NOR function (a) truth table, (b) logic symbol, and (c) equivalent logic. Figure 2.6 Two-input XOR and XNOR functions (a) truth table and (b) logic symbols. Figure 2.7 Circuit consisting of only NAND logic gates. 2.2.6 Exclusive-OR and Exclusive-NOR Functions The exclusive-OR function (XOR for short), defined by f (A, B) = A ⊕ B, is a function that has an output of 1 if an odd number of its inputs are 1. The exclusive-NOR (XNOR for short) is just the opposite of the exclusive-OR and is denoted by f (A, B) = A ⊕ B. Figure 2.6 shows the truth table and the logic symbols for both of these logic functions. All these latter four functions (i.e., NAND, NOR, XOR, and XNOR) can be realized by suitably combining the other three logic functions. In fact, either only NAND or only NOR functions can be successively combined in certain sequence to generate both XOR and XNOR functions. The XOR and XNOR functions occur so frequently in digital design that devices have been designed to perform these functions as well as the others just discussed. Consider the logic circuit of Figure 2.7. Since the logic elements used in this circuit are all NAND gates, we shall use NAND logic concept to first investigate the nature of the logic output at point P 1, and then at points P 2 and P 3, and finally at point P 4...

  • Semiconductor Basics
    eBook - ePub

    Semiconductor Basics

    A Qualitative, Non-mathematical Explanation of How Semiconductors Work and How They are Used

    • George Domingo(Author)
    • 2020(Publication Date)
    • Wiley
      (Publisher)

    ...We use a normally closed relay, so when the relay is OFF the light is ON and vice versa. Figure 11.4 shows the OR function. Now the light is ON if either switch A or B or both are ON. On the right is the symbol we use for the OR function and in the middle is the truth table for the OR function. Finally, Figure 11.5 shows the circuit, the truth table and the symbol for the NOT operation, also called the inversion operation. These three circuits, AND, OR, and NOT, are the main Boolean operations that we use in electronic designs. For the design of digital functions, and for pure convenience, we like to use four additional operations. The first one is called the exclusive OR or XOR operation. I show it in Figure 11.6. I do not show the equivalent relay network for the XOR circuit because it would be more confusing than helpful. But you can see that, by definition, the XOR is ON if and only if just one, and only one, of the inputs is ON. If both are ON or both are OFF, the output is OFF. Figure 11.6 The XOR truth table (left) and its symbol (right). For the output to be ON, one and only one of the inputs has to be ON. The output is OFF when both inputs are ON or both are OFF. Figure 11.7 The seven logic symbols we use in designing digital electronic circuits. These symbols are the basic components used in electronics and from them we can define others that we'll use in subsequent sections. The added ones are basically the reversal of the first three. Figure 11.7 shows all the logic symbols that we use. It is actually quite simple to remember these symbols and memorizing them will help you to follow the circuits that I explain later on. The only symbol with a triangle is the NOT circuit. If the line on top of the ovals is straight, the symbol is the AND function, if curved, it is the OR function, and if it has two curves on top, it is the XOR function. These last three may have a small ball at the output terminal, as I show in the second row of Figure 11.7...

  • Introduction to Digital Electronics

    ...1.6 Logic symbols, Boolean operators and truth tables of the common logic gates The gates shown in Fig. 1.6 include the NAND and NOR gates which are the NOT’d versions of the AND and OR gates (i.e. NOT-AND and NOT-OR). This simply means that their outputs are inverted, which is indicated by the bubbles on the outputs. 7 They are equivalent to AND and OR gates whose outputs are then passed through an inverter (NOT gate). The exclusive-OR gate The other new gate introduced at this stage is the exclusive-OR (XOR) gate whose output is 1 if and only if an odd number of inputs are 1. So a two-input XOR gate differs from the corresponding OR gate because Y = 0 if both A and B are 1 since in this case an even number of inputs is 1. The Boolean expression for the output from a two-input XOR gate is: Example 1.16 Write out the truth table for a three-input XOR gate and draw its circuit symbol. Solution These are shown in Fig. 1.7 Fig. 1.7 Truth table and symbol for a three-input XOR gate (see Example 1.16) In addition to the operation of logic circuits being described in terms of Boolean equations and circuit diagrams, remember that truth tables can also be used, as shown in Table 1.2. To recap, a truth table shows how the output(s) of a circuit (i.e. whether 0 or 1) depends upon the input(s). We now have three ways of representing the operation of a digital circuit: by a Boolean algebraic expression; a circuit diagram; or a truth table. Note that the rows of the truth table are ordered in binary code: i.e. 000, 001, 010, 011, etc. (for a table with three input variables). Example 1.17 Draw the circuit, and write out the truth table, for the Boolean expression stating what single gate it is functionally equivalent to. Then prove this equivalence using Boolean algebra. Solution The circuit and truth table are shown in Fig. 1.8. This complete circuit performs the function of an XOR gate. Fig...

  • Digital Logic Techniques
    • John Stonham(Author)
    • 2017(Publication Date)
    • CRC Press
      (Publisher)

    ...T is true. Connectives 0 and 15 are independent of the inputs and always give a constant output, whereas 3 and 5 are both independent of one variable, and have outputs identical to A and B, respectively; 10 and 12 are also only dependent on one variable, the outputs taking the opposite value of the inputs. This is the INVERSE or NOT function. The two propositional functions AND and OR occur as connectives 1 and 7, whereas 8 and 14, the inverse of these functions, are called NAND and NOR. NAND means NOT AND. Connective 6 is the EXCLUSIVE OR function. It differs from the OR operation in one important respect. The OR function is true if both inputs are true, whereas the EXCLUSIVE OR would be false under these input conditions. Both functions are true when only one input is true. OR is sometimes known as INCLUSIVE OR. Table 2.3 Binary connectives between inputs A.B and output Z The logic designer must be aware of the difference between OR and EX.OR. The distinction is not always obvious in natural language. Consider the following statements: Safety limit for elevator is 12 persons OR 1 ton goods. We will acept US dollars OR pounds sterling. OR function can have any number of inputs. EX.OR is a function of only two inputs. Statement (i) uses the EXCLUSIVE OR connective whereas statement (ii) is the OR function. Worked Example 2.2 Which binary connective is being used in the following statement? ‘For £10 I can buy one compact disc OR two cassette tapes.’ Solution The statement was an OR connective. Assuming a CD costs £10 and a tape costs £5, the statement implies purchase of the CD and not the tapes or the tapes and not the CD. It is not possible to buy both the two cassette tapes and the CD. This is the Exclusive or Operation: F = A ⊕ B = A B ¯ + A ¯ B Logic gates A logic gate is a two-state device that implements a binary connective. Most logic devices are electronic, although logic operations can be performed by mechanical, magnetic and even fluid systems...