Lecture Notes on ``Computational Boolean Algebra`` (PPT Slides)

advertisement
ENGG3190
Logic Synthesis
Computational Boolean Algebra
Winter 2014
S. Areibi
School of Engineering
University of Guelph
Outline
•
•
•
•
•
•
2
Computational Boolean Algebra “Basics”
Shannon Cofactors and Properties
The Boolean Difference Operator
Quantification Operators
Recursive Tautology
URP (Unate Recursive Paradigm)
Computational Boolean Algebra


Computational Boolean Algebra are
algorithmic and computational strategies
for manipulating Boolean Functions and
Circuits.
It is a set of




Data structures,
Techniques and theorems,
Algorithms,
It will help us to simplify and optimize
circuits, repair circuits, prove that they
perform certain tasks.
Co-factors of F()
y + z’ + yz’
xz’
Definition
The cofactor Cxj of a cube C
with respect to a literal xj is
• C if xj and xj do not appear in C
• C\{xj} if xj appears positively in C, i.e. xjC
•  if xj appears negatively in C, i.e. xjC
Example
If C = x1 x4‘ x6
Cx 2 = C
(x2 does not appear in C )
Cx1 = x4‘x6 (x1 appears positively in C)
Cx4 =  (x4 appears negatively in C)
8
Fxi = Positive Co-factor
Fxi’ = Negative Co-factor
Not a proof but a case study
Let xi = 1
F(x1, x2, …, xi=1, ….) = 1.F(xi=1) + 0.F(xi=0) = F(xi=1)
Which is the same!!
The same can be obtained by letting xi=0
Shannon (Boole) Cofactors
The cofactor fa of f by a literal a=xi or a=xi is
fxi (x1, x2, …, xn) = f (x1, …, xi-1, 1, xi+1,…, xn)
fxi (x1, x2, …, xn) = f (x1, …, xi-1, 0, xi+1,…, xn)
The computation of the cofactor is a fundamental operation in Boolean
reasoning!!!!
Example:
F no longer depends on a
f = abc + abc
fa = bc
c
c
b
b
a
a
11
Shannon Cofactor
f  abc  ab c  a b c  a bc
on
off
Don’t care
a
f a  bc  b c
12
Shannon Expansion
Definitions:
f : Bn  B
f  xi f xi  x i f xi
Theorem: F is a cover of f. Then
F  x i Fx i  x i Fx i
is also a cover of f.
We say that f (F) is expanded about xi.
xi is called the splitting variable.
13
Example
F  ab  ac  bc
F  aFa  aFa  a (b  c  bc)  a (bc)
 ab  ac  abc  abc
bc
c
b
a
Cube bc got split into two cubes
c
b
a
14
Generalized Cofactor
•
The generalized cofactor fC of f by a cube C is f with the fixed values indicated
by the literals of C, e.g. if C=xi xj, then xi =1, and xj =0.
•
if C= x1 x4 x6
fC is just the function f restricted to the subspace
where x1 =x6 =1 and x4 =0.
•
As a function,  fC does not depend on x1,x4 or x6 anymore
(However, we still consider fC as a function of all n variables, it just happens to
be independent of x1,x4 and x6).
15
Assume we have a mux with two Inputs (a,b).
Let variable x control the selection Line.
Negative Co-factor
If x = 0, we send a
If x = 1, we send b
F = a.x’ + b.x
x’ . F(x=0) + x . F(x=1)
This is Shannon Expansion!!
Positive Co-factor
F(x=1) = y . F(x=1,y=1) + y’ . F(x=1,y=0)
F(x=0) = y . F(x=0,y=1) + y’ . F(x=0,y=0)
x.y.F(x=1,y=1) + x.y’.F(x=1,y=0) + x’.y.F(x=0,y=1) + x’.y’.F(x=0,y=0)
Notice we have four sub-Boolean Functions when cofactoring around two vars
Shannon Cofactors: Example

F = a.b + a.c + a.b’.c’ + a’






Fa = b + c + b’.c’ (a’ is gone since a=1)
Fa’ = 1 (first three terms dissapear)
F = a.Fa + a’Fa’
Fa = b + c + b’.c’
Decompose F further around b
bFab + b’Fab’ (function of c only)


Fab = 1 + c
Fab’ = c + c’
Recursive?
Binary Recursion Tree
The recursive Shannon expansion corresponds to a
binary recursion tree
f  xf x  x f x
 x( yf xy  y f x y )  x( yf xy  y f x y )
