Digital Logic
Download
Report
Transcript Digital Logic
Digital Logic
Seth Price
Department of Chemical Engineering
New Mexico Tech
Rev. 9/15/14
Digital (Boolean) Logic
• Computer hardware understands “on” and
“off”
• Computer software understands “true” and
“false”
Ideal vs. Reality
• Ideal World
– “High” is +5V DC
– “Low’ is 0V DC or ground
• Reality
–
–
–
–
Real devices produce analog signals
“High” is between 2.2V and 5.0V
“Low” is between 0V and 0.8V
No man’s land between 0.8V and 2.2V!!!!
Logic Gates
• Logic gates are used to make decisions based
on a varying number of inputs
• While all gates exists theoretically, some are
more common than others in actual devices
• Logic Gates are often mounted on an
integrated circuit (IC)
Logic Gates
Logic Examples
• True AND False = False
– AND requires both arguments to be true
• True OR False = True
– OR requires only one argument to be true
• NOT true = False
– NOT inverts input
Problem Statement
• A certain piece of equipment has an emergency stop
button to stop the machine.
Call this input A
• It also has an interlock so that if the access panel is
opened, the machine will stop.
Call this input B
• We want the machine to stop if the button is pressed
OR if the access panel is opened, therefore
X=A+B
Truth Tables
• Now find where X is true, in this equation:
A’B + BC = X
• Instead of trying to reason it out with words:
– Find the possible inputs
– Break down the equation into segments
– Organize into a truth table
Finding Possible Inputs
• A, B, C can each equal 0 or 1. Therefore, possible
inputs are:
• 000
• 001
• 010
• 011
• 100
• 101
• 110
• 111
Truth Table: A’B + BC = X
First, find A’ (NOT A)
A
B
C
A’
0
0
0
1
0
0
1
1
0
1
0
1
0
1
1
1
1
0
0
0
1
0
1
0
1
1
0
0
1
1
1
0
Truth Table: A’B + BC = X
Next, find A’B (NOT A AND B)
A
B
C
A’
A’B
0
0
0
1
0
0
0
1
1
0
0
1
0
1
1
0
1
1
1
1
1
0
0
0
0
1
0
1
0
0
1
1
0
0
0
1
1
1
0
0
Truth Table: A’B + BC = X
Next, find BC (B AND C)
A
B
C
A’
A’B
CB
0
0
0
1
0
0
0
0
1
1
0
0
0
1
0
1
1
0
0
1
1
1
1
1
1
0
0
0
0
0
1
0
1
0
0
0
1
1
0
0
0
0
1
1
1
0
0
1
Truth Table: A’B + BC = X
Putting it all together
A
B
C
A’
A’B
BC
X
0
0
0
1
0
0
0
0
0
1
1
0
0
0
0
1
0
1
1
0
1
0
1
1
1
1
1
1
1
0
0
0
0
0
0
1
0
1
0
0
0
0
1
1
0
0
0
0
0
1
1
1
0
0
1
1
Binary Numbers
• Because computers only understand “1” and “0”,
numbers bigger than one are represented in
binary
• This is a different base. We normally count in
“Base 10”, where computers will talk in binary, or
Base 2.
• Occasionally, you will see “Base 8” (Octal) or
“Base 16” (Hexadecimal) numbers. These
ultimately reduce to a Base 2 system somewhere
in the computer
Converting to Binary
• Think about 2x, and figure out the largest
value of x that can be subtracted from your
number without producing a negative number
• Write ALL the values of x at and below this
number
• Subtract 2x from the number. Repeat the
process for the difference
Converting to Binary
•
•
•
•
•
•
•
•
Example: Convert the base 10 number 47 to binary:
25 = 32, 26 = 64. Choose 25.
47-32 = 15. 24 = 16, 23 = 8. Choose 23.
15-8 = 7. 23 = 8, 22 = 4. Choose 22.
7-4 = 3. 22 = 4, 21 = 2. Choose 21.
3-2 = 1. 21 = 2, 20 = 1. Chose 20.
1-1 = 0
Now put a “1” every time you could divide:
25 24 23 22 2 1 20
1 0 1 1 1 1
•
We can say that 47 is 101111 in binary!
Converting from Binary
• Example: Convert the base 2 number 101101 to base
10:
• There is 1 25 => 32
• There is 0 24
• There is 1 23 => 8
• There is 1 22 => 4
• There is 0 21
• There is 1 20 => 1
• Add these together: 32+8+4+1 = 45
• We can say that 101101 in binary is the decimal 45