Logic From Switches - HWS Department of Mathematics and
Download
Report
Transcript Logic From Switches - HWS Department of Mathematics and
Two Great Ideas Meet:
Logic and Arithmetic
CPSC 120
Principles of Computer Science
September 30, 2012
From Switches to Devices
Brief Version
Recall
our SPST, pushbutton switches
Let's replace the mechanical activation
with electronic control
Switch output can activate other switches!
Coordinate inputs with outputs to define
various devices/logic functions
Package each device and build more
complex circuits using these packages
Conventions Connecting
Logic, Voltage, and Numbers
Truth
TRUE
FALSE
Voltage
Vdd, Vcc, V+, +5V
Vss, GND, 0V
Switch
On
Off
Number
1
0
Note: This is a type of encoding that is
found everywhere in computing!
Logic From Switches
Mechanical switches
Transistor circuit (Inverter)
Truth table for this circuit
Truth Table for Inverter Circuit
Transistor Logic:
It’s Not What You Think
A
B
0
0
0
1
1
0
1
1
Output
What is the truth table of this circuit?
It’s backwards from our usual
expectation!
A
B
Output
0
0
1
0
1
1
0
1
1
1
0
This is an inverted AND circuit!
We will call it a NAND and package it
as a basic logical package or gate.
Question: How do we get a basic
AND gate?
Aside on making transistors
The first transistor
CMOS diagram
A dozen transistors
50 million transistors
A Catalog of the Basic Gates
Second Idea:
Binary Numbers/Arithmetic
We are used to dealing with numbers in decimal,
also known as base 10.
312 = 3 x 102 + 1 X 101 + 2 x 100 (place value)
We can use other bases, such as 2, to also
represent numbers. Base two is also called
binary arithmetic.
10112 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20
10112 = 8
+0
+2
+1
= 1110
This gives us a way to represent numbers using
only 0 and 1 as symbols! Two digits is simpler
than 10 digits!
The Great Idea Now Arrives
By
using transistors, we can create logic
gates to perform logical operations on
inputs such as AND, OR, NOT, etc
By using binary arithmetic, we can
represent numbers using 0/1 values
Therefore, we can perform a numerical
computation provided we know how to…?
(fill in this space)
The Great Idea Now Arrives
By
using transistors, we can create logic
gates to perform logical operations on
inputs such as AND, OR, NOT, etc
By using binary arithmetic, we can
represent numbers using 0/1 values
Therefore, we can perform a numerical
computation provided we know how to…
Make a logic circuit that adds (or
subtracts) using gates! We will call it…an
adder!
Addition Interlude
A typical decimal addition:
312
+ 129
---------441
(Notice we may have to carry between positions)
A typical binary addition:
10110
+ 1101
-----------100011
22 (Here is equivalent decimal form)
+13
---------35
Requirements for our binary
addition circuit
Add two binary digits, called bits, in the right
most column correctly
Determine if an addition of bits produces a carry
going to the next column on left
Also, we need to handle carries from the right
General situation: Correctly add two bits in a
column, taking into account there may be a carry
in from previous column and determine if there is
a carry out bit as well
Lots more needed to create a
modern electronic computer
We have the idea so far for a Calculator, rather
than a modern computer
Doing arithmetic by mechanical/electronics
devices is not the same as programmed control
We need a way to control/automate the actions
of the calculator we are about to invent
Computers deal with characters A-Z as often as
numbers. How do we code those?
Input and output of our computation needs
design as well. Coming attractions!