x
Example:
x1
1
x3
0
0
1
(v)
1
1
0
x2
y
1
0
y
0
f xy
1
fx y
f xy
0
fx y
v
Path (v) to node v corresponds to cube c(v)
Example: c(v) = x1 x2‘x3
20
Computational Boolean Algebra



Use of Shannon Cofactors
Properties of Cofactors
Boolean Difference
F
H
G
(Fx)’
We are measuring the sensitivity
of f to small changes in x
Fx xor Fx’
XOR is the ODD Function
Like Additions
f = x’,
df/dx = fx xor fx’
fx=0, fx’=1
df/dx = 0 xor 1 = 1
What makes this function == 1?
We must make y=1,
if you change x  f will change
f = x.y, fx = y and fx’=0,
df/dx = y xor 0 = y
what make this function == 1?
We must make y=0,
Any change on x will change f
f = x+y, fx=1, fx’=y
df/dx = 1 xor y = y’,
f = x xor y, fx= y’, fx’ =y,
df/dx = y xor y’ = 1,
APPLICATIONS?
When does a change in Cin make a change to Cout?
((Cout) Cin =1) = ab + (a + b).1 = ab + (a+b) = a(b+1) + b = a + b
((Cout) Cin =0) = ab
dCout /dCin = Cout (cin =1) xor Cout (cin=0) =
= (a + b)
xor ab
= (a+b)’ ab + (a+b) (ab)’
= a xor b
What does this mean?
When a != b any change cin will cause change in Cout
Computational Boolean Algebra

New Quantification Operators



Existential Quantification
Universal Quantification
A Realistic Application

Application to Logic Network Repair
ALSO CALLED CONSENSUS
OF F wrt Xi
ALSO CALLED the SMOOTHING
OF F wrt Xi
Universal
Quantification
What makes this a 1?
These other inputs make F=1 FOR ALL values of x
What makes this a 1?
There exits a value of ‘x’ that makes F=1 for this input
Pattern of other variables.
Existential
Quantification
Quantify the ‘x’ then quantify the ‘y’
What if we quantify the A Operands?
Independent of A1 A0!!
X+D
0
0
XD
X + C + 0 + XD + 0 = X + D
0
F(a,b) = ab + b’ == a + b’
Note: This is a simple
and Trivial Example!!
What we want?
Values of constants d0,d1,d2,d3 that make Z == 1 For all possible values
of original inputs a, b!!
Universally quantify the variables ‘a’ and ‘b’ out of the Z function, this
function will then depend only on d0,d1,d2,d3 == 1
(a, b) will disappear by cofactors
MUX Eqn
We will first use the above expression of
the MUX written and then substitute:
 a.b for s1 and
 b’ for s0
G = d0(ab)’b’’ + d1 (ab)’b’ +d2 (ab) b’’ + d3 (ab)b’
= d0(ab)’b + d1(ab)’b’ + d2 ab b + 0
= d0 (a’ + b’)b + d1 (a’ + b’)b’ + d2 ab
= d0a’b + d1b’ + d2 ab
If we Calculate Z
So now Z = G xnor F == GF + G’F’
then find Co-factors, this
What I want is to go calculate ** (For all a b Z)
will be complicated!!
= Z ab . Z a’b . Z ab’ . Z a’b’
Is there an easier way!
When a=0,b=0 then Za’b’ = d1 xnor 1 = d1
When a=0,b=1 then Za’b = d0 xnor 0 = d0’
When a=1,b=0 then Zab’ = d1 xnor 1 = d1
When a=1,b=1 then Zab = d2 xnor 1 = d2
The thing that I need to calculate is the universal quantification (FOR ALL ab Z)
(d0,d1,d2,d3) = AND of all cofactors= d0’d1d2 !!
What did we get??
How do we make this a ‘1’??
To make this a 1 (i.e. repair it) we need to make d0=0, d1=1,d2=1, d3=x
0
1
1
x
0
1
1
1
0
1
1
0
Computational Boolean Algebra


Positional Cube Notation (PCN)
Tautology Checking



Recursive Tautology
Concrete data structure
URP (Unate Recursive Paradigm)
Tautology
F  acd  bcd  abd  acd  cd  ac
 ad  bcd  abd  abc
