Day 22
I. Last Time:
Lab #2 Due!!! Demo Sheet
Lab #3 Posted
Test #2 Next Class

A. Inlining and C++ (Eliminates the overhead of calling function)

B. Multi-Dimensional Arrays - "Mapping" into memory

C. "Addressing" styles

D. stack:
Local / Minimum space (Reuse space)
Large Arguments / Argument Passing
Recursion

E. Test #2 - Topics
Crib Sheet: ONE full side of letter size paper.
Hand Written
My crib sheet
Calculator
More problem solving.
Tougher than test#1 - STUDY!!!!!
You MUST understand whats happening in the machine,
and the register/stack conventions.

II. New Stuff
     A. Boolean Logic/Algebra -
        Developed by George Boole ~1854
        Express Logic/Thought symbolically and manipulate
        with rules as in mathematics (Boolean Algebra)
        (Symbols could represent thought)

Consists of Propositions:
Statements that are either true or false
Propositions are combined into sentences with conjunctions
(Sounds like an english class right?)

     B. Basics of Boolean Algebra:
        OR: disjunction, |,||, v, +
           A binary operation (i.e. works on 2 things)
           A + B:
              Truth Table:
                  A B A+B
                  F F  F
                  F T  T
                  T F  T
                  T T  T
              Common Sense: the answer is true if either part is true

Ex: Robot making a decision: Wants good error,
but must make a decision within a certain time:

if(error<0.001 or time==10 seconds)
stop thinking

        AND: conjunction, &&, wedge, *
           A binary operation
              Truth Table:
                  A B A*B
                  F F  F
                  F T  F
                  T F  F
                  T T  T
              Common Sense: the answer is true only if both parts are true

Example: strcspn:

while(b[j]!=NULL AND a[i]!=b[j])
j++;

        NOT: negation, ~, notch, bar, /, !
           A uniary operation (i.e. works on one thing)
              Truth Table:
                  A   /A
                  F   T
                  T   T
              Common Sense: the answer is the reverse of the "input"

while(not done)

       Misc Others: XOR, NAND, NOR (These can be made by combining the
                                    above - we'll talk about them later)

       Boole found that these simple operations could be combined with
       statements to answer questions:

      Now Let's look at a simple equation:
         A+B*C*/D
      When is this equation true? Well, one way to find out is to
      create a truth table:
         1) If N variables, 2^N values in the truth table (Binary!)
         2) Solve smaller parts of the truth table
      You can also take a known truth table and generate an equation from
      it. We'll make a SOP (Sum-Of-Products) equation first:
         Look at Page B-5.
      Let's look at equation F:
         When is F true? When a=1,b=b,c=1. I.e. A*B*C
      What about an equation for E:
         /A*B*C+A*/B*C+A*B*/C
      Notice that we:
         1) Create a specific 1
         2) Or them together to get a composite function

    C. Boole's Further Discoveries:
          Boole found out that there are some simple laws that can
          be used to simplify and manipulate these logic equations:

          0 = False, 1 = True

          Zero Law:         A*0 = 0
          One Law:          A+1 = 1
          Inverse Laws:     A+/A = 1         A*/A = 0

          Identity Laws:    A+0 = A          A*1 = A
          Commutative Laws: A+B = B+A        A*B = B*A
          Associative Laws: A+(B+C)=(A+B)+C  A*(B*C)=(A*B)*C
          Distributive Laws:
                            A*(B+C)=(A*B)+(A*C) = A*B+A*C
                            A+(B*C)=(A+B)*(A+C)
          Precedence: NOT, AND, OR

          Notice that the precedence and the last four laws are identical to
          the rules that you learned in traditional algebra.

          We also have DeMorgan's Laws for converting from ANDs to ORs:
          /(A*B) = /A+/B
          /(A+B) = /A*/B

          Now, we can use these equations to simplify ugly equations:
              ((A*B)+(A*C)+(B*C))*/(A*B*C)
          = ((A*B)+(A*C)+(B*C))*(/A+/B+/C)                     (DeMorgans)
          = (A*B)*(/A+/B+/C)+(A*C)*(/A+/B+/C)+(B*C)*(/A+/B+/C) (Distribution)
          = (A*B*/A)+(A*B*/B)+(A*B*/C) +
            (A*C*/A)+(A*C*/B)+(A*C*/C) +
            (B*C*/A)+(B*C*/B)+(B*C*/C)
          = (0*B) + (A*0) + (A*B*/C) +                         (Inverse Law)
            (0*C) + (A*C*/B) + (A*0) +
            (B*C*/A) + (0*C) + (B*0)
          = 0+0+(A*B*/C) + 0+(A*C*/B)+0 + (B*C*/A)+0+0         (Zero Law)
          = (A*B*/C)+(A*C*/B)+(B*C*/A)                         (Identity Law)
          = (A*B*/C)+(A*/B*C)+(/A*B*C)                         (Commutative)
          = (/A*B*C)+(A*/B*C)+(A*B*/C)                         (Commutative)
          = /A*B*C+A*/B*C+A*B*/C                               (Precedence)

          Notice that we now have the same SOP expression that we had from
          column E of the table on page B-5.
          (So, we can use these rules for binary manipulation to manipulate
           equations and even convert them to a different form)

           
       Gates & Propagation Delay - 
          Engineers found early on that things called gates could be 
          made from relays/transistors. These gates are physical 
          implementations of the logic operations:
           AND Gate:
           OR Gate:
           NOT Gate:
           XOR Gate:
           Others: NOR, NAND, etc.
          Since these are physical systems, they have a physical arrangement
          which creates specific orders of operations.
          Ex: A*(B+C)
          
          Moreover, these gates have a property called propagation delay.
          This "delay" is the time it takes a change to travel through 
          the gate.  
           Gates are "mechanical" devices it takes time for information 
          to travel through them. This time is called propagation delay
          and is one of the most important factors in desiging computers
          and esp. high speed digital systems. 
          The maximum clock speed is often dependent on this propagation delay.

III. Next Time:
A. QUIZ!
B. Test