Title: Recall '''Numbers in Binary
1Recall ...Numbers in Binary
- Remember
- Binary representations of...
- Symbols
- Images
- Music
- In this lecture
- Further binary representations of data
- Sound
- Instructions
- Binary logic
2Representation of Music
3Representation of Sound
sound waves
paper cone
magnet
voltage wires
coil
4Representation of Sound
5Representing anything in Binary
- Programs/Instructions?
- A program is a sequence of tasks
- each unique task can be represented by a sequence
of bits - seems nearly anything can be represented in
binary... - So, how did we wind up with bits anyway?
6Logic and Logic Circuits
- What is a circuit?
- the complete path of an electric current, or a
collection of electronic elements - We are interested in logic circuits, those whose
output varies depending on their input - Logic circuits emulate the Boolean logic
operators from propositional logic
7Binary for Logic?
- In Propositional Logic we examine the truth of
logical sentences across all possible scenarios. - Sentences consist of
- Variables
- sub-sentences (A, B, C ) which are either true
or false - In computer science, we use
- true 1
- false 0
- Logical Operators
- e.g., NOT, OR, AND, XOR, NAND, NOR
- Example sentence
- X (A AND B) OR C
- We examine the logical outcome of a sentence
through truth table analysis
8Simplest Truth Tablea Single Variable
9Logical AND
10Logical AND on two variables
11Logical Or
- A OR B
- A ? B
- Has two values true if either A or B is true, or
if both A and B are true - false if they are both false.
- Are either of these things true?
- Note both can be true this is not exclusive or
12Logical Not
- Used to invert a meaning
- NOT A as an alternative
- A It is raining
- ?A It is not raining
13XOR- Exclusive Or
- True when either A or B are true, but not both
- So A and NOT B or B and NOT A
- Built from simpler logic
- (A ? ?B) ? (?A ? B)
14Nor and Nand
15Truth Table Analysis
- How do you build a truth table?
- Step 1 Create columns for all the variables in
the sentence - Step 2 Determine the number of rows you need
given the variables in your sentence - Step 3 Define all possible sequences (cases) for
your truth table, starting with all variables
false and ending with all variables true - Step 4 De-construct the logic in the sentence
and fill in your table - What is the truth table for
- X A AND (NOT B)
- X (NOT A) AND (NOT B)
- X (A OR B) AND C
16Logic and Logic Circuits
- What is a circuit?
- the complete path of an electric current, or a
collection of electronic elements - we will consider transistors to be the basic
building blocks of logic computer hardware. - Logic circuits are built from a series of
transistors - What is a transistor?
17Transistors
- A transistor is an electronic device that has
three ends a source, a sink, and a gate - In this type of transistor, when the gate is
- ON, power flows from the source to the sink.
- OFF, power does not flow to the sink
source
gate
sink
18Transistors (like faucets)
- The operation of a transistor could be explained
by making an analogy to faucets. - A faucet has
- An input
- the water company
- source
- An output
- a sink (where water is drained)
- sink
- Flow control
- If the tap knob (gate) is turned
- ON water flows from the source to the sink
- OFF no water flows.
- The state of the tap determines the presence of
water at the sink
19Transistors (like faucets)
- Changing from water to electricity in
transistors - Electricity flows from the source to the sink
with the gate 1 (ON) - Electricity does not flow from the source to the
sink with the gate 0 (OFF)
20Transistors
- The current technology used to build computer
hardware (chips) is called CMOS. - In CMOS we also use another kind of transistor,
distinguished by the little bubble - The bubble means that this transistor works in
the opposite way (it's ON when the gate is OFF
and OFF when the gate is ON).
source
gate
sink
21Building Complicated Circuits with Transistors
Battery
- What on earth does this do?
- If A0 then . . .
- bottom gate is off
- top gate is on
- power flows from the battery, cant go out the
sink, and goes out through Z. Z 1 - If A 1 then
- bottom gate is on
- top gate is off
- power doesnt get to Z from the battery, and any
power left in Z will flow out the sink. Z 0
A
Z
22Building Circuits with Transistors
Battery
A
Z
23Building Circuits with Transistors
Battery
What does this circuit do? -- build a truth
table!
A
B
Z
24Building Circuits with Transistors
Battery
A
B
Z
Looks like a negated AND (NAND) Attach a NOT
circuit to the output of Z and wed get AND
25Building Circuits with Transistors
Battery
A
B
Z
26Logic Gates