Professional Documents
Culture Documents
Week9 2
Week9 2
A+A=A, A*A=A
4
Boolean Algebra
To use Boolean algebra, note that
CO= abc+abc+abc+abc
Now,
abc+abc=ab(c+c)=ab.
abc+abc=ac(b+b)=ac
abc+abc=bc(a+a)=bc
We used term abc three times because
abc=abc+abc+abc!
K-map
It is actually more convenient to use
K-map to simplify digital circuits.
K-map is a very mechanical
procedure. Nothing fancy.
It basically uses two rules: A+A=A,
and AB+AB=A.
K-map
K-map
c
ab
0
1
00
01
10
11
CO = ab + ac + bc
K-map rules
Draw the K-map. Remember to make sure that the
adjacent rows/columns differ by only one bit.
According to the truth table, write 1 in the boxes.
Draw a circle around a rectangle with all 1s. The
rectangle must have size (1),2,4,8,16Then, reduce
the terms by writing down the variables whose values
do not change. For example, if there is a rectangle
with two 1s representing abc and abc, you write a
term as ab.
A term may be covered in multiple circles.
The rectangle can wrap-around!
Simplify to the simplest circuits possible. Usually it
means the minimum number of circles, i.e., minimum
number of terms in the equation. The terms should
also contain as few variables as possible.
K-map
F=abc+abc+abc+abc
c
ab
0
1
00
01
10
11
K-map
F=abc+abc+abc+abc
c
ab
0
1
00
01
10
11
F=ab+bc
K-map
F=abc+abc+abc+abc+abc
c
ab
0
1
00
01
10
11
K-map
F=abc+abc+abc+abc+abc
c
ab
0
1
00
01
F=b+ac
10
11
0
K-map
F=abcd+abcd+abcd+abcd+abc
ab
d+abcd
cd
00
01
10
11
00
01 1
11
10
1
1
K-map
F=abcd+abcd+abcd+abcd+abc
ab
d+abcd
cd
00
01
10
11
00
01 1
11
10
F=bd+acd+abc
Selector
s
K-map
F=sab+sab+sab+sab
b
sa
0
1
00
0
01
10
11
K-map
F=sab+sab+sab+sab
b
sa
0
1
00
0
F=sa+ab
01
10
11
Add
And
Or
Sub
ALU
Review
1-bit full adder
32-bit adder
And result
Or
a
b
Or result
Subtraction?
How to implement subtraction?
Subtraction
Using twos complement representation, we
can implement subtraction through addition
The reason is that a negative number -b in
2s complement is actually 2n-b. So if you do
a+2n-b and take only the lower n bits, it
becomes a-b because 2n is a one bit at bit n
(bit indices are 0,1,2,, n-1, n).
What do we need to add to the ALU we have
in order to be able to perform subtraction?
28
29
Subtraction
Notice that every time we want the
ALU to subtract, we set both CarryIn
and Binvert to 1. For add or logical
operations, we want both control
lines to be 0. We can therefore
simplify control of the ALU by
combining the CarryIn and Binvert to
a single control line called Bnegate.
31
Complication
If we only use the sign bit of the adder,
sometimes we will be wrong
For the following example (using 4 bits only), we
have
7ten 6ten
Then we have
Overflow
The problem is that sometimes we
have overflow.
If we have only 4 bits, a number greater
than 7 or a number less than -8 will
cause an overflow because it cannot be
represented in 4 bits.
In the previous example, -7-6=-13,
overflowed.
Overflow Detection
One way to detect overflow is to check whether the sign bit is
consistent with the sign of the inputs when the two inputs are of
the same sign if you added two positive numbers and got a
negative number, something is wrong, and vice versa.
35
Overflow Detection
Lets check the most significant bit more
carefully
38
Overflow Detection
The result shows that we can detect the
overflow by checking if the CarryIn and
CarryOut of the most significant bit are
different
39
Overflow
The sign bit is correct if there is no
overflow
If there is overflow, the sign bit will be
wrong and needs to be inverted
40
41
42
43
44
Final
32-Bit
ALU
47
ALU Symbol
48