lecture03
lecture03
Verification
Jie-Hong Roland Jiang
江介宏
Fall 2024
1
SOPs and Incompletely
Specified Functions
Reading:
Logic Synthesis in a Nutshell
Section 2
3
List of Cubes (Cover Matrix)
We often use a matrix notation to represent a
cover:
◼ Example
F = ac + c’d =
abcd abcd
ac → 1212 or 1-1-
c’d → 2201 --01
4
Programmable Logic Array (PLA)
5
PLA
A PLA implements a (multiple-output) function f :
Bn → Bm represented in SOP form
n=3, m=3 cover matrix
a a b b c c
abc f1f2f3
10- 1 - -
-11 1 - -
0-0 - 1 -
111 - 1 1
00- - - 1
f1 f2 f3
6
PLA
Each distinct cube appears just once in the AND-
plane, and can be shared by (multiple) outputs in
the OR-plane, e.g., cube (abc) in the previous
slide
Extensions from single-output to multiple-output
minimization theory are straightforward
7
SOP
The cover (set of cubes) can efficiently represent many
practical logic functions (i.e., for many practical functions,
there exist small covers)
bc ac
= onset minterm
ab
c Note that each onset minterm is
b “covered” by at least one of the
cubes!
None of the offset minterms is
a covered
8
Irredundant Cube
Let F = {c1, c2, …, ck} be a cover for f, i.e.,
f = ik=1 ci
A cube ci F is irredundant if F\{ci} f
◼ Example
f = ab + ac + bc
bc ac bc
Not covered
ab ac
c
b
F\{ab} f
a
9
Prime Cube
A literal x (a variable or its negation) of cube c F (cover
of f) is prime if (F \ {c}) {cx} f,
where cx (cofactor w.r.t. x) is c with literal x of c deleted
Example
f = xy + xz + yz yz
c = xy; cy = x (literal y deleted)
(F \ {c}) {cy} = x + xz + yz x
z xz
inequivalent to f since y
offset vertex is covered
x
10
Prime and Irredundant Cover
Definition 1. A cover is prime (resp. irredundant) if all its
cubes are prime (resp. irredundant)
11
Prime and Irredundant Cover
Example
f = abc + b’d + c’d is prime and irredundant.
abc is essential since abcd’abc, but not in b’d or c’d or ad
abc
bd
c
b
d
a cd
Why is abcd not an essential vertex of abc?
What is an essential vertex of abc?
What other cube is essential? What prime is not essential?
12
Incompletely Specified Function
Let F = (f, d, r) : Bn → {0, 1, *}, where *
represents “don’t care”
◼ f = onset function f(x)=1 F(x)=1
◼ r = offset function r(x)=1 F(x)=0
◼ d = don’t care function d(x)=1 F(x)=*
13
Incompletely Specified Function
A completely specified function g is a
cover for F = (f,d,r) if
f g f+d
◼ gr =
◼ if xd (i.e. d(x)=1), then g(x) can be 0 or 1;
if xf, then g(x) = 1; if xr, then g(x) = 0
We “don’t care” which value g has at xd
14
Prime of Incompletely Specified
Function
Definition. A cube c is a prime of F = (f,d,r) if c
f+d (an implicant of f+d), and no other implicant
(of f+d) contains c (i.e., it is simply a prime of
f+d)
15
Prime of Incompletely Specified
Function
Example
Consider logic minimization of F(a,b,c)=(f,d,r) with
f=a’bc’+ab’c+abc and d = abc’+ab’c’
don’t care
F2={a, a’bc’, ab’c}
ab’c is redundant c
b
a is prime
F3= {a, a’bc’} a
Expand a’bc’ → bc’
16
Checking of Prime and
Irredundancy
Let G be a cover of F = (f,d,r), and D be a cover for d
ci G is redundant iff
ci (G\{ci}) D (1)
Note: Both tests (1) and (2) can be checked by tautology (to be explained):
17
(Literal) Cofactor
Let f : Bn → B be a Boolean function, and x= (x1, x2, …, xn)
the variables in the support of f; 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)
Example
f = abc + abc fa = bc
c c
b b
a a
18
(Literal) Cofactor
The cofactor Cxj of a cube C (representing some
Boolean function) 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
C = x1 x4’ x6,
C x2 = C (x2 and x2’ do not appear in C)
Cx1 = x4’ x6 (x1 appears positively in C)
C x4 = (x4 appears negatively in C)
19
(Literal) Cofactor
Example
F = abc’ + b’d + cd
Fb = ac’ + cd
20
Shannon Expansion
Let f : Bn → B
Shannon Expansion:
f = xi fxi + xi’ fxi’
21
Shannon Expansion
Example
F = ab + ac + bc
F = a Fa + a’ Fa’
= a (b+c+bc)+a’ (bc)
= ab+ac+abc+a’bc
ab
c c
b b
a a 22
(Cube) Cofactor
The 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
◼ x1 f f x 1
E.g., for f = ac + a’c, afa = af = ac and fa=c
23
(Cube) Cofactor
The cofactor of the cover F of some function f is
the sum of the cofactors of each of the cubes of F
24
Containment vs. Tautology
A fundamental theorem that connects functional containment and
tautology:
Proof.
We use the fact that xfx = xf, and fx is independent of x.
()
Suppose fc 1. Then cf = fcc = c. Thus, c f.
()
Suppose c f. Then f+c=f. In addition, fc = (f+c)c = fc+1=1. Thus,
fc=1.
f
c
25
Checking of Prime and Irredundancy
(Revisited)
Let G be a cover of F = (f,d,r). Let D be a cover for d
ci G is redundant iff
ci (G\{ci}) D (1)
Note: Both tests (1) and (2) can be checked by tautology (explained):
26
Generalized Cofactor
Definition. Let f, g be completely specified
functions. The generalized cofactor of f with
respect to g is the incompletely specified function:
co( f , g) = ( f g, g, f g)
27
Shannon vs. Generalized Cofactor
Let g = xi . Shannon cofactor is
fxi (x1, x2, …, xn) = f (x1, …, xi-1, 1, xi+1,…, xn)
Note that
f xi fxi f xi + xi = f + xi
28
Shannon vs. Generalized Cofactor
on
f = abc + abc + abc + abc off
Don’t care
co( f , a) = ( f a, a, f a) fa = bc + bc
29
Shannon vs. Generalized Cofactor
co( f , a) = ( f a, a, f a)
f a fa fa + a
So f a fa f + a
30
Shannon vs. Generalized Cofactor
x fx + x fx = f f = g co( f , g) + g co( f , g)
( fx )y = fxy co(co( f , g),h) = co( f , gh)
( f g )y = f y gy co( f g,h) = co( f ,h) co(g,h)
(f ) = ( f )
x x
co( f , g) = co( f , g)
31
Data Structure for SOP
Manipulation
33
Operation on Cube Lists
OR operation:
◼ take two lists of cubes
◼ computes union of both lists
Naive implementation:
On-the-fly optimizations:
◼ remove cubes that are completely covered by other cubes
complexity is O(m2); m is length of list
◼ conjoin adjacent cubes (consensus operation)
◼ remove redundant cubes?
coNP-complete
too expensive for non-orthogonal lists of cubes
34
Operation on Cube Lists
Simple trick:
◼ keep cubes in lists orthogonal
check for redundancy becomes O(m2)
but lists become significantly larger (worst case:
exponential)
◼ Example
01-0
01-0 0-1- 1-01
OR =
1-01 1-11 001-
0111
1-11
35
Operation on Cube Lists
Adding cubes to orthogonal list:
36
Operation on Cube Lists
Naive implementation of COMPLEMENT operation
◼ apply De’Morgan’s law to SOP
◼ complement each cube and use AND operation
Example
Input non-orth. orthogonal
01-10 => 1---- => 1----
-0--- 00---
---0- 01-0-
----1 01-11
37
Tautology Checking
Let A be an orthogonal cover matrix, and all cubes of A be
pair-wise distinguished by at least two literals (this can be
achieved by an on-the-fly merge of cube pairs that are
distinguished by only one literal)
38
Tautology Checking
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;
}
39
Tautology Checking
Implementation tricks
◼ Variable ordering:
pick variable that minimizes the two sub-cases (“-”s
get replicated into both cases)
40
Tautology Checking
-1-0
Example --10
1-11 x1
0--- -1-0
x1 tautology (case 1)
-1-0 --10
--10 ----
x2
--11
--10
x2 not tautology (case 3)
---0 --11
x3
--10
---0 not tautology (case 3)
--11
x3 ---- tautology (case 1)
x4
---0
---1
x4 ---- tautology (case 1) 41
Special Functions
Definition. A function f : Bn → B is symmetric with respect
to variables xi and xj iff
f(x1,…,xi,…,xj,…,xn) = f(x1,…,xj,…,xi,…,xn)
f xi x j = f xi x j
- can skip one of four sub-cases
- used in automatic variable ordering for BDDs
42
Special Functions
Definition. A function f : Bn → B is positive unate in variable
xi iff
fx fx
i i
m−j = m+j , j i
mi− = 0
mi+ = 1
Example
(1001, 1011) with i = 3
43
Special Functions
Similarly for negative unate fx fx
i i
monotone decreasing f (m − ) f (m + )
44
Special Functions
Example
f = ab + bc + ac
m+ positive unate in a,b
negative unate in c
c
b f(m-)=1 f(m+)=0
m-
a
45
Unate Recursive Paradigm
Key pruning technique is based on exploiting the
properties of unate functions
◼ based on the fact that unate leaf cases can be
solved efficiently
46
Unate Recursive Paradigm
Unate covers F have many extraordinary properties:
◼ If a prime cover F is minimal with respect to single-
cube containment, all of its cubes are essential primes
In this case F is the unique minimum cube representation
of its logic function
47
Unate Recursive Paradigm
1. Create cofactoring tree stopping at unate covers
◼ choose, at each node, the “most binate” variable for splitting
◼ iterate until no binate variable left (unate leaf)
2. “Operate” on the unate cover at each leaf to obtain the result for that leaf.
Return the result
3. At each non-leaf node, merge (appropriately) the results of the two
children.
a
b c merge
48
Unate Recursive Paradigm
Binate select heuristic
◼ Tautology checking and other programs based
on the unate recursive paradigm use a
heuristic called BINATE_SELECT to choose the
splitting variable in recursive Shannon
expansion
49
Unate Recursive Paradigm
Binate select heuristic
◼ Example
Unate and non-unate covers:
a b c d is unate
G = ac+cd’ 1 - 1 -
- - 1 0
a b c d
F = ac+c’d+bcd’ 1 - 1 - is not unate
- - 0 1
- 1 1 0
Choose c for splitting!
◼ 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
50
Unate Recursive Paradigm
Example
f = ac + c d + bc d c
1 0 1 - 1 -
1--- F= - - 0 1
FC F C
-1-0 ---1 - 1 1 0
unate unate
f = ace + c d + bc d e
c
1 0
1---0 1 - 1 - 0
---1-
-1-01 e F= - - 0 1 -
0 unate
- 1 1 0 1
1
-1-0- 1----
unate unate 51
Unate Recursive Paradigm
Unate Reduction
Let F(x) be a cover. Let (a,c) be a partition of the variables x,
and let
A C
F =
T F
where
1. the columns of A (a unate submatrix) correspond to
variables a of x
2. T is a matrix of all “-”s
52
Unate Recursive Paradigm
Unate Reduction
Example
1 − 0 1
− 1 1 0 1 1
A C
F = − − 1 1 − 0
T F − − − 0 − 1
− − − 1
We pick for the partitioning unate variables because it is easy to decide that A1
53
Unate Recursive Paradigm
Unate Reduction
Example
0 1
A1 1 0
B1
− − − − − − − A3 A4
− − − − − − −− − − − −
− − − − − − −− − − − − 1 D
0 1
A2 0 0 B2
1 1
54
Unate Recursive Paradigm
Unate Reduction
Theorem:
A C
F =
T F
Proof:
If part: Assume F* 1. Then we can replace F*
by all -’s. Then last row of F becomes a row of all
“-”s, so tautology.
55
Unate Recursive Paradigm
Unate Reduction
Proof (cont’d):
Only if part: Assume F* 1. Then there is a
minterm m2 (in c variables) such that F*m2 = 0
(cofactor in cube), i.e. m2 is not covered by F*.
Similarly, m1 (in a variables) exists where Am1 = 0,
i.e. m1 is not covered by A. Now the minterm
m1m2 (in the full variable set) satisfies Fm1m2 = 0.
Since m1m2 is not covered by F, F 1.
56
Unate Recursive Paradigm
Application – Tautology Checking
Improved tautology check
Algorithm CHECK_TAUTOLOGY(List_of_Cubes C) {
if(C == ) return FALSE;
if(C == {-...-}) return TRUE; // cube with all ‘-’
C = UNATE_REDUCTION(C)
xi = BINATE_SELECT(C)
C0 = COFACTOR(C,xi)
if(CHECK_TAUTOLOGY(C0) == FALSE) {
return FALSE;
}
C1 = COFACTOR(C,xi)
if(CHECK_TAUTOLOGY(C1) == FALSE) {
return FALSE;
}
return TRUE;
}
57
Unate Recursive Paradigm
Application – Tautology Checking
-1-0 Unate reduction 0---
Example --10
not tautology (case 2 and 3)
1-11 x1
0--- -1-0
x1 tautology (case 1)
-1-0 --10
--10 x2 ----
--11
--10 not tautology (case 3)
x2
---0 --11
x3
--10
---0 not tautology (case 3)
--11
x3 x4 ---- tautology (case 1)
---0
---1
x4 ---- tautology (case 1) 58
Unate Recursive Paradigm
Application – Complement
We have shown how tautology check (SAT check) can be
implemented recursively using the Binary Decision Tree
Similarly, we can implement Boolean operations recursively,
e.g. the COMPLEMENT operation:
Theorem. f = x fx + x fx
Proof.
g = x fx + x fx
f = x fx + x fx
f g = 0
g = f
f + g = 1
59
Unate Recursive Paradigm
Application – Complement
Complement operation on cube list
Algorithm COMPLEMENT(List_of_Cubes C) {
if(C contains single cube c) {
Cres = complement_cube(c) // generate one cube per
return Cres // literal l in c with l
}
else {
xi = SELECT_VARIABLE(C)
C0 = COMPLEMENT(COFACTOR(C,xi)) xi
C1 = COMPLEMENT(COFACTOR(C,xi)) xi
return OR(C0,C1)
}
}
60
Unate Recursive Paradigm
Application – Complement
Efficient complement of a unate cover
Idea:
◼ variables appear only in one polarity on the original cover
(ab + bc + ac)’ = (a’+b’)(b’+c’)(a’+c’)
61
Unate Recursive Paradigm
Application – Complement
Map (unate) cover matrix F into Boolean matrix B
F B
a b c d e a b c d e
− 1 − 0 − 0 1 0 1 0
− − 0 0 1 0 0 1 1 1
1 1 − − 1 1 1 0 0 1
1 − 0 − 1 1 0 1 0 1
62
Unate Recursive Paradigm
Application – Complement
Find all minimal column covers of B.
◼ A column cover is a set of columns J such that for each row i,
jJ such that Bij = 1
Example
{1,4} is a minimal column cover for matrix B
1 2 3 4 5
0 1 0 1 0 1
0 0 1 1 1 1
1 1 0 0 1 1
1 0 1 0 1 1
63
Unate Recursive Paradigm
Application – Complement
For each minimal column cover create a cube with opposite
column literal from F
Example
By selecting a column cover {1,4}, a’d is a cube of f’
1 2 3 4 5 1 2 3 4 5
a b c d e a b c d e
− 1 − 0 − 0 1 0 1 0
− − 0 0 1 0 0 1 1 1
1 1 − − 1 1 1 0 0 1
1 − 0 − 1 1 0 1 0 1
64
Unate Recursive Paradigm
Application – Complement
The set of all minimal column covers = cover of f
Example
a b c d e a b c d e
− 1 − 0 − 0 1 0 1 0
− − 0 0 1 0 0 1 1 1
1 1 − − 1 1 1 0 0 1
1 − 0 − 1 1 0 1 0 1
f = ad + bc + be + de
65
Unate Recursive Paradigm
Application – Complement
Theorem (unate complement theorem):
Let F be a unate cover of f. The set of cubes associated with
the minimal column covers of B is a cube cover off.
Proof:
We first show that any such cube c generated is in the
offset of f, by showing that the cube c is orthogonal with
any cube of F.
◼ Note, the literals of c are the complemented literals of F.
Since F is a unate cover, the literals of F are just the union
of the literals of each cube of F).
◼ For each cube miF, jJ such that Bij=1.
J is the column cover associated with c.
◼ Thus, (mi)j = xj cj =xj and (mi)j =xj cj = xj. Thus
mic = . Thus c f .
66
Unate Recursive Paradigm
Application – Complement
Proof (cont’d):
We now show that any minterm m f is contained in some
cube c generated:
◼ First, m must be orthogonal to each cube of F.
For each row of F, there is at least one literal of m that
conflicts with that row.
◼ The union of all columns (literals) where this happens is a
column cover of B
◼ Hence this union contains at least one minimal cover and the
associated cube contains m.
67
Unate Recursive Paradigm
Application – Complement
The unate covering problem finds a minimum
column cover for a given Boolean matrix B
◼ Unate complementation is one application based on the
unate covering problem
68