Welcome to Computer Organization and Assembly!
Gates and Wires
CS/COE 0447
Jarrett Billingsley
1
Class announcements
go to the software page and download Logisim!
it’s said “logi-sim”, cause it’s a logic simulator not lodge-ism lol
CS447
2
2
What’s electricity?
(a For Fun and Context™ section)
CS447
3
In your orbit
CS447
4
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*
*narrator: that was not true.
protons sit still* while electrons can move around.
– if you had any kind of high school science you know that this is greatly oversimplifying things but HEY it’s a MODEL
4
Opposites attract…
CS447
5
p+
e-
p+
e-
opposite charges attract.
two of the same charge repel.
here’s electricity. here it is.
but protons are kinda stuck in place, so…
– the repulsion of electrons is a very powerful force.
– it’s like a little spring…
– and when you have quintillions of these little springs in one place, you can do some fun stuff
5
Lots of fish electrons in the sea
CS447
6
here’s a solid piece of metal.
the atomic nuclei 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.
important to consider: electrons are physical objects. they have mass and inertia.
– they really do kinda move around in this “bucket brigade” fashion.
6
Two moles is company, three’s a crowd (animated)
CS447
7
if we shove more electrons in…
aaa
noo
packing more electrons in leads to two things:
1. this metal is now negatively charged
2. the electrons are now closer together so they’re less happy
– negative charge: e > p
– positive charge: e < p
- neutral charge: e = p
7
Carousel of unhappiness
CS447
8
and then give them a (difficult) way out
and then have something which will squeeze them back together again (a voltage source)
well now you have electricity.
wire
if we shove electrons down a wire…
wire
we'd like to get off mister bones wild ride
- a battery uses an electrochemical reaction to squeeze electrons together
- but there are many ways to do that.
8
Watch em go
CS447
9
voltage (V, volts) measures relative electron unhappiness.
current (A, amps) measures how many electrons are moving past a point per second.
low
high
and that's electricity.
there is a difference of unhappiness between these two places. that's voltage.
- resistance (Ω, ohms) measures how "difficult" it is for electrons of different unhappinesses to move from the less happy place to the more happy place
- power (W, watts, = V*A) measures how much "effort" something takes. since it's the product of volts and amps, you can get high power with high voltage and low current, or vice versa. (or high both. both works too.)
- you can also think of resistance as "how much power is wasted as heat to just move the electrons through this material"
- the higher the current, the more power is wasted. so low voltage, high power stuff needs THICK wires. long-distance power transfer is done with extremely high voltage (on the order of 100KV~1MV) so we can keep the wires a reasonable size.
- then there's capacitance (F, farads) and inductance (H, henries)…
- stationary electrons generate a static electric field. this is capacitance.
- moving electrons generate a magnetic field, which then re-interacts with the electrons. this is inductance.
- an insulator is a crappy wire. a resistor is a long wire. a capacitor is a broken wire. an inductor is a loopy wire. a transformer is two inductors who are very close friends.
9
How ICs are made
(another For Fun and Context™ section)
10
CS447
How ICs (integrated circuits) are made
silicon is purified and grown into a monolithic crystal (extremely expensive)
this is sliced thinly to make wafers
gooey caramel is put between them to make stroopwafel
a series of complicated photochemical processes do things like:
change its electrical properties
make wires to connect things
make inert insulating layers
11
CS447
- silicon is a semiconductor – it's somewhere between conductor and insulator.
- it can be "nudged" towards one or the other by either changing it physically (stuffing boron or phosphorous atoms in between the silicon ones) or by applying electrical fields/currents
- it's this property that lets us build switches with zero moving parts
11
How ICs (integrated circuits) are made
many ICs are printed on one wafer
the wafers are diced (chopped up)
the ICs are tested
the ICs are mounted in a package ->
they’re tested again
then they’re ready to sell
12
CS447
– yes, they print rectangular chips on a round wafer. yes, this means there are partial chips on the edges.
– they just recycle the silicon into the next crystal.
– “then why not grow a rectangular crystal?” cause it’s way harder than growing a round one!
12
Manufacturing yield
ICs are tiny and complex
silicon crystals can have defects
a tiny speck of dust during production can ruin an entire chip
the yield is the percentage of usable chips
bigger chips have smaller yields: more opportunities for mistakes!
the size of the silicon is the biggest factor in the price of an IC
huge ICs (several cm on each side!), such as very high-resolution camera sensors, can cost thousands of dollars!
the tiniest ICs are like… the size of a grain of sand and cost cents
manufacturers can also bin resulting chips
bug-free ones can be sold as Core i7s for lotsa money
slightly malformed ones can be sold as Core i5s and i3s
and the ones they sweep off the floor are the Celerons
13
CS447
13
The fundamental unit: Transistors
a transistor is an electrically-controlled switch
the input, output, and control are all single bits
the bits are represented as voltages (maybe 3.3V = 1, 0V = 0)
CS447
14
it connects its input to its output if control is a 1.
input
output
control
now just put 3 billion of them together! who said EE was hard?
this one connects its input to its output if control is a 0.
input
output
control
– ;))))))))))))))))))))
14
Infinite diversity… in infinite combinations (animated)
from these switches, we build… everything.
CS447
15
1
0
A
Y
1
0
0
1
when A = 1, the top switch is open and the bottom switch is closed, so Y = 0.
when A = 0, the top switch is closed and the bottom switch is open, so Y = 1.
what boolean function is this?
– it’s a boolean NOT!
15
Schematics
Okay, start studying here!
CS447
16
From writing to drawing
a schematic is a graphical way to represent systems.
CS447
17
for example, flowcharts are a schematic way of describing an algorithm or program.
but schematics and text are equal in descriptive power. so, we’re not just playing around when we learn this stuff.
“real” hardware design is done with HDLs – hardware description languages.
– maybe you’ve programmed schematically before, if you used Scratch or something similar!
– text and graphics have their own advantages and disadvantages, and sometimes it’s best to use a combination of both
– a graphical description of a system is often easier to understand at a glance
– graphics are two- or three-dimensional; text is one-dimensional
– text can be a lot more terse for small or repetitive tasks
– text is easier to work with for people with visual disabilities
17
Go with the flow
rather than showing a sequence of steps, circuit schematics show how data flows between components.
CS447
18
0001
A
0101
B
+
components can produce values…
components can consume values…
and components can do both.
the connections between them are the wires – they connect the producers to the consumers.
– the wires do not have arrows on them because there is no implied directionality.
– data flows from the producers to the consumers because it must.
– also, the direction of the data flowing through the wires can change over time.
– inputs tend to be on the left, and outputs tend to be on the right. that way, data flows left-to-right through the circuit.
– tend to be. it’s just a convention, and we can break that convention.
– here we have LEDs whose inputs are on the bottom.
18
Everything happens so much
there is no implied “order” when you make a circuit schematic.
everything in the circuit happens simultaneously.*
CS447
19
+
+
+
+
if I have 4 adder components next to each other, then I am doing 4 additions in parallel – at the same time.
this is likely a totally different way of thinking than you are used to.
unless you’ve been doing a lot of multithreaded programming which seems unlikely
next week we’ll look at sequential circuits, which can make things change over time.
* ok yeah there’s no such thing as “simultaneously,” everything takes time, so there is some concept of order.
– but everything in the circuit is Doing Its Thing all the time, in parallel. this is totally different from a flowchart.
19
Gates
CS447
20
Gates
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.
CS447
21
this little bubble means “NOT”
A
Y
A is the input
Y is the output
A
Y
without the bubble you get a… nothing gate?
well, it’s a “buffer” and it’s used in the Real World but we won’t need it
– why do we use Y?? Y, indeed…. ;))))))))))))))))
– in the real world, buffers are used to delay signals by a tiny fraction of a second or to amplify weak signals
21
AND, OR, and… XOR?
we know about AND and OR, but what’s XOR?
CS447
22
A
Y
B
AND gate
A
Y
B
OR gate
A
Y
B
XOR gate
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
eXclusive OR means “one or the other, but NOT BOTH.”
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
– in most programming languages, XOR is written A^B
– that is NOT “to the power of”, it’s exclusive OR.
– as far as I know, only calculators use ^ to mean exponents.
22
Bubbles and Legs
very often you want to NOT one (or more) inputs to a gate
CS447
23
but drawing the NOT gate gets tiring
so we can use this as shorthand.
you can also have more than 2 inputs to a gate.
this does “A & B & C” or, more tersely, ABC
– Logisim lets you do these things too.
23
If you give an electrical engineer a NAND gate…
if you stick a NOT gate after an AND gate, you get a NAND gate
CS447
24
this kind of gate has a cool property: it’s universal
that means you can make any boolean function with NAND gates
~A = A NAND A
A & B = ~(A NAND B)
etc… (no you do not have to remember these)
you can build an entire computer with NANDs
digital logic courses use them cause NAND gate chips are cheap
but in Logisim, we have infinite gates for free 😀
– there are also NOR gates and XNOR gates, and you can guess what they are.
– there are some low-level reasons why NAND is preferred in some cases, but all the literature I can find seems to say that modern circuit design just uses “whatever is needed” in most cases
– the hardware designers are likely working a few levels of abstraction above “picking individual gates” in most cases anyway
24
Inputs, Outputs, and Wires (in Logisim)
CS447
25
Logisim’s Inputs and Outputs
to interact with our schematics, Logisim gives us these.
CS447
26
0
this little dot is the pin that you can attach wires to.
Inputs have square corners.
x
Outputs are round, or have rounded corners.
you can use the hand tool 👆 to change their value to interact with your circuit.
do not confuse inputs and outputs! they have totally different purposes.
they show a value that you give them. (this one isn’t being given a value, so it shows x.)
– it’s just a really really common mistake so I have to mention it
26
Other kinds of inputs and outputs
some really common ones I’ll use in examples and such:
CS447
27
a button is an input that normally produces 0, but produces a 1 when you push 👆 it.
an LED (light-emitting diode) is an output that is normally dark, but lights up when you give it a 1.
–
probes kinda look like outputs, but they’re more like a “debug print” for inspecting values.
they can display their value in different bases.
13
d
27
What’s a wire?
say you wanna do AB + C i.e. (A & B) | C
CS447
28
A
B
C
so we need an AND gate…
and an OR gate…
and then hook them together like this.
wires transport values from producers to consumers. this happens “instantly.”
– nothing actually happens instantly in real life. but this is schematic land!
28
Logisim’s wire colors
Logisim colors wires according to their kind and state.
CS447
29
green wires are 1-bit.
1
0
blue wires are carrying X.
X is weird. it’s neither 1 nor 0. blue is bad. avoid these.
red wires mean “error.”
you have a bug.
orange wires mean a size mismatch.
you have… a different bug.
1
8
– black wires are multi-bit wires, which we won’t talk about until next time.
– blue is actually really useful in some cases, but not actually needed for anything we’ll talk about in this course.
– it’s tied to that concept of “wires where the direction can change over time”…
– it’s a way for multiple producers to share one wire, which is normally a Bad Thing that causes red wires.
– grey wires are unconnected to anything… just delete em.
29
What causes red error wires?
very often, it’s this.
CS447
30
you cannot connect two outputs together with a wire.
what if one gate outputs 1 and the other outputs 0?
IRL this would cause the value to be “indeterminate.”
or your gates would blow up
another really common possibility: you didn’t hook anything up to one or more of a component’s inputs.
– you can’t have two producers producing different values onto the same wire.
– unfortunately, Logisim doesn’t simulate the release of Magic Smoke
– what does it mean to AND nothing with nothing?
30
But this is totally OK
you can connect one wire to as many inputs as you want.
CS447
31
the little circle means these wires are connected together.
this way one producer can send its value to any number of consumers.
they all “see” the same value at the same time.
Tunnel time
a tunnel is a named wire; it lets you connect things long-distance.
CS447
32
one
one
the name of the tunnel is what’s important.
any tunnels of the same name are “virtually” connected.
you can have as many copies of the tunnel as you like.
one
tunnels are your main way to avoid spaghetti circuits. use them!
– learn to copy and paste things without right-clicking. it saves a lot of time.
32
What is real?
do Logisim’s components represent real-world objects?
some of them, sure.
but schematics are an abstraction, like programming languages.
e.g. tunnels are a convenient way to tidy up your circuit, but you can’t magically teleport signals across space in real life.
radio communication is not magic and requires a lot of stuff to make it happen IRL
real circuit design software translates these high-level abstractions into real, buildable circuits for you, in much the same way that HLL compilers translate stuff into assembly/machine code.
CS447
33
33
/docProps/thumbnail.jpeg