xor.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <html>
  2. <head>
  3. <title>XOR/XNOR/Odd Parity/Even Parity Gate</title>
  4. </head>
  5. <body bgcolor="FFFFFF">
  6. <table><tr><td>
  7. <img align="center" src="../../../../en/icons/xorGate.gif" width="32" height="32">
  8. <img align="center" src="../../../../en/icons/xnorGate.gif" width="32" height="32">
  9. <img align="center" src="../../../../en/icons/parityOddGate.gif" width="32" height="32">
  10. <img align="center" src="../../../../en/icons/parityEvenGate.gif" width="32" height="32"><br>
  11. <img align="center" src="../../../../en/icons/xorGateRect.gif" width="32" height="32">
  12. <img align="center" src="../../../../en/icons/xnorGateRect.gif" width="32" height="32">
  13. <img align="center" src="../../../../en/icons/parityOddGate.gif" width="32" height="32">
  14. <img align="center" src="../../../../en/icons/parityEvenGate.gif" width="32" height="32">
  15. </td><td valign="center"><h1><em>XOR/XNOR/Odd Parity/Even Parity Gate</em></h1></table>
  16. <p><table>
  17. <tr><td><strong>Library:</strong></td>
  18. <td><a href="index.html">Gates</a></td></tr>
  19. <tr><td><strong>Introduced:</strong></td>
  20. <td>2.0 Beta 1 for XOR/Odd/Even; 2.0 Beta 6 for XNOR</td></tr>
  21. <tr><td valign="top"><strong>Appearance:</strong></td>
  22. <td valign="top"><table>
  23. <tr><th></th>
  24. <th width="60">XOR</th>
  25. <th width="60">XNOR</th>
  26. <th width="50">Odd<br>Parity</th>
  27. <th width="50">Even<br>Parity</th></tr>
  28. <tr><th valign="middle" height="65" align="left">Shaped:</th>
  29. <td rowspan="3" colspan="4">
  30. <img src="../../../../en/img-libs/xor.png" width="295" height="113">
  31. </td></tr>
  32. <tr><th valign="middle" height="65" align="left">Rectangular:</th></tr>
  33. </table></td></tr>
  34. </table></p>
  35. <h2>Behavior</h2>
  36. <p>The XOR, XNOR, Even Parity, and Odd Parity gates each compute
  37. the respective function of the inputs, and emit the result on the
  38. output.</p>
  39. <p>By default, any inputs that are left unconnected are ignored
  40. &mdash; that's if the input truly has nothing attached to it,
  41. not even a wire.
  42. In this way, you can insert a 5-input gate but only attach two inputs,
  43. and it will work as a 2-input gate;
  44. this relieves you from having to worry about configuring
  45. the number of inputs every time you create a gate.
  46. (If all inputs are unconnected, the output is the error value <em>X</em>.)
  47. Some users, though, prefer that Logisim insist that all inputs be connected,
  48. since this is what corresponds to real-world gates.
  49. You can enable this behavior by going to the Project &gt; Options&hellip; menu item,
  50. selecting the Simulation tab, and
  51. selecting <q>Error for undefined inputs</q> for
  52. <q>Gate Output When Undefined.</q></p>
  53. <p>The two-input truth table for the gates is the following.</p>
  54. <center><table>
  55. <tr><th><var>x</var></th><th><var>y</var></th><th>XOR</th>
  56. <th>XNOR</th><th>Odd</th><th>Even</th></tr>
  57. <tr><td align="center">0</td><td align="center">0</td>
  58. <td align="center">0</td><td align="center">1</td>
  59. <td align="center">0</td><td align="center">1</td></tr>
  60. <tr><td align="center">0</td><td align="center">1</td>
  61. <td align="center">1</td><td align="center">0</td>
  62. <td align="center">1</td><td align="center">0</td></tr>
  63. <tr><td align="center">1</td><td align="center">0</td>
  64. <td align="center">1</td><td align="center">0</td>
  65. <td align="center">1</td><td align="center">0</td></tr>
  66. <tr><td align="center">1</td><td align="center">1</td>
  67. <td align="center">0</td><td align="center">1</td>
  68. <td align="center">0</td><td align="center">1</td></tr>
  69. </table></center>
  70. <p>As you can see, the Odd Parity gate and the XOR gate behave identically
  71. with two inputs; similarly, the even parity gate and the XNOR gate
  72. behave identically.
  73. But if there are more than two specified inputs, the XOR gate will emit
  74. 1 only when there is exactly one 1 input, whereas the Odd Parity gate
  75. will emit 1 if there are an odd number of 1 inputs.
  76. The XNOR gate will emit 1 only when there is <em>not</em> exactly one 1
  77. input, while the Even Parity gate will emit 1 if there are an even
  78. number of 1 inputs. The XOR and XNOR gates include an attribute titled
  79. Multiple-Input Behavior that allow them to be configured to use the
  80. Odd Parity and Even Parity behavior.</p>
  81. <p>If any of the
  82. inputs are the error value (e.g., if conflicting values are coming into
  83. the same wire) or floating, then the output will be the error value.</p>
  84. <p>The multi-bit versions of each gate will perform its one-bit
  85. transformation bitwise on its inputs.</p>
  86. <p><strong>Note:</strong> Many authorities contend that the shaped XOR
  87. gate's behavior should correspond to the odd parity gate, but there is
  88. not agreement on this point. Logisim's default behavior for XOR gates is based
  89. on the IEEE 91 standard. It is also consistent with the intuitive
  90. meaning underlying the term <em>exclusive or</em>: A waiter asking
  91. whether you want a side dish of mashed potatoes, carrots, peas, or cole
  92. slaw will only accept one choice, not three, whatever some authorities
  93. may tell you. (I must admit, though, that I have not subjected this
  94. statement to a rigorous test.) You can configure the XOR and XNOR gates
  95. to use parity by changing its <q>Multiple-Input Behavior</q> attribute.</p>
  96. <h2>Pins (assuming component faces east)</h2>
  97. <dl>
  98. <dt>West edge (inputs, bit width according to Data Bits attribute)</dt>
  99. <dd><p>The inputs into the component. There will be as many of these as
  100. specified in the Number of Inputs attribute.</p>
  101. <p>Note that if you are using shaped gates, the west side of XOR and
  102. XNOR gates will be curved. Nonetheless, the input pins are in a line.
  103. Logisim will draw short stubs illustrating this; and if you overshoot a
  104. stub, it will silently assume that you did not mean to overshoot it. In
  105. "printer view", these stubs will not be drawn unless they are connected
  106. to wires.</p></dd>
  107. <dt>East edge (output, bit width according to Data Bits attribute)</dt>
  108. <dd><p>The gate's output, whose value is computed based on the current
  109. inputs as described above.</p></dd>
  110. </dl>
  111. <h2>Attributes</h2>
  112. <p>When the component is selected or being added,
  113. the digits '0' through '9' alter its <q>Number of Inputs</q> attribute,
  114. Alt-0 through Alt-9 alter its <q>Data Bits</q> attribute,
  115. and the arrow keys alter its <q>Facing</q> attribute.</p>
  116. <dl>
  117. <dt>Facing</dt>
  118. <dd>The direction of the component (its output relative to its inputs).</dd>
  119. <dt>Data Bits</dt>
  120. <dd>The bit width of the component's inputs and outputs.</dd>
  121. <dt>Gate Size</dt>
  122. <dd>Determines whether to draw a wider or narrower version of the
  123. component. This does not affect the number of inputs, which is specified
  124. by the Number of Inputs attribute; however, if the number of inputs exceeds 3 (for a
  125. narrow component) or 5 (for a wide component), then the gate will
  126. be drawn with "wings" to be able to accommodate the number of inputs
  127. requested.</dd>
  128. <dt>Number of Inputs</dt>
  129. <dd>Determines how many pins to have for the component on its west
  130. side.</dd>
  131. <dt>Output Value</dt>
  132. <dd>Indicates how false and true results should be translated into output values.
  133. By default, false is indicated by a low voltage (0) and true by a high voltage (1),
  134. but one or the other can be replaced by a high-impedance (<q>floating</q>) value
  135. instead. This allows wired-or and wired-and connections, as illustrated in
  136. the <a href="basic.html">AND/OR/NAND/NOR Gate documentation</a>.</dd>
  137. <dt>Label</dt>
  138. <dd>The text within the label associated with the gate.</dd>
  139. <dt>Label Font</dt>
  140. <dd>The font with which to render the label.</dd>
  141. <dt>Multiple-Input Behavior (XOR and XNOR only)</dt>
  142. <dd>When three or more inputs are provided, the XOR/XNOR gate's output will
  143. either be based on whether exactly one input is 1 (the default) or an odd number
  144. of inputs are 1.</dd>
  145. </dl>
  146. <h2>Poke Tool Behavior</h2>
  147. <p>None.</p>
  148. <h2>Text Tool Behavior</h2>
  149. <p>Allows the label associated with the gate to be edited.</p>
  150. <p><a href="../index.html">Back to <em>Library Reference</em></a></p>
  151. </body>
  152. </html>