CSC 110 - Intro. to Computing Lecture 5: Boolean Logic, Gates, & Circuits.
-
Upload
stephen-hudson -
Category
Documents
-
view
215 -
download
1
Transcript of CSC 110 - Intro. to Computing Lecture 5: Boolean Logic, Gates, & Circuits.
Announcements
Quiz at end of class on ThursdayCovers 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 goodMost mistakes came from miscopying
numbers or addition mistakesVery few mistakes were due to errors in
algorithm Brief review includes most common
error(s)
Homework Problem #7
Convert 14D16 into octalDon’t know how to convert hex to octal
directly(Harder) Solution: Convert to decimal first
14D16 =
Convert 14D16 to Octal
(Harder) Solution: Convert to decimal first14D16 = 13 * 160 = 13 * 1 = 13
4 * 161 = 4 * 16 = 64 1 * 162 = 1 * 256 = + 256
33310
Convert 14D16 to Octal
(Harder) Solution: Convert to decimal first14D16 = 33310 = 5158
41 5 08 333 8 41 8 5
32 40 0 13 1 5 8 5
Convert 5158 to Hexadecimal
(Easier) Method: Convert to binary first5158 = 101 001 1012
Convert 5
Convert 1
2 1 02 5 2 2 2 1
4 2 01 0 1
02 1 Need to pad wi th 2 0s to make 3 bi ts!
01
Convert 5158 to Hexadecimal
(Easier) Method: Convert to binary first5158 = 2 = 16
11012 = 1 * 20 = 1 * 1 = 1 0 * 21 = 0 * 2 = 0 1 * 22 = 1 * 4 = 4 1 * 23 = 1 * 8 = + 8 1310
10100
1101
Convert 5158 to Hexadecimal
(Easier) Method: Convert to binary first5158 = 2 = 16
11012 = 1 * 20 = 1 * 1 = 1 0 * 21 = 0 * 2 = 0 1 * 22 = 1 * 4 = 4 1 * 23 = 1 * 8 = + 8 1310 = D16
10100
1101
D
Convert 5158 to Hexadecimal
(Easier) Method: Convert to binary first5158 = 2 = 16
01002 = 0 * 20 = 0 * 1 = 0 0 * 21 = 0 * 2 = 0 1 * 22 = 1 * 4 = 4 0 * 23 = 0 * 8 = + 0 410 = 416
10100
1101
4 D
Convert 5158 to Hexadecimal
(Easier) Method: Convert to binary first5158 = 2 = 16
12 = 1 * 20 = 1 * 1 = 1 110 = 116
10100
1101
1 4 D
George Boole
Mathematician from English middle-classLived from 1815 – 1864Started 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 systemWorld 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
operationsYou have been using some of these for years,
howeverWork 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 operationReturns the negation of the input
True when a is false; false when a is true
Written as a
false
true
aa
Boolean Operation: OR
OR takes two values as inputsWritten as Returns true when either value is true
True when either a OR b are true; false otherwise
false falsefalse truetrue falsetrue true
a b a b
a b
Boolean Operation: AND
AND also takes two inputsWritten asReturns true when both values are true
True when a AND b are true; false otherwise
false falsefalse truetrue falsetrue true
a b a b
a b
Boolean Operation: XOR
First slightly unfamiliar idea: XORXOR computes “exclusive or” Written as True when a or b, but not both, is true
false falsefalse truetrue falsetrue true
a b a b
a b
Boolean Operation: NAND
NAND computes NEGATIVE ANDWritten as
Combines notation for AND & NOT
Returns true when either input is not true True if a OR b are false; false otherwise
false falsefalse truetrue falsetrue true
a b a b
a b
Boolean Operation: NOR
Last operation is NEGATIVE ORWritten 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 falsefalse truetrue falsetrue true
a b a b
a b
George Boole: 1 World: 0
Turns out Boolean algebra is VITALBasis 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 termsFor more on truth, see religious studies or
philosophy Use “1” rather than true & “0” for false
0 00 11 01 1
a b a b
Extended Boole’s Algebra
Algebra includes ability to combine inputs and operations functions f(x, y, z) = x2 + y + z3 + 5 f(2, 4, 1) = 22 + 4 + 13 + 5
= 4 + 4 + 1 + 5 = 14
This is true for Boole’s algebra, tooComputers do more than negate bitsWe 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 a
0
1
aa a
Really Complex Circuits
Determine truth table for ( ) ( )a b a b
0 00 11 01 1
a b a b a b ( ) ( )a b a b
Creating Truth Tables
Start truth table by listing all possible inputsFor 1 input, 2 possible values existFor 2 inputs, 4 possible combinationsFor 3 inputs, 8 combinationsFor 4 inputs, 16 combinations For 5 inputs, 32 combinationsFor 10 inputs, 1024 combinationsFor n inputs, 2n combinations
Creating Truth Tables
There is a secret to making the inputs1st input – Alternate one 0 and one 12nd input – Repeat two 0s then two 1s3rd input – Repeat four 0s then four 1s4th 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
0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
a b c0 00 11 01 1
a b01
a
Gate
Piece of hardware which combines electrical signal input(s) to generate an output signalComputer 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 operationsSimilar 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
Drawing Logic Diagrams
Often use results from one gate as input into another gateE.g., use result from in
Show this by connecting wire from first gate’s output to second gate’s input
( ) a b cb c
b
c
a
a
b
c
Drawing Logic Diagrams
Sometimes we have one value used as input for more than 1 gateShow this by drawing a “splitter”E.g. ( ) ( ) a b b c