3-multiv

advertisement
Multi-Valued Logic
Up to now…two-valued synthesis
– Binary variables take only values {0, 1}
Multi-Valued synthesis
– Multi-valued variable Xi can take on values
Pi = {0,…,|Pi|-1} (integers - but no ordering
implied)
– Symbolic variables take values from
symbolic set, e.g. state: {s0,s1,…,sn} or
X: {a,b,c}.
1
Multi-Valued Logic
• Formally: F : P1  Pn  {0,1,*}
(sometimes called an mv-function).
• Problem:
find the minimum (SOP) form for an
incompletely-specified function of this
kind
• Big News:
Nothing (much) changes
2
Example “Truth Table”
• P1={0,1,2}, P2={0,1}
X1
0
0
1
1
2
2
X2
0
1
0
1
0
1

1
1
0
1

1
• Here “2” means the value 2 and not {0,1}
f(0,0) = 1
f(2,1) = 1
f(1,0) = 0
f(2,0) = * unspecified
(don’t cares)
3
MV Function
X3
X2
X1
on
off
Don’t care
4
Terminology
• Vertex:
A point of the space P1 
• Cube:
A set c  c1 
• Containment:
 Pn
 cn , ci  Pi
c  d (c, d cubes) iff ci  d i , i
When c is a vertex, d  c, also say c  d
• Implicant:
Cube c such that for all v c, F(v)  0
5
Terminology
• Onset minterm:
Vertex v such that f(v)  1. If v  (c1, ,cn )
then each ci has exactly one member.
• Prime Implicant:
Implicant c such that there is no implicant d
such that d  c
• Cover of F :
A set of implicants which together
contain every onset minterm of f
6
Terminology
• Prime Cover of F :
A cover, each of whose elements is prime
• Distance of cubes c,d :
n
 c, d    ci  d i   
i 1
• Supercube of c,d :
  c, d   c1  d1 
 cn  d n
Note: All these definitions are exactly as they
7
were in the binary case.
Notation-MV Literals
Definition - A multi-valued literal X ici is a
binary logic function of the form
ci
X i  ( X i   1 )   ( X i
where
k)
 j  ci  Pi
Definition - A cube c  c1  c2    cn can
be written as the product of MV-literals:
cn
c1 c 2
X1 X 2  X n
8
Notation-MV Literals
• If ci=Pi we may omit X iPi from the
Pi
expression (since X i =1)
• Note analogy to two-valued case:
X i{0}  X i
X
X
{1}
i
{0,1}
i
 Xi
1
• Actually, multi-valued notation is superior to
old (binary).
9
Example
Can form rows marked a (b)
as a single mv-cube
implicant
Cube a  {0,2}×{0,1}  X1{ 0,2 }
X1
0
0
1
1
2
2
Cube b  {0,1,2}×{1}  X 2{ 1}
Both a and b are prime implicants
X 1{ 0 } X 2{ 0 ,1 }  X 1{ 0 } is an implicant of F
X2
0
1
0
1
0
1

1
1
0
1