Given a cover F, we want to know if F = 1? NOT EASY !!!
1311
3111
2132
2322
F=
3321
1323
1332
3212
2231
2213
== 1?
53
bc
a’
ab
Is this a minimal representation?
NO
Anding Two Cubes
and getting 00 (void)
means kill the cube
a’
bc
[a b c]
a’ = [10 11 11]
[a b c]
bc = [11 01 01]
EX: f(a,b,c) = a’ + bc + ab  [10 11 11], [11 01 01], [01 01 11]
What if the function I am looking at is too complex?
Break it into two pieces (cofactors) thereby decomposing it into simpler problems!!
Steps
a1
abd
bc’
c1
 [11 01 11 01] (change 01 to 11)
 [01 01 11 01] (nothing!)
 [11 01 10 11] (nothing !)
 Cube Vanishes!!
is unate? Why?
Because you see variable ‘a’ but not a’ you see c’ but not c …
is not unate? Why?
Because you see variable ‘x’ and x’ … but it is unate in variable y!!
Analogy to Continuous Functions?
x1
x2
A Boolean function is called
positive unate in x if the variable
x orginally 0 changes to 1 and
therefore the value of f(…,x,…)
will remain flat or increases from
0 to 1
a
b’c
ac
a
b’c
bc
Why do we care
about this result?
1
1
1
1 1
1
1
1
1
Tautology
Not a Tautology
You can have many rules but
It will be computationally
Expensive to check all of them!!
x
x’
x + x’ = 1
The Binate Select Heuristic
Example Unate and non-unate covers:
a b c d
G = ac+cd
1 - 1 - - 1 0
F = ac+cd+bcd
a
1
-
b
1
c
1
0
1
d
1
0
is unate
is not unate
=> Choose c for splitting!
•
•
The binate variables of a cover are those with both 1’s and 0’s in the
corresponding column.
In the unate recursive paradigm, the BINATE_SELECT heuristic
chooses a (most) binate variable for splitting, which is thus eliminated
from the sub-covers.
66
Heuristic !!
Rules of
Termination
Selection Rule ..
Recursion ..
Generic Tautology Check
Algorithm CHECK_TAUTOLOGY(List_of_Cubes C) {
if(C == )
return FALSE;
if(C == {-...-})return TRUE; // cube with all ‘-’
xi = SELECT_VARIABLE(C)
C0 = COFACTOR(C,^Xi)
if(CHECK_TAUTOLOGY(C0) == FALSE) {
print xi = 0
return FALSE;
}
C1 = COFACTOR(C,Xi)
if(CHECK_TAUTOLOGY(C1) == FALSE) {
print xi = 1
return FALSE;
}
return TRUE;
}
69
when we set a=1
when we set a=0
b [11 01 11]
c [11 11 01]
b’c’[11 10 10]
fourth disappears
Should we Stop?
73
Tautology …
n
Check if a function is always TRUE.
n
Plays an important role in all algorithms for logic optimization.
n
Recursive paradigm
• Expand about a variable.
• If all cofactors are TRUE then function is a tautology.
n
TAUTOLOGY
• The cover has a row of all 1s (Tautology cube).
• The cover depends on one variable only, and there is no column of
0s in that field.
n
NO TAUTOLOGY
• The cover has a column of 0s (A variable that never takes a certain
value).
n
When a cover is the union of two subcovers that depend on
disjoint subsets of variables, then check tautology in both
subcovers.
74
… Tautology
n
Unate heuristics
• If cofactors are unate functions, additional criteria to
•
determine tautology.
Faster decision.
n
A cover is not tautology if it is unate and there is not a
row of all 1’s.
n
If a function is expanded in a unate variable, only one
cofactor needs to be checked for tautology
• Positive unate in variable xi, fxi  fxi’ ; only fxi’ needs to be
•
checked for tautology.
Negative unate in variable xi, fxi  fxi’ ; only fxi needs to be
checked for tautology.
75
Tautology Example
n
n
f = ab+ac+ab’c’ +a’
Select variable a.
• Cofactor w.r.to a’
•
n
Cofactor w.r.to a is:
Select variable b.
• Cofactor w.r. to b’ is:
•
n
• 11 11 11 => Tautology.
• Depends on a single variable, no column of 0’s => Tautology.
Cofactor w.r. to b is: 11 11 11 => Tautology
Function is a TAUTOLOGY.
76
Download