Presentation is loading. Please wait.

Presentation is loading. Please wait.

IB Computer Science Computer Organization

Similar presentations


Presentation on theme: "IB Computer Science Computer Organization"— Presentation transcript:

1 IB Computer Science Computer Organization
Part 4 – Digital Logic, Logic Gates, and Boolean Expressions

2 What the IB curriculum says…

3 Boolean Algebra

4 Boolean Algebra A variant of algebra where values can only be
TRUE (1) or FALSE (0) Core operators are not addition, multiplication, etc. Instead we use AND, OR, and NOT. Others covered are NAND, NOR, and XOR. Others exist, but aren’t covered on the IB test.

5 Boolean Notation Variables are what you’re used to: X, Y, A, B, etc.
Values can only be 0 or 1 (or True/False) Core functions notation: NOT = A’ (A prime) – sometimes shown as 𝐴 AND looks like multiplication: AB, or A·B, or sometimes A˄B OR looks like addition: A+B, or sometimes A˅B Let’s look at the details for each one…

6 NOT operator NOT just means the opposite Notation reminder: A’
Since the only values are 0 and 1: 0’ = 1 1’ = 0 So if A = 0, A’ = 1, and if B = 1, B’ = 0 A TRUTH TABLE for NOT is here: In circuit design, we use a NOT gate, also called and inverter (the circle means flip or invert): So this means we can trace through a circuit… A A’ 1

7 AND operator AB AND usually has multiple inputs
Notation reminder: AB, or A·B, or A˄B Output is TRUE (1) only if both inputs are TRUE (1) AB = 1 only if A=1 and B=1 The TRUTH TABLE is: The circuit symbol is: A B A B AB 1 AB

8 OR operator A+B OR usually has multiple inputs
Notation reminder: A + B, or sometimes A˅B Output is TRUE (1) if either or both inputs are TRUE (1) AB = 1 if A=1 OR B=1 (or both =1) The TRUTH TABLE is: The circuit symbol is: A B A B A+B 1 A+B

9 IB Test Specifics On the IB Test, you don’t have to remember the symbols for these, but you should learn them anyways for college Just remember the types of logic AND OR NOT Coming later… NAND NOR XOR And draw them as: AND

10 Boolean Expressions

11 Boolean Expressions …like algebraic expressions in some ways. We use them to define the result of processing inputs with logic gates Parenthesis can be used to define precedence The priority for precedence is: Work expressions inside parenthesis first NOT AND OR

12 Boolean expression examples
Example 1: If I did my homework (A) AND didn't play video games(B represents playing video games), then I get ice cream for dessert. AB' represents whether I get ice cream AB’ take the opposite of B first, then AND with A Example 2: If I did my homework (B) AND fed the dog (C), OR I babysat my sister (A), then I can watch Daredevil on Netflix. A + BC represents whether I can watch Netflix A+BC take AND of BC first, then OR with A

13 More practice, the other way
Write on paper, the equations of: Y=?? X=?? Draw a diagram using all three types of symbols, and have your partner solve it by writing the equation

14 Example 1: Solving an equation for a specific set of inputs
For the equation: (A+B)’ + CD(E+FG’) Solve where A=1, B=0, C=1, D=1, E=0, F=1, and G=0 What does the above expression result in? Note you can show the result in: Words A TRUTH TABLE A Boolean Expression as above A Circuit diagram These are all equivalent solutions, just different ways to look at it Let’s create a TRUTH TABLE, and a Circuit for the above We’ll work this one together on the Whiteboard… TURN OFF YOUR MONITORS, DON’T LOOK AHEAD IN THE SLIDES

15 Whiteboard:(A+B)’ + CD(E+FG’) Solve where A=1, B=0, C=1, D=1, E=0, F=1, and G=0
Truth Table (add columns for the expression parts) Circuit diagram (work from inside out, and down) A B C D E F G G' FG' etc 1