1
a
a
b
a
a
The following are cube covers of F. F2 is a prime cover
F1  X 2{ 1}  X1{ 0 } X 2{ 0 }
F2  X 2{ 1}  X1{ 0,2 }
b
10
b
Positional Notation
Example: cube X 1{A, B} X 2{R}
P1={A,B,C,D}, P2={R,S} (Symbolic)
Cube:
A B C D
1 1 0 0
R S
1 0
• A cube does not depend on variable Xi if it has all 1’s in
the set of columns associated with Xi .
• Each of the columns of a variable is called a part of that
variable. There is one part for each value a variable can
take.
• Extension of Espresso notation
11
Positional Notation
Extension of Espresso notation
(value=0) (value=1)
0
1
1
1
0
0
1
1
2
Example:
c1
c2
c3
c4
c5
X1
11110
01100
01010
00110
00001
X2
00001
00011
00100
01001
11111
X3
11111
01010
11111
11010
10110
12
Positional Notation
5 Cubes
12345
X3
c1
c2
c3
c4
c5
X1
11110
01100
01010
00110
00001
X2
00001
00011
00100
01001
11111
X3
11111
01010
11111
11010
10110
X2
X1
13
Minimization Problem for
Multi-Valued Logic
Given: a cover F of  and a cover D of the don’t-care
set d,
Find: A minimum sum-of-products form for 
Same problem as for two-valued
• Generate primes of (f+d)
• Generate covering table
• Solve the covering table (unate covering problem)
Same algorithms as for two-valued (except for small
details).
14
Applications of Multi-Valued
Logic
Theorem (Hong): minimizing a two-valued (n input)  (m
output) logic function g is equivalent to minimizing a
single binary-output MV-logic function:
f : {0,1}  {0,1}  ...  {0,…,m-1}  {0,1}
Proof( sketch):
Let g = {f0,…,fm-1} be the multiple output function.
Consider the characteristic function f of the multiple
output function, (defined on (n+1) variables with the last
one, y, being multi-valued on {0,1,…,m-1} ) :
m 1
f ( x , y )  1    ( y  i )  fi ( x ) 
i 0
15
Applications of Multi-Valued
Logic
Note: an implicant of g (the multi-output function) is a
cube c in the x-space where each output is turned
on only if fi(c)=1. Any output not turned on means no
information (not offset), since the each output is the
OR of all of its input cubes.
g
X
f1 f2 f3 f4 f5 f6
x-cube
010110
16
Other Applications:
Encoding Problems
Other Applications:
• Input Encoding problem
– bit-grouped PLA structure
• Output encoding problem?
– output phase optimization?
• State encoding problem
– Minimize symbolically to get constraints on a posssible
binary encoding
– solve constraints to derive binary code
– Re-minimize binary problem
– Implement in binary
17
Multi-Valued Minimization
Example
f0  X 1 X 2 X 3  X 1 X 2 X 3  X 1 X 2 X 3  X 1X 2 X 3

g   f1  X 1 X 2 X 3  X 1 X 2 X 3  X 1 X 2 X 3  X 1 X 2 X 3

f2  X 1 X 2 X 3  X 1 X 2 X 3  X 1 X 2 X 3  X 1X 2 X 3
f : {0,1} {0,1} {0,1} {0,1,2}  {0,1}
f : P1  P2  P3  P4  {0,1}
f  X 10 X 20 X 30 X 40  X 10 X 21 X 30 X 40  X 10 X 21 X 31 X 40 
X X X X X X X X X X X X 
1
1
1
2
1
3
0
4
0
1
0
2
0
3
1
4
0
1
0
2
1
3
1
4
X X X X X X X X X X X X 
0
1
1
2
1
3
1
4
1
1
0
2
1
3
1
4
0
1
0
2
0
3
X X X X  X X X X  X1X X X
0
1
0
2
1
3
2
4
0
1
1
2
0
3
2
4
1
2
1
3
2
4
2
4
18
Example - after minimization
Prime and irredundant SOP of f:
f  X 10 X 21 X 31 X 4{0,1}  X 11 X 21 X 31 X 4{0, 2} 
X 10 X 2{0,1} X 30 X 4{0, 2}  X 10 X 20 X 3{0,1} X 4{1, 2} 
X 1{0,1} X 20 X 31 X 41
(five cubes 1+2+3+4+5)
Equivalent to:
f0  1  2  3  X1 X 2 X 3  X1 X 2 X 3  X1 X 3
f1  1  4  5  X 1 X 2 X 3  X 1 X 2  X 2 X 3
f2  2  3  4  X1 X 2 X 3  X1 X 2  X1 X 3
19
Example - after minimization
f0
f1
f2
Note: X 1 X 2 X 3 is not a prime of f0, but X 1 X 2 X 3 X 4{0, 2} is a
prime of f. Similarly for X 1 X 2 X 3 .
20
Shannon Cofactor
Cofactor of cube c with respect to cube d (cd)
if c  d  

cd  
 c1  d1   cn  d n otherwise
Note: di  Pi \ di
Note: this agrees with “standard” cofactor in the case
of two-valued
Hint: check cases on di, ci, e.g. if di=ci=1 (i.e. xi in d and c) , then
(cd)i = ci di = 2 = {0,1}
Rationale: Only care about value of c on subspace given
21
by d. ( d is don’t care)
Shannon Cofactor - Example
Example: space is {0,1}  {0,1,2}
X
0
1
X 2{0, 2}

