A Tutorial On The Boolean Logic Gates and Their Quick Understanding! by R. Steve Walz rstevew@armory.com The Gates: BUFFER, INVERTER, AND, NAND, OR, NOR, XOR, XNOR , that's ALL! Call them XORs and XNORs, it's more correct and consistent. The X means that the state where all Inputs are 1 is *eXcluded* from being like that same line of the OR and NOR, respectively, that's all!! You will note that the A=1 B=1 lines of the XOR and XNOR are the ONLY lines which are opposite the OR and NOR, both respectively!! ALSO, note that all gates with an "N" in front of the primary proposition, BUFFER, AND, OR XOR, have inverted entries for their Outputs from their primaries! Okay, THE BOOLEAN TRUTH TABLE for ALL GATES!! ( na = Not Applicable: The BUFFER and INVERTER have only 1 INPUT ) +--------+----------------------------------------------------+ | INPUTS | OUTPUTS | +--------+------------------+-----------+---------+-----------+ | B A | BUFFER INVERTER | AND NAND | OR NOR | XOR XNOR | +--------+------------------+-----------+---------+-----------+ | na 0 | 0 1 | na | na | na | | na 1 | 1 0 | na | na | na | +--------+------------------+-----------+---------+-----------+ | 0 0 | na | 0 1 | 0 1 = 0 1 | | 0 1 | na | 0 1 | 1 0 = 1 0 | | 1 0 | na | 0 1 | 1 0 = 1 0 | | 1 1 | na | 1 0 | 1 0 =#= 0 1 | <--"X" +--------+------------------+-----------+---------+-----------+ "Driver" |\ "NOT Gate" |\ BUFFER A--| >-- INVERTER A--| >O-- <--Note: "BALL"="N"=INVERTER ___ |/ ___ ___ |/ ___ ___ ___ A--| \ A--| \ A--\ \ A--\ \ A--\\ \ A--\\ \ | AND )-- |NAND )O-- ) OR )-- )NOR )O-- ))XOR )-- ))XNOR)O-- B--|___ / B--|___ / B--/____/ B--/___ / B--//___ / B--//___ / Note: A "BALL" on Outputs Shows NOT+AND=NAND , NOT+OR=NOR , NOT+XOR=XNOR As for writing Boolean propositions in Boolean Algebra, actually, once you learn the Gates and DeMorgan's Laws, then you can do most problems mostly by inspection!! If we use "-" for an inversion or "NOT", and "*" for AND, and "+" for OR, and "(+)" for XOR, then we can write these like a simple equational algebra starting with the "Output" on one side and the Gate Array that produces it on the other using the equals sign! A AND B : A*B , A OR B : A+B , A XOR B : A(+)B , NOT(A AND B) : -(A*B) and et cetera. So XOR means, precisely, Either JUST One Input OR ANY Other Input = 1, But NOT Both(or All). This lets us write: XOR: A(+)B = (-A*B)+(A*(-B)) or XNOR: -(A(+)B) = -[(-A*B)+(A*(-B))] Can you see why XOR is a difference detector and XNOR is a comparator?? Note that Gates CAN have MORE than 2 Inputs, and the same principles apply. Namely, that for an AND or NAND, the only Inputs which result in a 1 Output or 0 Output, respectively for those two, are the case in Which the ALL(EVERY) Input = 1 is TRUE. The OR or NOR is like its simple rule as well, that Either One Input must = 1 OR the OTHER(ANY) Input = 1 for its Output to = 1 . Thus there are many-Inputted forms of All Gates! To "N" the Output, merely put the Input of an INVERTER on the Gate Output and its Output IS the "N" version of BUFFER, AND, OR, and XOR Gates. Thus, if you don't HAVE an XOR Gate, then you can MAKE one of ANDs, an OR, and INVERTERS from the above recipe, as follows: |\ ___ [A]-+-----| >O--[-A]--| \ | |/ | )--[(-A)*B]--+ | +--------[B]---|___ / | ___ | | +--\ \ | | ) )---[((-A)*B)+(A*(-B))] | | ___ +--/___ / = A(+)B !!! +--]--------[A]---| \ | | |\ | )--[A*(-B)]--+ [B]----+--| >O--[-B]--|___ / |/ So you see, those equations actually MEAN these Gates doing the work, and the Output gets its meaning from the inner propositions OUTWARD!! There are a list of AXIOMS for Boolean manipulations of equations in any Logic book. They are very like their plain algebraic cousins!! And DeMorgan's Laws look difficult as equations, and make perfect sense when you do them as Gates. Here's the secret to remembering DeMorgan's Laws: "Any AND or OR Gate-core can be seen to be its opposite core with all its Inputs and Outputs which ARE INVERTED becoming UN-INVERTED, and all Inputs or Outputs which are NOT INVERTED *BECOMING* INVERTED!!" Examples: +---------+---------INVERSIONS------------+ | | | |\ v ___ | | ____ A---| >O--| \ v A----------\ \ |/ |NAND )O--- <== EQUALS ==> |\ v ) OR )---- B----------|___ / B---| >O--/____/ |/ +--+----------+---INVERSIONS | | | |\ v | ___ | ___ A---| >O------| \ v A----\ \ |/ __| |NAND )O--- <== EQUALS ==> ) OR )---- | +--|___ / B----/___ / |\ v | ^^^^^ ^^^^^ B---| >O---+ NO INVERSIONS |/ +------------------INVERSIONS-------------+---------+ | | | |\ v ___ | ___ | A---| >O--| \ A----------\ \ v |/ | AND )---- <== EQUALS ==> |\ v )NOR )O--- B----------|___ / B---| >O--/___ / |/ INVERSIONS-------+--+-----------+ | | | NO INVERSIONS |\ v | | vvvv vvv ----| >O----+ | ___ |/ __| | ___ | ----| \ | +--\ \ v | AND )---- <== EQUALS ==> |\ v )NOR )O--- ----|___ / ----| >O-------/___ / |/ A quicker way to draw this stuff is to JUST USE BALLS for INVERSIONS!: DeMorgan's Laws in Gate form: ( <==> = "Is Equivalent To", and in both directions! ) ___ ___ A---| \ A--O\ \ | AND )--- <==> ) OR )O-- <-- A true AND Gate at left! B---|___ / B--O/___ / (Yes, it looks like an NOR, but just ___ ___ think of "BALLs" as discrete "NOTs"!) A--O| \ A---\ \ | AND )--- <==> ) OR )O-- B---|___ / B--O/___ / ___ ___ A---| \ A--O\ \ | AND )--- <==> ) OR )O-- B--O|___ / B---/___ / ___ ___ A--O| \ A---\ \ | AND )--- <==> ) OR )O-- <-- A true NOR Gate! B--O|___ / B---/___ / ___ ___ A---| \ A--O\ \ | AND )O-- <==> ) OR )--- <-- A true NAND Gate at left! B---|___ / B--O/___ / ___ ___ A--O| \ A---\ \ | AND )O-- <==> ) OR )--- B---|___ / B--O/___ / ___ ___ A---| \ A--O\ \ | AND )O-- <==> ) OR )--- B--O|___ / B---/___ / ___ ___ A--O| \ A---\ \ | AND )O-- <==> ) OR )--- <-- A true OR Gate B--O|___ / B---/___ / In OTHER words, swap OR core for AND, and put "BALLs" where there weren't and take them away where they were, and you have converted an OR to AND core proposition, or the reverse. These above are EQUALITIES, which have the SAME TRUTH TABLE as the Gate Array!! For further fun, use DeMorgan and "slide" the "BALLs" along a wire to where two meet and cancel and see what results, or introduce two at opposite ends of a wire and see what DeMorgan Law conversions can be accomplished to use up hex gate and quad gate chips most efficiently!! Look at our first XOR made of an OR, 2 ANDs, and 2 NOTs above and see if you can make it ONLY with either NAND or NOR gates. These are the only two Gates which each have the property that ALL other Gates can be made from them alone, all NANDs or all NORs, even any computer architecture, functionally speaking!! And even though DeMorgan's Laws don't cover the XOR and XNOR Gates: There ARE even SOME interesting DeMorgan-esque features like this to the XOR and XNOR Gates, but I'll leave that exploration to you out there with idle time and a lot of napkins at some restaurant tonight!! I'm getting tired of drawing!! ;-) Take good care, -Steve -- Copyright (C) 1997 by Richard Steven Walz - Free Non-Commercial Use All Commercial Rights Reserved by Author -- -Steve Walz rstevew@armory.com ftp://ftp.armory.com:/pub/user/rstevew -Electronics Site!! 1000 Files/50 Dirs!! http://www.armory.com/~rstevew Europe:(Italy) ftp://ftp.cised.unina.it:/pub/electronics/ftp.armory.com