Lecture Notes 05 (29 January 2002)

Logic Gates


Please Note:

  • The beginning of today's lecture, will start by revisiting the end of the previous lecture
  • Today's lecture will involve many demonstrations using the "Logg-O" software from the DH text. Please see the following information regarding using the Decker/Hirschfield software.

  • Overall Reading
    Brookshear: pp. 18-20
    Decker/Hirshfield: Mod. 7.1-7.2

    Outline:

  • The truth about bits: bits about truth
  • Logical Operators (Boolean algebra)
  • Logic Gates
  • Building Circuits

  • The truth about bits: bits about truth

    We have talked about representing information digitally, through the use of bits of memory, where every bit is set to one of two possible states.

    When representing numerical information, we used a binary system, and thus abstracted these two states into numerals, {0,1}, even though the underlying physical mechanism is not inherently numerical.

    Today, we will draw a parallel between the two-states of a bit and representing logical information with the two states, {true, false}.

    We can imagine applications where a computer uses various bits of memory to represent the truth of various statements:

    I am outside.
    It is raining.
    I am wet.
    At any given time, each of these statements might be true or false. For example, it may be the case that:
    I am outside = false
    It is raining = true
    I am wet = false

    Computer scientist still tend to like to use numerals, so by convention, we equate 0=false and 1=true.


    Logical Operators (Boolean Algebra)

    Furthermore, we feel that we understand sometimes how the truth about one statement may relate to the truth, or lack thereof, of another statement. For example, is the following state of affairs possible:
    I am outside = true
    It is raining = true
    I am wet = false
    Or what about this state:
    I am outside = true
    It is raining = false
    I am wet = true

    In some settings, we feel that we can apply logic to relate the state of various statements (ahh...is that why we use the word 'statement')

    In English, we start to build compound statements using conjunctions such as: AND, OR, NOT.
    What is the semantics of the conjunction 'AND'?

    AB(A  AND  B)
    000
    010
    100
    111

    What about semantics of 'OR'?

    AB(A  OR  B)
    00
    01
    10
    11


    Once you start playing with compound statements, you will start to find some interesting theorems, for example the statement:

    NOT (A  OR  B)
    is equivalent to the statement
    NOT(A)  AND  NOT(B)
    (Note: this is known as DeMorgan's Law)

    AB(A  OR  B)NOT(A  OR  B)NOT(A)NOT(B) NOT(A)  AND  NOT(B)
    0001111
    0110100
    1010010
    1110000

    There is an underlying algebra system which relates how truth values and these logical operators interact. One of the early names in studying these properties was a mathematician named George Boole (1815-1864). For this reason, we refer to this system as Boolean algebra, and to logical operations as Boolean operations. In fact many modern programming languages refer to variables which can only take two values, true or false, as Boolean variables.

    Sometimes, Boolean expresions are written using the syntax of arithmetic (though the semantics of boolean algebra):

    '+' is used for OR (e.g. 'A+B')
    concatenation is used for AND (e.g. 'AB')


    Logic Gates

    We can physically build electronic devices which demonstrate the behavior of the logical operators discussed above. We will call such devices "gates".

    (Discuss Figure 7.2 of [DH])

    Common gates: AND, OR, NOT
    [demo Logg-O file]

    Additional gates: NAND, NOR, XOR
    [demo Logg-O file]

    We will soon see that individual gates can be combined in many ways to build more complex circuits.

    In fact, the choice of gates above is somewhat redundant. For example, if you have NOT gates and AND gates, you do not really need a NAND gate - you could build an equivalent circuit.

    Quite interestingly, all possible circuits can be constructed entirely of NAND gates.

    Yet having all the choices is convenient.

    [demo Logg-O file]


    Building Circuits

    We can wire many switches, gates and lights together to make many more interesting circuits.

  • 1-bit comparator (p. 243 [DH]) [demo Logg-O file]

  • Build NOR without using NOR gate (from Lab 7.2 [DH])

  • Build NOR without using OR gate (DeMorgan's law) [demo Logg-O file]

  • 3-way OR (from Lab 7.2 [DH]) [demo Logg-O file]

  • XOR from scratch (from Lab 7.2 [DH]) [demo Logg-O file]

  • comp150 Class Page
    mhg@cs.luc.edu
    Last modified: 5 February 2002