X 1{ 0 ,1} X 22
 X 10 X 2{0,1, 2}  X 10
Cofactor of cover F  c1    c m
to cube d is
Fd  c1d 
with respect
 cdm
Note: Cofactor of a cover with respect to another
cover is not defined.
22
Shannon Cofactor-Example
F = (f,r) and cube d = X1{0,2}
Co(F,d)
fd
F
d
Consider the generalized cofactor:
Co(F,d) = (fd,d, rd)
f d  X 1{0} X 2{0} X 3{1}  X 1{0} X 2{0} X 3{0}  X 1{2} X 2{1} X 3{1} d
{0 ,1} {0} {1}
{1, 2} {1} {1}
 X1 X 2 X 3  X1 X 2 X 3
Note: We keep all the onset (not ind ) and project the care onset
fd tod. Also, f Ø f d as in the binary case, but df  df d 23
Shannon Cofactor Expansion
Theorem (General Case)
Theorem: Let f be any function and {c1, …, ct} any set of
cubes which partition the input space:
t
i
c
  1 and
i 1
i
c  c j   for i  j
Then
t
f   c i f ci
i 1
24
Shannon Cofactor Expansion
Theorem (General Case)
We immediately have:
f  1 iff f ci  1 for every i, and
t
f   c i ( f ci )
i 1
i.e. most Shannon cofactor results continue to hold.
However, note f
 f , but c f  c f
 
c
 c
 
c
 c
25
Recursive Paradigm:
Multi-Valued Version
Tautology(f )
if f  1 return true;
if f  0 return false;
Choose c1,...,c t such that
c i  c j (don't need c i  c j   for this)
1   i 1 c i
t
for (i  1,...,t)
if (Tautology(fc i )  false)
return false;
return true;
26
Recursive Paradigm: MV version
Still Open:
• Unate leaves (what does unateness mean?)
• Splitting choice (i.e. which { ci })
• Unate Reduction
27
Unateness: Multi-Valued
Definition 1: f is said to be weakly unate in Xi if
there exists some value j, such that changing Xi
from value = j to something else, does not cause f
to decrease.
f ( , X i  j, )  f ( , X i  k , ), k  j
• Analog to unateness in two-valued case set j=0
and get monotone increasing; set j=1 and get
monotone decreasing
In general: detecting unateness is hard (obviously)
Special case: unate cover
28
Weakly-Unate Cover
Definition 2: A cover F= c1 +…+ ct is said to be weakly
unate in Xi iff there is some j such that, for each
cube ck, either:
j  cik
cik  Pi
or
(universal set)
(monotone increasing from
value j in variable Xi)
j (Xi)
c1 01010
c2 00100
. 01000
ct-1 11111
ct 11111
29
Weakly-Unate Cover
Analogy to two-value:
• Rewrite (binary to MV)
X i  X i{0}
X i  X i{1}
2  X i{0,1}
Example
Xi
0
2
Xi
10
 11
0
10
2
11
Here j=1 i.e. monotone
increasing from j=1
(monotone decreasing in Xi )
Xi
1
1
2
Xi
01
 01
11
Here j=0 i.e. monotone
increasing from j=0
(monotone increasing in Xi )
30
Weakly-Unate Cover
Easy to detect:
for each variable X i
vi  Pi (start with all values)
for each cube ck
if cik  Pi (if not all values Pi )
vi  vi \ cik (remove any value in c k )
Unate variables are those for which vi  
(Just looking for a column with all 0’s, except for rows
of all 1’s)
31
Weakly-Unate Cover
1. throw out rows of all 1’s
2. Look for column of all 0’s
c1
c2
.
ct-1
ct
j (Xi)
01010
00100
01000
11111
11111
32
Example
f  X 1{0,1, 2,3, 4} X 2{4} X 3{0,1, 2,3}  X 1{1, 2} X 2{3, 4} X 3{1,3} 
X 1{1,3} X 2{2} X 3{0,1, 2,3, 4}  X 1{2,3} X 2{1, 4} X 3{0,1,3} 
X 1{4} X 2{0,1, 2,3, 4} X 3{0, 2,3}
P1  P2  P3  {0,1,2,3,4}
v1  v2  {0}, v3  {4}
F is weakly-unate in every variable.
c1
c2
c3
c4
c5
X1
11111
01100
01010
00110
00001
X2
00001
00011
00100
01001
11111
X3
11110
01010
11111
11010
10110
33
Application to Tautology
Theorem 1: Let {c1, …, ct} be a cube partition as in
Shannon expansion theorem. Then:
f  1 iff f ck  1 for every k
(1)
Proof: follows two-valued case exactly.
f  c1 f c1  c 2 f c2 
 c t f ct
c i  c j  , i  j
c
i
1
34
Monotone Theorem
Theorem 2: Let f be weakly unate in variable xi from
value j. Then:
(2)
f { j }  f {k } for all k  Pi
Xi
Xi
Analogous to f x  f x for monotone increasing (from 0).
Proof:
We first show that fx {k} is independent of xi . Let {c l } be any
i
l
xi{k}
cover for f . Then {c } is a cover for fx{k} . Each cube c xl {k} is
i
i
either  or has all 1's in the xi part. (When cofactoring by
cube xi{k} , cikl  0  , cikl  1  all 1's, because we add 1's
to all values Pi \ {k} ).
35
Monotone Theorem
Let v be an arbitrary point in the space excluding xi .
Let u  xi{j}v,w  xi{k}v . Since f is weakly unate from j,
f(u)  f(w). By Shannon expansion
pi 1
f   xi{l} fx {l}
l 0
i
so
f (u )  fx { j} (v )  f (w )  fx { k} (v )
i
i
(since fx {k} is independent of xi ). Since v is an arbitrary
i
point, then fx {j}  fx {k}
i
i
36
Weakly Unate Reduction
Theorem
Theorem 3: (unate reduction) f is weakly-unate in Xi, and
the “unate value” is j. Then f = 1 iff f X { j }  1
i
Proof:
(  ) Write
pi 1
f   X i{ k } f X { k }
i
k 0
from (1), f  1 iff fx {k}  1 for every k, and hence f  1 implies fx { j }  1
i
i
(  ) If fx { j }  1, then by (2) fx {k}  fx { j }  1 and hence fx {k}  1,
i
i
i
i
and so f  1 by (1).
37
Weakly Unate Reduction
Theorem
Note this is exactly two-valued theorem:
 A X 

