0% found this document useful (0 votes)
8 views

Lecture 22 Logic - F24

ECE 1004 lecture 22 logic

Uploaded by

eggzactness
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lecture 22 Logic - F24

ECE 1004 lecture 22 logic

Uploaded by

eggzactness
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

ECE 1004 – Lecture 22

Logic Gates
ECE 1004

❖ Today’s lecture:
• Binary Math
• Logic gates and truth tables
• Combinational logic
Read through section 7.4 in Hambley
HW6 due Thursday
Exam 2 is October 30th
Wear a costume for quiz credit!
No quiz today
2
Standard method for negative
numbers
2. 2’s complement
• The most common way to represent a signed binary integer
on a computer is using 2’s complement
• The MSB (left-most bit) is still the sign bit!
• Pros
• It’s fast for a computer to use 2’s complement.
• No special hardware is needed to compute basic
math.
• Cons
• Halves the range of positive numbers that can be
represented in n bits compared to unsigned
How to convert a number to 2’s
complement:
• Positive numbers are not changed.
• Negative numbers are converted in the following
way:
• Flip all the bits (called 1’s complement)
• 0s become 1s
• 1s become 0s
• Add 1 to the flipped bits (called 2’s complement)
• Ignore any “carry out” from most significant bit.
• Overflow is a carry that would require more bits to
store than the number of bits available
Example
• In 8 bits, represent the following numbers:
•1
• 0000 0001
The computer system must be told
• -1
what numbers are “negative” so as
• 1111 1111
to not confuse them with positive
• 127 numbers.
• 0111 1111
• -127
• 1000 0001
Subtracting binary numbers.
• We follow the same basic idea as subtracting
decimals.
• In this case, we negate the subtrahend.
• We negate the subtrahend using 2’s complement.
• Then we can add!

You will see in the future that it is much easier to add


than subtract with computer hardware, which is why
it’s done this way.
Example

1110 0001 Carry bits


33 0010 0001 Minuend
+ -27 + 1110 0101 Subtrahend
6 0000 0110
In-class problems

8
Logic Gates!
Used for all kinds of tasks in digital systems:
• Multiplexers
• Registers
• ALUs
• Memory, etc.

Made up primarily of diodes and transistors


• They act as electronic switches, 0 and 1
Example: A Data Router
To give you an idea: MM74HC138
Example: seven-segment display driver
Logic Gates
• Computers are assembled using logic gates.
• Logic gates are assembled using transistors.
• We will discuss transistors later and so we’ll
cover more about gates later.
• The gates we will discuss today are
memoryless
• Meaning their output is dependent only on the
input to the circuit “at the moment.“
• Usually called “combinational logic”
Logic Inverter: NOT Gate
• The NOT operation is represented with a bar over
the variable.
ഥ is “not A”, or “inverse A”
• A
• If A is 0, then 𝐴ҧ is 1 and vice versa
• Circuits that perform the NOT operation are called
inverters.
• The truth table and circuit symbol are on the next
slide.
• The bubble on the symbol indicates inversion.
NOT Truth Table

NOT Operations:
ഥ =0
• AA

ഥ=𝐴
•A
Aside: A memory cell is made of inverters

Uses two inverters


back-to-back.

The advantage of
doing this is that
noise will prevent the
cell from staying in
the unstable region
The AND Gate
• AND is a logical operation that can operate on at
least two inputs.
• It is represented as AB for inputs A, B.
• AB is read “A and B”
• AND is also called logical multiplication.
• The operation of the AND gate can be seen in the
following truth table.
• The symbol for the AND gate is on the next slide as
well.
AND Truth Table

AND Relations:
• AA = A
• A1 = A
• A0 = 0
• AA = 0
• AB = BA
• A(BC) = (AB)C
3 Input AND Gate
The OR Gate
• OR is a logical operation that can operate on at
least two inputs.
• It is represented as A + B for inputs A, B.
• A + B is read “A or B”
• OR is also called logical addition.
• The operation of the OR gate can be seen in the
following truth table.
• The symbol for the OR gate is on the next slide as
well.
The OR Gate
OR Relations:
• (A + B) + C = A + (B + C) = A + B + C
• A(B + C) = AB + AC
• A+0=A
• A+1=1
ഥ=1
• A+A
• A+A=A
3 Input OR Gate
Using Truth Tables
• You can use truth tables to prove a Boolean
Expression
• You list all possible combinations of inputs
• Then, show the combinations
• The next slide shows the example of associative law
for OR
Additional Gates
• NAND, NOR, XOR Gates
• NAND is just an inverted AND gate
• NOR is just an inverted OR gate
• XOR is the exclusive or
• XOR is a two input logic variables
• XOR is only true when either input is true
• A Buffer is a single input and produces an output with
the same value (for providing output current)
• An Equivalence Gate (aka XNOR) is a high value only
when both inputs are the same value (opposite of XOR)
Symbols
Logic gate
summary
Real-world two-input NAND and its model
Two-input NAND Simplified model

• Both transistors
must be on for
output to be
grounded/low
• (= 0)

• If either transistor
is off, then the
output is high
Building logic gates from switches
• We can build logic gates from voltage-controlled
switches

NAND NOR
+V (HIGH) +V (HIGH)

R R

OUT
OUT

A
If either A or A B If either A
B is low or B is high,
B
(switch open), OUT is low.
OUT is high.
Real-world two-input NOR and its model

If any switch is
on, output is
low
(grounded)

Two-input NOR gate Simplified model

You might also like