16 Example 1 solution for review
(A+B)’ + CD(E+FG’) A TRUTH TABLE if A=1, B=0, C=1, D=1, E=0, F=1, and G=0 Circuit Diagram A B C D E F G A+B (A+B)’ G’ FG’ (E+FG’) CD CD(E+FG’) (A+B)’ + CD(E+FG’) 1 You can fill out all of the other combinations too, but that’s a lot of work!

17 Example 2 A car has 3 sensors Create:
K is TRUE if the key is in the ignition D is TRUE if the door is open L is TRUE if the lights are on Output Buzzer B should be true if: The lights are on when the key is not in the ignition, or when the door is open and the key is in the ignition Create: A Boolean expression A FULL truth table showing all 8 combinations of inputs (0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0), etc. A circuit diagram using logic gates TURN OFF YOUR MONITORS AGAIN. DON’T LOOK AT THE NEXT SLIDE. IT’S THERE FOR REVIEW WHEN YOU'RE RESTUDYING THIS Work with a partner or two

18 Example 2 solution for review
LK’ + DK = B L K D B 1

19 Practice tools for logic gates
In the Unit 2 folder on the Google drive, open the Logic Circuit folder and install Cedar Logic Simulator (CedarLSSetup.exe) Use it to drag and drop gates, connect them, and test out how they work. Focus on the top 3 categories of gates: Basic Gates (AND, OR, and later NAND, NOR, XOR) Invert and Connect (INVERTER = NOT, From and To with the Oscilloscope feature) Input and Output (On/Off Switches, Square Wave, LED for output) Use View, OScope to use the Oscilloscope feature with square waves Requires Using the To block to measure something on the scope Double click the To block to relabel it Double click the Square Wave block to change its frequency

20 Cedar Logic Sim (AND gate)
We’ll build this together so you can become familiar with the tool

21 Exercise: Build Ex 2 in Cedar
3 Inputs: Lights, Key, Door (Connect to on/off switches) One Output: B for Buzzer (Connect to an LED) Add in and connect up the gates Test it out by flipping the switches to see if the LED comes on when appropriate (simulates the buzzer going off)

22 Example 3 Convert this circuit diagram to a Boolean expression
Create and analyze this in Cedar Create a full TRUTH TABLE showing X for all 8 input combos Also, if A=1, B=1 and C = 0, what is X? TURN OFF YOUR MONITORS AGAIN. DON’T LOOK AT THE NEXT SLIDE. IT’S THERE FOR LATER REVIEW

23 Example 3 solution for review
If A=1, B=1 and C = 0, what is X? Working through: AB=1 B’C = 0 (B’C)’=1 AB+(B’C)’ = 1 (AB+(B’C)’)’ = 0 A B C X 1

24 Simplifying Expressions
If Q = (A’ + B)’C + AC’ Then we have this TRUTH TABLE Looking at the table, we see that Q is 1 when A is 1, except if B AND C are both 1 Thus, we can simplify to: Q=A(BC)’ What do the circuits look like? Which is simpler? Which would cost less to implement using gates? A B C Q 1

25 Other ways to simplify The following are the basic Boolean theorems. They are used to simplify boolean expressions. You'll cover these in detail in college. Idempotent Law A * A = A A + A = A Associative Law (A * B) * C = A * (B * C) (A + B) + C = A + (B + C) Commutative Law A * B = B * A A + B = B + A Distributive Law A * (B + C) = A * B + A * C A + (B * C) = (A + B) * (A + C) Identity Law A * 0 = 0     A * 1 = A A + 1 = 1     A + 0 = A Complement Law A * A' = 0 A + A' = 1 Involution Law (A')' = A DeMorgan's Law (A * B)' = A' + B' (A + B)' = A' * B'

