CSC Intro. to Computing Lecture 5: Boolean Logic, Gates, & Circuits
Announcements Quiz at end of class on Thursday Covers converting numbers between bases and addition in other bases Homework answers available on web Homework #2 will be next week CSC tutors are now available Hours posted outside Wehle 206 & 208
Homework Review Results were (generally) very good Most mistakes came from miscopying numbers or addition mistakes Very few mistakes were due to errors in algorithm Brief review includes most common error(s)
Homework Problem #7 Convert 14D 16 into octal Don’t know how to convert hex to octal directly (Harder) Solution: Convert to decimal first 14D 16 =
Convert 14D 16 to Octal (Harder) Solution: Convert to decimal first 14D 16 = 13 * 16 0 = 13 * 1 = 13 4 * 16 1 = 4 * 16 = 64 1 * 16 2 = 1 * 256 =
Convert 14D 16 to Octal (Harder) Solution: Convert to decimal first 14D 16 = = 515 8
Convert to Hexadecimal (Easier) Method: Convert to binary first =
Convert to Hexadecimal (Easier) Method: Convert to binary first = Convert 5 Convert 1
Convert to Hexadecimal (Easier) Method: Convert to binary first = 2 = = 1 * 2 0 = 1 * 1 = 1 0 * 2 1 = 0 * 2 = 0 1 * 2 2 = 1 * 4 = 4 1 * 2 3 = 1 * 8 =
Convert to Hexadecimal (Easier) Method: Convert to binary first = 2 = = 1 * 2 0 = 1 * 1 = 1 0 * 2 1 = 0 * 2 = 0 1 * 2 2 = 1 * 4 = 4 1 * 2 3 = 1 * 8 = = D D
Convert to Hexadecimal (Easier) Method: Convert to binary first = 2 = = 0 * 2 0 = 0 * 1 = 0 0 * 2 1 = 0 * 2 = 0 1 * 2 2 = 1 * 4 = 4 0 * 2 3 = 0 * 8 = = D
Convert to Hexadecimal (Easier) Method: Convert to binary first = 2 = = 1 * 2 0 = 1 * 1 = = D
George Boole Mathematician from English middle-class Lived from 1815 – 1864 Started work at age 16 as a teaching assistant Held two assistantships to support family Later opened his own school Reached pinnacle when appointed a Professor Published Mathematical Analysis of Logic in 1847
Mathematical Analysis of Logic Boole’s book proposed new logical system World consisted of only two values Derived other numbers from combinations of these Devised addition, subtraction, and multiplication rules Basis for several areas of academic research World thought work was of little importance Not until 1963 did someone find a use for it…
Boolean System of Logic Also called “Boolean algebra” Initial world consists of two values Think of them as “true” and “false” Also defines several basic Boolean operations You have been using some of these for years, however Work exactly as you have been using them
Truth Table Normal way we present Boolean functions Each table include all possible inputs… Made easier since we only have true & false …and shows each possible result Not as complicated as it sounds Actually, not very complicated at all!
Boolean Negation: NOT NOT is simplest operation Returns the negation of the input True when a is false; false when a is true Written as false true
Boolean Operation: OR OR takes two values as inputs Written as Returns true when either value is true True when either a OR b are true; false otherwise false true false true
Boolean Operation: AND AND also takes two inputs Written as Returns true when both values are true True when a AND b are true; false otherwise false true false true
Boolean Operation: XOR First slightly unfamiliar idea: XOR XOR computes “exclusive or” Written as True when a or b, but not both, is true false true false true
Boolean Operation: NAND NAND computes NEGATIVE AND Written as Combines notation for AND & NOT Returns true when either input is not true True if a OR b are false; false otherwise false true false true
Boolean Operation: NOR Last operation is NEGATIVE OR Written as The negation (NOT) of an OR operation Returns true when both inputs are not true True if a AND b are false; false otherwise false true false true
George Boole: 1World: 0 Turns out Boolean algebra is VITAL Basis for nearly all computer hardware work “Last useful thing by anyone claimed by computer scientists” – a former colleague (hardware engineer)
Boolean Logic in Computers Computers work best with concrete terms For more on truth, see religious studies or philosophy Use “1” rather than true & “0” for false
Extended Boole’s Algebra Algebra includes ability to combine inputs and operations functions f(x, y, z) = x 2 + y + z f(2, 4, 1)= = = 14 This is true for Boole’s algebra, too Computers do more than negate bits We still use truth tables for this work
Circuits Combines results of multiple operations List result of each operation in truth table Compute each new operation step-by-step Consider combining two NOT operations Written 0 1
Even More Complex Circuits Compute Negate a, then compute result AND b
Really Complex Circuits Determine truth table for
More Complex Circuits Consider
Creating Truth Tables Start truth table by listing all possible inputs For 1 input, 2 possible values exist For 2 inputs, 4 possible combinations For 3 inputs, 8 combinations For 4 inputs, 16 combinations For 5 inputs, 32 combinations For 10 inputs, 1024 combinations For n inputs, 2 n combinations
Creating Truth Tables There is a secret to making the inputs 1 st input – Alternate one 0 and one 1 2 nd input – Repeat two 0s then two 1s 3 rd input – Repeat four 0s then four 1s 4 th input – Repeat eight 0s then eight 1s Start with row of all 0s Stop when you reach a row with all 1s
Creating Truth Table Keep going until we reach row with only 1s
Gate Piece of hardware which combines electrical signal input(s) to generate an output signal Computer signals range from 0 – 5 volts 0 – 2 volts is “low” --- in “0” state 2 – 5 volts is “high” and in “1” state 6 gates commonly used today: NOT, OR, AND, XOR, NAND, NOR
Logic Diagrams Gate-centric way of writing Boolean operations Similar to equations from before, but not as math-centric Highlights the electronic nature of gates Shows values coming into and out of each gate as a wire Label the wires for circuit inputs
Logic Diagrams a a b a b
a b a b a b
Drawing Logic Diagrams Often use results from one gate as input into another gate E.g., use result from in Show this by connecting wire from first gate’s output to second gate’s input b c a
a b c Drawing Logic Diagrams Sometimes we have one value used as input for more than 1 gate Show this by drawing a “splitter” E.g.
For next lecture Study for the quiz on number systems on Thursday Finish reading section 4 Be ready to discuss Algebraic Properties of Boolean Logic