A  1  
  1  B  1
 T B 

except that here we are doing one unate variable at a time.
Also note that
Xi
01101
F  ...
01010
00110
11111
11111
Xi
...
FX { 0 }  ...11111...
i
11111
because xi{ 0 } does not intersect with the first 3 cubes.
38
Tautology for Weakly Unate
Cover
Definition 3: Cover c1 + … + ct is weakly-unate iff it is
weakly-unate in all variables.
Theorem 4 : c1+ …+ct weakly-unate then c1+ …+ct =1
iff cj=1 for some cube j. c j  1 means c j  X 1P1 X nPn
Proof. Follows from reduction theorem.
Thus for weakly unate cover, can tell immediately.
0101 1011 0011
0011 1010 1011  1
1111 1111 1111
0101 1011 0011
0011 1010 1011  1
0101 1011 1001
Vertex 1000 0100 0100 not covered.
39
Reduction in One Step
Form cube c  X1μ1
 Pi
μi  
v i
X nμn where
v i   (i.e.if X i is "binate")
(unate part of variable X i )
f  1 iff fc  1
(Unate reduction. Gets rid of cubes with 0 in any of
{v i } parts)
c exactly as in two-valued algorithm
A X

f  
1201
T B 
A  2202  c  0110
c is cube of unate variables, e.g.
1021
then Ac=0. Hence fc=(T B).
40
Revised Tautology
Tautology(F )
while (F is weakly unate in some variables)
F  Fc
if F  1 return true;
if F  0 return false;
Choose c 1,...,c t (some cube partition of space)
for (i  1,...,t )
if (Tautology(fc i )  false)
return false;
return true;
Left open: how to split?
i.e. how to choose c1, …, ct where ci  cj = , and ci =1.
41
Methods of Splitting
“Split by value”
X
X i{3}
{0}
i
X i{1} X {2}
i
– Gets rid of variable Xi in a single step.
42
Methods of Splitting
“Split by parts”
q, s partition Pi (e.g. q={0,1}, s={2,3}
X iq
X is
f  X iq f X q  X is f X s
i
i
– May get to unate leaves (somewhat) more quickly
– More freedom to choose good partitions -don’t need to entirely
eliminate variable Xi at a node before splitting on Xk.
In practice, “split by parts” is used
43
Choice of Splitting Variable
Cover F = 1 +…+ |F|
Goal: get to weakly unate leaves as fast as possible
Definition 4: Active value of variable Xi:
{ j | (k ) such that j   ik }
(Any value k of Xi with all 1’s in column is not active)
Choose variable with most active values
(Note: all inactive values can be equivalently grouped into
44
one value.)
Choice of Splitting Variable
Tie breaks (|F| is number of cubes)
– Variables i maximizing
|F |
|F |
j 1
j 1
j
j
|
P
\

|

|

 i i  i|
(“Smallest” variable = most 0’s in columns)
– Variables minimizing
 P   
|F |
j
j 1
i
i
(least “2’s”)
45
Choice of Partition
Cover F=c1+…+ ct, variable Xi
• Goal: Like to find partition q, s of Pi such that:
is minimized.
| FX q |  | FX s |
i
i
F
X iq
X is
q not active
s not active
FXq
i
FXs
i
Heuristic:
• m active values in Xi
• q gets first m/2 active
values, s the rest
This reduces the number of
active values on each
side by half
• Hard problem! Use heuristic
• “Fast to compute” more important than quality...
46
Strongly Unate Functions
Weakly-unate good enough for tautology based
algorithms, but…
• F weakly-unate   Fc weakly-unate
Example: F is weakly unate cover.
X1 X2 X3 X3
10 11 11 111
F = 11 10 10 100
11 11 10 010
c = 11 11 10 110
10 11 11 111
Fc = 11 10 11 101
11 11 11 011
Fc is not weakly unate in X3.
(But in this example, fc is!)
(However, this also holds for f
and fc as well
i.e. f can be weakly unate
in a variable but fc may not
be).
47
Strongly Unate Functions
F weakly-unate does not imply every prime of f essential.
Example: f = { p1,p2,p3,p4,p5 }
p1
p2
p3
p4
p5
11111
01100
01010
00110
00001
00001
00011
00100
01001
11111
11110
01010
11111
11010
10110
Weakly unate in all
variables
A column of all 1’s
indicates a value that
is not active.
p1,…, p5 are all primes.
–
–
–
–
–
P1 essential
p2 nonessential
p3 essential
p4 nonessential
p5 essential
5 Cubes
12 3 4 5
48
Strongly Unate Functions
f weakly-unate does not imply f weakly-unate.
00110
11111
00001
f = 01100
11000
10110
10010
01000
00001
11110
00010
11000
10100
10010
00101
00001
01001
10101
11111
11111
11111
All these are primes.
Need stronger condition...
49
Stongly Unate functions
Definition 5: f is strongly-unate in Xi iff there is
some total order
<
on Pi such that, for j<k in Pi
f X { j}  f X {k }
i
i
Thus “increasing” Xi (from value j to value k, if j<k)
doesn’t decrease f.
Example: strongly unate cover (order is from left to right i.e.
1<2<3 on all variables)
111 011 1111
f = 011 001 1111
001 111 0011
Can detect strongly unate cover by the existence of a value order
for each Pi, where the 0’s are on the left for all cubes. 50
Strongly Unate Functions:
Propositions
•
•
•
•
f strongly-unate
f strongly-unate
f strongly-unate
f strongly-unate
 f weakly-unate
f strongly-unate
 fc strongly-unate
 every prime of f essential..
But:
• Weakly-unate applies to a cover more often
– easier to compute
– good enough for tautology based algorithms
Strongly unate not used in two-level logic minimization
algorithms (so far).
51
Exact Minimization
Use basic logic synthesis algorithm
1. Generate all primes
2. Form covering table
3. Solve covering table
Steps (2)-(3) are same as in binary case
52
Heuristic Minimization
Use Espresso-II
• Irredundant, Reduce, Lastgasp
(Unchanged because tautology based)
• Essential Primes essentially unchanged
(minor technical differences in expression)
• Expand
Minor difference from Espresso-II
Can’t use blocking matrix Bc when expanding cube c.
– May be able to expand ci even if column j is in a minimal column
cover of Bc.
53
Download