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

logic basics
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CS 0447 Introduction to Computer Programming Luís Oliveira

Fall 2020

Logic Basics

Original slides by: Jarrett Billingsley Modified with bits from: Bruce Childers, David Wilkinson

#C

slide-2
SLIDE 2

What's electric icity?

(E (EE-ish sec ection)

2

slide-3
SLIDE 3

3

In In your orb rbit

p+

e-

here's a proton. it has a positive charge here's an electron. it has a negative charge it kinda goes around the proton in an orbit*

*it actually doesn’t… it’s way more complex than that! Waves, teleportation and other black magic!

protons sit still while electrons can move around

slide-4
SLIDE 4

4

Opposites att ttract…

p+ e- p+ e-

  • pposite charges

attract two of the same charge repel here's electricity. here it is but protons are kinda stuck, so…

slide-5
SLIDE 5

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

slide-6
SLIDE 6

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

aaa noo

slide-7
SLIDE 7

7

Caro rousel of f unhappiness

and then give them a (difficult) way out and then have something which will squeeze them back together again well now you have electricity if we shove some down a wire

wire

we'd like to get off mister bones wild ride

slide-8
SLIDE 8

8

Watch em em go go

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

slide-9
SLIDE 9

Logic ic Basic ics

9

slide-10
SLIDE 10
  • Why is a vacuum tube called like that?
  • They are also called thermionic valves (or simply valves)

10

Valv lves (o (or tu tubes) – more fu fun?

https://en.wikipedia.org/wiki/Vacuum_tube

slide-11
SLIDE 11
  • a transistor is like a little valve

11

Tra ransis istors

MOSFET BJT There are multiple types of transistors

common

  • utput

input

  • utput

common input

  • utput

common input

Can be used many different ways!

slide-12
SLIDE 12
  • The ones we’ll focus on MOSFET transistors
  • Metal-Oxide Semiconductor Field-Effect Transistor
  • Commonly used just as switches (digital electronics)

12

Tra ransis istors

D S G 9V D S G 0V

The positive terminal (e.g. 9V) The negative/ground terminal (0V)

slide-13
SLIDE 13
  • Used as an electrically controlled switch
  • The input is connected to G (Gate)

▪ controls the switch state

  • The output is D (drain) is connected to S (source)
  • The voltages represent bits! (maybe 9V = 1, 0V = 0)

13

Tra ransis istors

Input Output D S G

slide-14
SLIDE 14
  • MOSFETs come in two varieties:

14

Tra ransis istors

D S G “N” Type Work when connected to 0 G=1 G=0 ON OFF S D G “P” Type Work when connected to 1

This means inverted

G=0 G=1 ON OFF

slide-15
SLIDE 15

15

Tra ransis istors – Overly ly sim implifie ied

1 D S G 1 S D G “N” Type “P” Type

The current must flow!!

slide-16
SLIDE 16

16

Tra ransis istors

Now just put 3 billion

  • f them together! who

said EE was hard?

slide-17
SLIDE 17
  • 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

17

Gate tes

this little bubble means "invert"

A Q

A is the input Q is the output

slide-18
SLIDE 18
  • if we want to, say, NOT a 32-bit value, we can draw it like:

18

Tim ime to to bundle up

32 32

  • it's a lot nicer than drawing 32 wires with 32 NOT gates
  • Logisim calls these wire bundles
  • it doesn't draw the slashes and numbers though…
slide-19
SLIDE 19

19

NOT with ith MOSFETs

A Q “N” Type “P” Type

A Q

A Q 1 1

A=0

1

A=1

slide-20
SLIDE 20

20

NAND with ith MOSFETs

A Q B

A B Q 1 1 1 1 1 1 1

A A B Q B

slide-21
SLIDE 21

21

AND with ith MOSFETs

A Q B

A B Q 1 1 1 1 1

A A B B Q

slide-22
SLIDE 22

22

NOR with ith MOSFETs

A B Q 1 1 1 1 1

A A B Q B A Q B

slide-23
SLIDE 23

23

OR with ith MOSFETs

A B Q 1 1 1 1 1 1 1

A A B B A Q B Q

slide-24
SLIDE 24
  • we know about AND and OR, but what's XOR?

24

AND, OR, , and… XOR?

A Q B

AND gate

A Q B

OR gate

A Q B

XOR gate

A B Q 1 1 1 1 1 1 A B Q 1 1 1 1 1 1 1

eXclusive OR means "one or the other, but NOT BOTH."

A B Q 1 1 1 1 1

AB A+B A⊕B

slide-25
SLIDE 25
  • If you have more than 2 inputs…

you can just concatenate:

25

AND (m (multiple le in inputs)

A Q’ B

AND gate

Q’ Q C

AND gate

A B C Q 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-26
SLIDE 26

AND and/or r OR

  • Combining logic is just a matter of

combining logic gates:

  • Look at the truth entries on the truth-table
  • when Q is “1”
  • AND each entry variable
  • Then, OR each entry:

ABC + ABC

  • In English:

26

A B C Q 1 1 1 1 1 1 1 1 1 1 1 1 1 1

It’s truth when “A is false” and “B is true” and “C is false” OR “A is false” and “B is true” and “C is true”

slide-27
SLIDE 27

ABC + ABC

27

AND and/or OR

B A Q C

A B C Q 1 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-28
SLIDE 28
  • if you stick a NOT gate after an AND gate, you get a NAND gate

28

If If you giv ive an ele lectrical l engineer a NAND gate…

  • this kind of gate has a cool property: it's universal
  • 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