26 One Simplification Example
Simplify: C + (BC)': Expression Rule(s) Used C + (BC)' Original Expression C + (B' + C') DeMorgan's Law (BC)' = B' + C'. (C + C') + B' Commutative, Associative Laws. True + B' Complement Law. True Identity Law. Lots of examples online to see more: search for Boolean Expression Simplification

27 NAND and NOR gates

28 NAND and NOR are special
NAND is just the inversion of AND NOR is just the inversion or OR The electronics (silicon chip design) is typically faster than AND and OR, and cheaper to build (less transistors) Interestingly, any circuit can be built using just NAND and NOR gates

29 NAND gates: X AND Y, Inverted
XY (XY)’ 1 NAND = (XY)’ Symbol and TT: Where the dot means take the opposite of AND If the inputs are X and Y, then the output is (XY)’ Looking at the TT: the output is the same as: X’ + Y’ X Y X’ Y’ X’+Y’ (XY)’ 1

30 NOR gates: X or Y, inverted
X+Y (X+Y)’ 1 NOR = (X+Y)’ Symbol and TT: Where the dot means take the opposite of OR If the inputs are X and Y, then the output is (X+Y)’ Looking at the TT: the output is the same as: X’Y’ X Y X’ Y’ X’Y’ (X+Y)’ 1

31 Alternative/equivalent gates
As we saw above from the Truth Tables: NAND = (XY)’ = X’ + Y’ NOR = (X + Y)’ = X’Y’ AND = XY = (X’ + Y’)’ OR = X + Y = (X’Y’)’

32 AND/OR, NAND/NOR equivalency
Many expressions are written like: AB+CD - a Sum of Products, or SOP (A+B)(C+D) - a Product of Sums, or POS Which yielded circuits using AND and OR gates We’ve said these gates are more expensive and slower than NAND and NOR gates

33 AND/OR, NAND/NOR equivalency
But we can also use NAND and NOR gates For a Sum of Products (SOP), we can just use NAND gates Replace with Because: NAND = (XY)’ = X’ + Y’ The negatives (NOTs) cancel, Leaving AND / OR combo: =

34 AND/OR, NAND/NOR equivalency
Similarly for Product of Sums, or POS, we can just use NOR gates Because: NOR= (X + Y)’ = X’Y’ Replace with The negatives (NOTs) cancel, Leaving OR / AND combo: =

35 AND/OR, NAND/NOR equivalency
Summary If you have an SOP expression F = AB+A’C+B’D you can use AND / OR gates, or JUST NAND gates If you have a POS expression F = (A+B’)(C’+D) you can use OR / AND gates, or JUST NOR gates Also use inverters (NOTs) when needed

36 NAND Examples for SOP

37 NOR examples for POS

38 Exclusive OR (XOR)

39 XOR operator XOR is TRUE if either input is TRUE, but NOT BOTH INPUTS
Notation: A B Output is TRUE (1) only if one input is TRUE (1) A B = 1 only if A=1 OR B=1 The TRUTH TABLE is: The circuit symbol is: A B XOR 1

40 XOR Example Create a truth table for A XOR (B OR C) Solution:
Fill out the ABC values (000, 001, 010, 011, 100, 101, etc.) Do B OR C first – the stuff in parenthesis Now do column A XOR'd with column (B OR C) Answer is True(1) only if one or the other column is 1 (but not both) A B C (B OR C) A XOR (B OR C) 1

41 Summary of Gates Venn diagrams overlap with Math, Logic, Reason, TOK
𝐴 is same as A’ i.e., NOT

42 Boolean Algebra Theorems (for reference, not on tests)
Idempotent Law A * A = A A + A = A Associative Law (A * B) * C = A * (B * C) (A + B) + C = A + (B + C) Commutative Law A * B = B * A A + B = B + A Distributive Law A * (B + C) = A * B + A * C A + (B * C) = (A + B) * (A + C) Identity Law A * 0 = 0     A * 1 = A A + 1 = 1     A + 0 = A Complement Law A * ~A = 0 A + ~A = 1 Involution Law ~(~A) = A DeMorgan's Law ~(A * B) = ~A + ~B ~(A + B) = ~A * ~B You can use these to simplify expressions manually. In college, you’ll do this, along with something called Karnaugh maps (K Maps)


Download ppt "IB Computer Science Computer Organization"

Similar presentations


Ads by Google