logic basics
play

Logic Basics Lus Oliveira Original slides by: Jarrett Billingsley - PowerPoint PPT Presentation

#C CS 0447 Introduction to Computer Programming Logic Basics Lus Oliveira Original slides by: Jarrett Billingsley Modified with bits from: Bruce Childers, David Wilkinson Fall 2020 What's electric icity? (E (EE-ish sec ection) 2 In


  1. #C CS 0447 Introduction to Computer Programming Logic Basics Luís Oliveira Original slides by: Jarrett Billingsley Modified with bits from: Bruce Childers, David Wilkinson Fall 2020

  2. What's electric icity? (E (EE-ish sec ection) 2

  3. In In your orb rbit here's an electron. it has here's a proton. it has a negative charge a positive charge e - it kinda goes p + around the proton in an orbit* protons sit still while electrons can move around *it actually doesn’t… it’s way more complex than that! Waves, teleportation and other black magic! 3

  4. Opposites att ttract … p + e - two of the same charge repel here's electricity. opposite charges here it is attract e - p + but protons are kinda stuck, so … 4

  5. Lots ts of f fis fish ele lectrons in in th the sea here's a solid piece of metal the atoms are in a fixed structure but some of the electrons are free to move around right now, the charges are balanced: same number of positive and negative let's knock it out of whack 5

  6. Two mole les is is company, th three's 's a cro rowd let's shove more electrons in packing more electrons in leads to two things: 1. this metal is now negatively charged 2. the electrons are now closer together meaning they're less happy noo aaa 6

  7. Caro rousel of f unhappiness if we shove some down a wire wire and then give them a we'd like to get off (difficult) way out mister bones wild ride and then have something which will squeeze them back together again well now you have electricity 7

  8. Watch em em go go voltage measures current measures how electron unhappiness many electrons per second are moving past a point low low high and that's electricity high 8

  9. Logic ic Basic ics 9

  10. Valv lves (o (or tu tubes) – more fu fun? ● Why is a vacuum tube called like that? ● They are also called thermionic valves (or simply valves) https://en.wikipedia.org/wiki/Vacuum_tube 10

  11. Tra ransis istors common ● a transistor is like a little valve output input There are multiple types of transistors input output output common common input MOSFET BJT Can be used many different ways! 11

  12. Tra ransis istors ● The ones we’ll focus on MOSFET transistors o Metal-Oxide Semiconductor Field-Effect Transistor The positive o Commonly used just as switches (digital electronics) terminal (e.g. 9V) 9V D D G G S S 0V The negative/ground terminal (0V) 12

  13. Tra ransis istors ● Used as an electrically controlled switch o The input is connected to G (Gate) ▪ controls the switch state o The output is D (drain) is connected to S (source) ● The voltages represent bits! (maybe 9V = 1 , 0V = 0 ) D Input G Output S 13

  14. Tra ransis istors ● MOSFETs come in two varieties: OFF OFF ON ON D S G G=0 G G=1 G=0 G=1 This means S D inverted “N” Type “P” Type Work when connected to 0 Work when connected to 1 14

  15. Tra ransis istors – Overly ly sim implifie ied The current must flow!! S D 1 0 G 1 0 G D S “N” Type “P” Type 15

  16. Tra ransis istors Now just put 3 billion of them together! who said EE was hard? 16

  17. Gate tes ● We can combine transistors in interesting ways to make gates ● A gate implements one of the basic boolean logic functions ● Let's start with the simplest: the NOT gate Q is the output A is the input A Q this little bubble means "invert" 17

  18. Tim ime to to bundle up ● if we want to, say, NOT a 32-bit value, we can draw it like: 32 32 ● it's a lot nicer than drawing 32 wires with 32 NOT gates ● Logisim calls these wire bundles o it doesn't draw the slashes and numbers though … 18

  19. NOT with ith MOSFETs A=0 A Q A=1 “P” Type A Q A Q 1 0 0 1 1 0 “N” Type 19

  20. NAND with ith MOSFETs A Q B B A A B Q Q A 0 0 1 0 1 1 1 0 1 B 1 1 0 20

  21. AND with ith MOSFETs A Q B B A A B Q Q A 0 0 0 0 1 0 1 0 0 B 1 1 1 21

  22. NOR with ith MOSFETs A Q B A A B Q B 0 0 1 Q 0 1 0 B A 1 0 0 1 1 0 22

  23. OR with ith MOSFETs A Q B A A B Q B 0 0 0 Q 0 1 1 B A 1 0 1 1 1 1 23

  24. AND, OR, , and … XOR? ● we know about AND and OR, but what's XOR? A A A Q Q Q B B B XOR gate AND gate OR gate A B Q A B Q A B Q e X clusive OR 0 0 0 0 0 0 0 0 0 means "one or 0 1 0 0 1 1 0 1 1 the other, but NOT BOTH." 1 0 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 AB A+B A ⊕ B 24

  25. AND (m (multiple le in inputs) A B C Q ● If you have more than 2 inputs… you can just concatenate: 0 0 0 0 1 0 0 0 A Q’ Q’ 0 1 0 0 Q B 1 1 0 0 C AND gate 0 0 1 0 AND gate 1 0 1 0 0 1 1 0 1 1 1 1 25

  26. AND and/or r OR ● Combining logic is just a matter of A B C Q combining logic gates: 0 0 0 0 ● Look at the truth entries on the truth-table o when Q is “1” 1 0 0 0 ● AND each entry variable 0 1 0 1 ● Then, OR each entry: ABC + ABC 1 1 0 0 ● In English: 0 0 1 0 It’s truth when 1 0 1 0 “A is false” and “B is true” and “C is false” OR 0 1 1 1 “A is false” and “B is true” and “C is true” 1 1 1 0 26

  27. AND and/or OR ABC + ABC A B C Q 0 0 0 0 1 0 0 0 A 0 1 0 1 Q 1 1 0 0 B 0 0 1 0 1 0 1 0 C 0 1 1 1 1 1 1 0 27

  28. If If you giv ive an ele lectrical l engineer a NAND gate … ● if you stick a NOT gate after an AND gate, you get a NAND gate ● this kind of gate has a cool property: it's universal o in other words, you can build an entire computer with NANDs ● but this isn't how real circuits are designed, at least anymore ● digital logic courses use them cause NAND gate chips are cheap ● but in Logisim, we have infinite gates for free :D ● use the kind of gate you need for the situation at hand 28

Recommend


More recommend