CS140 Lecture 02a: The Machinery of ... - Clark University
Transcript of CS140 Lecture 02a: The Machinery of ... - Clark University
![Page 1: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/1.jpg)
1
John Magee22 January 2016
Some material copyright Jones and BartlettThanks to Charles Petzold for some diagrams and Aaron Stevens for some slides.
CS140 Lecture 02a:The Machinery of Computation:
Circuits and Gates
![Page 2: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/2.jpg)
2
Overview/Questions
In your previous CS courses, you’ve probably learned about abstraction and digital representation of information/data. Now we’re ready to ask some tough questions: – What is the machinery of computation?– How does digital computation happen?– Why did we learn about binary numbers?
![Page 3: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/3.jpg)
3
The Machinery of Computation
The Central Processing Unit (CPU) is where computation happens. – The CPU is a microprocessor chip made up of
billions (109) of circuits. – What is a circuit? – What does a circuit do?– How are circuits arranged to do computation?
![Page 4: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/4.jpg)
4
A Plumbing PrimerHow faucets work A faucet is like an gate, which controls the flow of water.
ON: the water flows from the source into the sink.
OFF: the water gets stopped at the gate, and never makes it into the sink.
Wikimedia Commons – User: Chabacano
![Page 5: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/5.jpg)
5
Anatomy of a Flashlight
A flashlight has 3 main components:
– A battery– A bulb– A conductor (e.g. wire)
![Page 6: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/6.jpg)
6
Anatomy of a Flashlight
Here the wires are connected, which forms a sort of circle, called a circuit.
The circuit allows electrons to move from a source to a sink.Along the way, the bulb is lit.
![Page 7: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/7.jpg)
7
Edison’s First Rule of ElectricityYou cannot make electricity flow without a plug.
or, more precisely:
Electric current flows through a closed circuit. If the wire is not connected, the circuit is said to be “open”, and the electrons don’t flow.
of course, electrons can flow through the air (e.g. lightning, arcs, etc.) but let’s keep it simple for now
![Page 8: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/8.jpg)
8
We need a switch…
Wikimedia Commons: Author Funpika
ON: the electrons flows from the source into the sink.
OFF: the electrons gets stopped at the gate, and never makes it into the sink.
Wikimedia Commons: Author Scwerllguy
![Page 9: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/9.jpg)
9
… an electronically controlled switch…
Vacuum Tubes
Wikimedia Commons: Dave Fischer
“a device used to amplify, switch, otherwise modify, or create an electricalsignal by controlling the movement of electronsin a low-pressure space”
![Page 10: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/10.jpg)
10
…a small switch!
Transistors!
a semiconductor device commonly used to amplify or switch electronic signals.
AT&T Bell Labs – 1947
The greatest invention of the 20th century?
Wikimedia Commons – User: Transisto
![Page 11: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/11.jpg)
11
Light Switch CircuitsWe will now consider several examples to demonstrate some techniques for wiring circuits with light switches.
This link brings up a great animated/interactive version, but I’ve reproduced “still” pictures on the following slides.http://www.charlespetzold.com/blog/2007/09/LogicalSwitches.xamlhttp://www.charlespetzold.com/blog/2007/09/ThreeWaySwitch.xaml
![Page 12: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/12.jpg)
12
Switches in SeriesConsider this arrangement, called wiring in series.(the light is off)
![Page 13: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/13.jpg)
13
Switches in SeriesNow we close one switch (e.g. connect the wire)(the light is still off)
![Page 14: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/14.jpg)
14
Switches in SeriesNow we close the other switch (e.g. connect the wire)(the light is still off)
![Page 15: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/15.jpg)
15
Switches in SeriesNow we close both switches (e.g. connect the wire)(now the light is on)
![Page 16: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/16.jpg)
16
Switches in Series: Summary
Left Switch Right Switch Light BulbOFF OFF OFFOFF ON OFFON OFF OFFON ON ON
Light is on if and only if both switches were closed (on).
![Page 17: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/17.jpg)
17
Building BlocksThese wiring arrangements are the fundamental building blocks of computer circuitry.
– Each switch has 2 states (on or off)– Each light bulb has 2 states (on or off)
We can abstractly describe switches and bulbs as each having a 1 bit state.
![Page 18: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/18.jpg)
18
Building BlocksGates (not Bill)Simple electric circuits which perform like our light switch examples.
The input values explicitly determine the output values.
We assume the “switch” is controlled by a electronic input rather than a physical switch.
![Page 19: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/19.jpg)
19
Describing Gates and CircuitsWe describe gates and circuits using:
Boolean expressionsUses Boolean algebra, a mathematical notation for expressing two-valued (T/F) logic.
Logic diagramsA graphical representation of a circuit; each gate has its own symbol.
Truth tablesA table showing all possible input value and the associated output values.
![Page 20: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/20.jpg)
20
AND GateThe AND gate accepts two input signals.The output is 1 if and only if both inputs are 1.Otherwise the output is 0.
Figure 4.2 Various representations of an AND gate
Just like wiring in series.
![Page 21: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/21.jpg)
21
Switches in ParallelNow let’s try connecting the switches a little differently. Consider this arrangement, called wiring in parallel.(the light is off)
![Page 22: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/22.jpg)
22
Switches in ParallelNow we close just the top switch.(the light came on!)
![Page 23: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/23.jpg)
23
Switches in ParallelOr we just the bottom switch.(the light is still on!)
![Page 24: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/24.jpg)
24
Switches in ParallelOr we close both switches!(the light is still on!)
![Page 25: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/25.jpg)
25
Switches in Parallel: Summary
Top Switch Bottom Switch Light BulbOFF OFF OFFOFF ON ONON OFF ONON ON ON
Light is on if either switch alone, or both switches together are closed (on).
![Page 26: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/26.jpg)
26
OR GateThe OR gate accepts two input signals.The output is 1 if either input is 1.The output is 0 if both inputs are 0.
Figure 4.3 Various representations of a OR gate
Just like wiring in parallel.
![Page 27: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/27.jpg)
27
A 3-Way SwitchConsider this arrangement, called wiring a 3-way switch.Both switches are to the left (the light is off).
![Page 28: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/28.jpg)
28
A 3-Way SwitchNow we have one switch left, one switch right.(the light is on).
![Page 29: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/29.jpg)
29
A 3-Way SwitchNow we have one switch right, one switch left.(the light came one)
![Page 30: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/30.jpg)
30
A 3-Way SwitchNow we have both switches to the right.(now the light is off again)
![Page 31: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/31.jpg)
31
3 Way Switch: Summary
Left Switch Right Switch Light BulbLEFT LEFT OFFLEFT RIGHT ON
RIGHT LEFT ONRIGHT RIGHT OFF
Light is on if and only if one switch is left and the other switch is right
![Page 32: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/32.jpg)
32
XOR Gate
Figure 4.4 Various representations of an XOR gate
An XOR (eXclusive OR) gate accepts two input signalsWhen the 2 inputs differ, the output is 1
When both inputs are the same, the output is 0
Just like wiring with a 3-way switch.
![Page 33: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/33.jpg)
33
NOT Gate
The NOT gate accepts one input signal (0 or 1).The output is the opposite.
Figure 4.1 Various representations of a NOT gate
A NOT Gate is also called an inverter.
![Page 34: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/34.jpg)
34
Combinational Circuits
Combines some basic gates (AND, OR, XOR, NOT) into a more complex circuit.
– Outputs from one circuit flow into the inputs of another circuit.
– The input values explicitly determine the output values.
![Page 35: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/35.jpg)
35
Combinational CircuitsThree inputs require eight rowsto describe all possible input combinations (23 = 8):
This same circuit using a Boolean expression is (AB + AC)Canonical Representation: AB’C + ABC’ + ABC
![Page 36: CS140 Lecture 02a: The Machinery of ... - Clark University](https://reader034.fdocuments.net/reader034/viewer/2022043021/626c27c078a6f954362eb3bd/html5/thumbnails/36.jpg)
36
Take-Away Points
– Gates control the flow of electric current.– Basic logic gates (AND, OR, XOR, NOT)– Combination gates