BDD Minimization by Truth Table Permutations
Masahiro Fujita Yuji Kukimoto Robert K. Brayton Fujitsu Laboratories of America University of California
San Jose, CA 95134 Berkeley, CA 94720
Abstract
Bern, Meinel and Slobodov´a [1] have recently proposed a novel technique called cube transformations to minimize the size of binary decision diagrams. Given a Boolean function, they try to find a domain transformation such that the function after the transformation has a smaller BDD. It has been shown that well-chosen transformations enable us to represent compactly the hidden-weight-bit functions, which are known to have exponential-sized BDDs for any variable ordering.
Although their results are promising, no heuristics for picking good transformations are provided in [1] , i.e. they carefully chose a particular transformation for each function by investigating the characteristic of the function. In this paper, we present a set of heuristic algorithms which construct effective transformations starting from given BDDs. The algorithms are incremental in the sense that they construct a transformation as the combination of local transformations, each of which is guaranteed to generate smaller BDDs. Preliminary experimental results showed that this technique gives us a minimization ability which cannot be captured by dynamic reordering.
1 Introduction
Binary decision diagrams (BDD) are the most memory-efficient canonical data structure for Boolean functions known so far, which are now used in almost every aspect of logic synthesis and verification. The fact that the size of BDDs is highly sensitive to variable ordering has spurred a large body of research on heuristic variable ordering [2, 4, 3]. In 1993, Rudell [6] gave a powerful reordering algorithm called sifting and showed that there is an efficient way to change variable ordering dynamically while BDDs are constructed, which significantly enlarged the applicability of BDDs. Recently Bern, Meinel and Slobodov´a [1] have proposed a novel technique called cube transformations to minimize the size of binary decision diagrams. Given a Boolean function, they try to find a domain transformation such that the function after the transformation has a smaller BDD. The transformation can be seen as a row-wise permutation of the truth table of a given function. More precisely, given a completely specified function
f
:B
n!B
, a cube transformation is a one-to-one mapping'
:B
n !B
n, where forx
2B
n, the output value of the transformed function off
isf
('
(x
)). In this paper, we use a different terminology truth table permutations or TTP for short since we think this is more informative. We are interested in finding a transformation'
such thatbdd size
(f
('
(x
)))< bdd size
(f
(x
)). Notice that the technique can be seen as an extension of variable reordering since any variable reordering can be cast into a simple truth table permutation. It has been shown in [1] that well-chosen transformations enable us to represent compactly the hidden-weight-bit functions, which are known to have exponential-sized BDDs for any variable ordering. Although their results are promising, no heuristics for picking good transformations are provided in [1] , i.e. they carefully chose a particular transformation for each function by investigating the characteristic of the function. In this paper, we present a set of heuristic algorithms which construct effective transformations starting from given BDDs. The algorithms are incremental in the sense that a transformation is constructed as the combination of local transformations, each of which is guaranteed to generate smaller BDDs. Preliminary experimental results showed that this technique gives us a minimization ability which cannot be captured by dynamic reordering.This paper is organized as follows. Section 2 gives a simple example of truth table permutations. Section 3 gives the basic definition of truth table permutations. Section 4 discuss how to construct a promising transformation given a BDD. In Section 5 we show that truth table permutations can be seen as a heuristic technique for solving the re-encoding problem for multi-valued functions. Preliminary experimental results are given in Section 6. Section 7 concludes the paper.
The second author is supported by NSF/DARPA under Contract #MIP-8719546
00 0 01 0 10 1 11 1 ab o
00 0 01 1 10 1 11 0
ab o Permutation
a
b b a
0 1 0 1
1 0
Figure 1: Example — Truth Table Permutation
2 Example
We will show a simple example of truth table permutations to clarify how BDDs can be simplified. Consider the two-input EXOR function
f
=a
b
. The BDD for this function has five nodes as shown in Figure 1. Notice that the size is not sensitive to variable ordering since the function is symmetric. Consider a truth table permutation where (a;b
) =(0
;
0);
(0;
1);
(1;
0);
(1;
1)are mapped to(0;
0);
(1;
1);
(1;
0);
(0;
1)respectively, i.e. the output values of(a;b
)=(0;
1)and(1
;
1)are swapped. Once we applied this transformation to the EXOR function, the resulting function isa
, whose BDD has only three nodes, i.e. we could reduce the BDD size by two. Note that this type of reductions is not possible by any variable reordering. If we maintain the precise information on the permutation performed, then the original functionality can be always extracted from the transformed function. In other words, any transformation induced by a truth table permutation is invertible. Note that the inverse transformation is also a truth table permutation.3 Truth Table Permutations
Definition 1 [1] A truth table permutation
'
is a one-to-one mapping'
:B
n !B
n, whereB
=f0;
1gandn
is thenumber of input variables.
Let
f
:B
n!B
nandx
2B
n. Letf
' =f
'
be the new function obtained after applying the TTP'
tof
, wheredenotes the functional composition. Intuitively,
'
gives a permutation on the input domainB
n. Given a mintermx
, thepermutation gives a minterm of
B
n, where the functionf
is evaluated. Our goal is to find a permutation such that the functionality after the transformation is simplified. Note that this is equivalent to changing the onset of a function such that the size of the onset remains unchanged. As long as we keep the permutation and the resulting function, the original functionality can be always extracted. Therefore, truth table permutations do not cause any loss of information.Bern, Meinel and Slobodov´a proposed in [1] the basic notion of truth table permutations and showed that the hidden- weight bit functions can be represented compactly with a certain truth table permutation. Specifically, they investigated a strict subset of truth table permutations, namely those represented by complete types. Figure 2 shows an example of complete types for functions defined over three variables
a;b
andc
. Given a complete type represented as a DAG, one can extract a TTP by traversing the graph from its root to its leaves. For the details of complete types, the reader should refer to [1]. Due to the structural constraint on complete types, it is known that we cannot explore the entire flexibility of TTPs by complete types.Truth table permutations give us a way to reduce the size of BDDs as seen in Figure 1, but we still remain to answer if they are useful in actual applications. The following properties of TTPs make them attractive [1].
a
b b
1 0
c
c
t
Figure 2: Complete Type
f
g
=?
f
g TTP =?
Figure 3: Boolean Comparison
1. Let
'
be a truth table permutation.f
=g
ifff
'=g
' 2. Let?
be a binary operator on Boolean functions.(
f ? g
)'=f
'? g
'The first property implies that Boolean comparison of two functions can be done by comparing the corresponding functions after a truth table permutation. The second property allows us to perform any binary operation on the original functions using transformed functions. These two properties are essential in setting up an effective Boolean comparison technique using TTPs. The idea is to attach an additional circuit representing a truth table permutation to the input of the two functions as shown in Figure 3. By smartly choosing a truth table permutation, one can make the transformed functionality of the two outputs simpler, thereby making Boolean comparison itself easier. Notice that TTPs can be applied dynamically just like dynamic reordering. The approach would be that when we get a huge BDD while constructing an output function, a TTP is dynamically performed to reduce the size of the function. The entire TTP is maintained incrementally in runtime.
When Boolean comparison fails, one can derive distinguishing input patterns by taking the image of distinguishing input patterns for the transformed functions in terms of the TTP function.
One of the most important properties of TTPs is the existence of a powerful permutation for any Boolean function.
Theorem 1 Given any Boolean function and any variable ordering, there exists a TTP which gives a linear-sized BDD.
of the function,j
f
j, and then construct the function whose onset is a contiguous region from 00:::
0 tobinary
(jf
j?1).Intuitively, the transformation moves every minterm of the function as close as possible to 00
:::
0. It is easy to see that the BDD constructed this way is of linear-size. Although the construction of the resulting function is easy, computing such a TTP itself is difficult in practice. Therefore, the realistic goal is to come up with a good TTP heuristically, which is described in Section 4.In the following subsections, we discuss the relationship between TTPs and other closely related techniques.
3.1 TTPs vs. Variable Reordering
Swapping two variables in BDD ordering can be seen as a TTP transformation, i.e. variable reordering is a strict subset of TTPs. For example, the swap of two variables
x
andy
in the current ordering can be done with the following TTP.x y x y
:::
0:::
0:::
):::
0:::
0:::
:::
0:::
1:::
):::
1:::
0:::
:::
1:::
0:::
):::
0:::
1:::
:::
1:::
1:::
):::
1:::
1:::
3.2 TTPs vs. Spectral Transformations
Spectral transformation is a well-known transformation applicable to Boolean functions. The input to this transformation is a vectorx2f0
;
1g2n corresponding to the output values of ann
-variable Boolean function for all the input patterns, and a 2n2ninteger matrixM
. The result of the transformation is another vectory =M
x. The structure of the matrixM
characterizes the type of the transformation.
The similarity between TTPs and spectral transformations is the fact that TTP can also be represented as a matrix of the same size, which we call a permutation matrix. The constraint to be satisfied is:
The matrix is a 0-1 Boolean matrix.
For any row of the matrix, there exists a single column containing 1.
For any column of the matrix, there exists a single row containing 1.
In spectral transformations, generally
M
(x?
y )6=M
x? M
y, where?
is a binary operation. Thus, computingM
(x?
y )from
M
xandM
yusually takes exponential time. On the other hand, TTPs satisfies the equality as we saw in the second property of TTPs.4 Algorithms for Constructing Permutations
In the previous section, we have shown that for any function, there exists a TTP that enables us to represent the transformed function with a linear-sized BDD. Computing such a TTP, however, is in general difficult. Moreover, the representation of the permutation in BDDs could be large, thereby potentially canceling out the reduction obtained from the transformation.
Thus, we want to extract a reasonably good TTP heuristically. Specifically, we are interested in constructing a promising TTP automatically given a BDD. In this section, a couple of such algorithms will be presented, where a TTP is dynamically constructed in order to reduce the size of the current BDD. The algorithms are based on local hill-climbing, i.e. each transformation tries to convert the current BDD to a smaller BDD level-by-level. A final TTP is generated as the combination of such transformations.
4.1 One-level Swapping
The first local transformation looks at each level of a given BDD one by one to find out a pair of nodes(
index;then;else
)=(
x;f;g
);
(x;g;f
), i.e. two nodes which are labeled with the same variable and have the same two children connected differently. The twox
nodes of the left BDD in Figure 4 are an example of such a pair of nodes. We want to merge the two1 0
x x
y z
0 1 1
0 x
y z
Figure 4: One-level Swapping
0 1
x x
y z
w
0 1
x
y z
0 1
w original BDD (f)
BDD after TTP (new f)
BDD for TTP (p)
Figure 5: Example of One-level Swapping
nodes into a single node as shown on the right in Figure 4. Note that the reduction shown in Figure 4 is exactly the same as Minato’s input complement edges [5]. The TTP to be performed is: given a minterm(
seq;:::
)whereseq
corresponds to a 0-1 assignment to the variables abovex
in the current BDD ordering,If
seq
leads to the shaded node, then(seq;
0;:::
) ) (seq;
1;:::
)and(seq;
1;:::
) ) (seq;
0;:::
), else notransformation is performed.
More formally, let
p
be the function which evaluates to one if and only if an evaluation up to variablex
leads to the shaded node in the left BDD. Letf
be the initial function being minimized. The result of the TTP is:f
' =f
jx=xporf
'=pf
+p
(xf
¯ x+xf
x¯). Note thatp
captures the exact information on the permutation.Figure 5 shows how the reduction is done in a simple example. The two nodes labeled with
x
here are the pair of nodes chosen by this TTP. The two children of the right node are swapped so that the resulting node is exactly the same as the left node. This reduction causes a further reduction on levelw
, where the only node is removed since both its 0-edge and 1-edge point to the same node. This transformation saves us 2 nodes, while one additional node is needed to representp
. Inthis particular example,
p
=w
.4.2 Two-level Swapping
This technique is an extension of one-level swapping. Instead of looking at each level one by one, now we examine two levels of a given BDD simultaneously to find out a set of potential nodes for size reduction. Figure 6 shows an example of TTPs falling into this category. Here we are looking at level
x
and levely
simultaneously to see if there is a node labeled withx
whose grandchildren can be rearranged so that the total number of nodes in the BDD decreases. In this example, the 01 child and the 10 child are swapped. This saves us one node at levely
. Note that this transformation is a generalization of adjacent-variable swapping in BDD ordering in the sense that swapping is done selectively to a subset of nodes in a level not to all the nodes in the level as in variable swapping. The corresponding TTP is:0 1 x
y
x
y
G1 G2 G3 y
0 1
G1 G2 G3 00
01 10 11
00 10 01 11
Figure 6: Two-level Swapping
1 0
x
y
x
y
G1 G2 G3
y
0 1
G1 G2 G3 00
01 10 11
00 11 10 01 TTP
Figure 7: Two-level Swapping
If seq leads to the shaded
x
-node, thenxy xy
(
seq
01:::
) ) (seq
10:::
)(
seq
10:::
) ) (seq
01:::
)else no transformation.
More formally, let
f
be an initial function to be minimized andp
be the function which evaluates to one if and only if an evaluation leads to the shadedx
node. Thenf
'=[p
+p
(x
y
)]f
+p
(x yf
¯ xy¯ +xyf
¯ xy¯):
Figure 7 shows a similar transformation as before, but this is not even a local variable swapping since the swapping is done between the 01-child and 11-child.
So far we have not considered the case where the nodes on the second level, i.e. the nodes labeled by
y
in Figure 6, are pointed by some other nodes. This case complicates our situation since even if ay
node can be removed locally from a subgraph, it may still be pointed by another node, in which case the function still needs this node. A reduction strategy based on this observation is illustrated in Figure 8. Here we try to find a set of nodes which have the same four grandchildrenG
1;G
2;G
3 andG
4. In Figure 8 the two nodes labeled withx
satisfy this condition. We pick one of them as a canonical form and transform everything else to this canonical form by a TTP. This allows us to reuse existing nodes effectively.4.3 Minimizing Multiple BDDs
In real applications, one needs to minimize the size of more than one BDD simultaneously. The algorithms presented so far can be extended naturally by applying the same TTP to all the functions we are interested in. One problem in this extension
1 0
x
y
G1 G2 G3 y
G4 x
y y
1 0x
y
G1 G2 G3 y
G4 00 01
01 10 10 11 11 00 TTP
Figure 8: Two-level Swapping
is that the effect of TTPs is not any more predictable since a TTP which gives a local size reduction of one BDD could increase the size of other BDDs. One has to discard a TTP if the total gain is negative.
5 Application: Re-encoding Multi-Valued Variables
In this section, we show that the technique can be adapted to solve the re-encoding problem of multi-valued variables heuristically. The re-encoding problem is to find a better encoding of multi-valued variables given a multi-valued input function and an initial encoding. The cost criterion is to minimize the complexity of the encoded function in some representation. In the following, we measure the complexity of the functions by the size of BDDs.
Let
f
be a multi-valued-input binary-output function,f
:P
1P
2:::P
m !B
, whereP
i(i
=1;:::;m
)is the multi- valued domain ofi
-th multi-valued variable. Assume thati
-th multi-valued variable is encoded withdlogjP
ijeBoolean variables (x
i;1;:::;x
i;dlogjPije). Letenc
(f;
[E
1;:::;E
m]) be the encoded Boolean function off
under the encoding[
E
1;:::;E
m]), whereE
i is the encoding ofi
-th multi-valued variable. Then, re-encoding ofi
-th multi-valued variable in this functionenc
(f;
[E
1;:::;E
m])corresponds to a specific class of TTPs in which only the Boolean variables fori
-thvariable, (
x
i;1;:::;x
i;dlogjPije), are allowed to be permuted. More precisely, the TTPs'
should satisfy the following condition, where'
(x
1;1;:::;x
m;dlogjPmje)=(x
˜1;1;:::; x
˜m;dlogjPmje).1. (
x
i;1;:::;x
i;dlogjPije)!(x
˜i;1;:::; x
˜i;dlogjPije)is an arbitrary TTP fromB
dlogjPije!B
dlogjPije.2. 8
k: x
˜j;k=x
j;kifj
6=i
It is easy to restrict our TTP construction algorithms to find TTPs satisfying these constraints by allowing local changes only in the levels(
x
i;1;:::;x
i;dlogjPije).6 Experimental Results
We have conducted a preliminary experiment on the minimization of BDDs using TTPs. Our scenario was as follows.
pre-reordering TTP post-reordering (+ permutation)
C499 32106 18395 18105 18944 0.59
C1355 29562 28872 28872 28883 0.97
C7552 9741 9496 9566 9603 0.98
des 4438 4061 4020 4027 0.90
i10 42006 38742 34434 34498 0.82
rot 5592 5414 4943 4944 0.88
Table 1: Experimental Result – BDD Size Reduction
circuit CPU time
pre-reordering TTP post-reordering
C499 20.2 6310.5 42.3
C1355 21.0 1066.1 23.2
C7552 11.5 679.6 53.5
des 1.6 218.8 2.7
i10 127.7 655.2 90.5
rot 3.4 37.5 5.2
Table 2: Experimental Result – CPU Time
1. Read in a multi-level network.
2. Compute all the primary output functions of the network using dynamic reordering. The initial ordering is chosen by Malik’s heuristic [4].
3. Minimize BDDs by dynamic reordering (pre-reordering).
4. Perform TTP-based minimization.
5. Minimize BDDs further by dynamic reordering (post-reordering).
Note that the same TTP is used to minimize all the primary output functions.
We picked 19 large multi-level networks for this experiment from the MCNC/ISCAS benchmark suite. Table 1 shows the result for 6 circuits, where TTP yielded reasonable reduction. The second, the third and the fourth columns contain BDD sizes for primary outputs after pre-reordering, TTP minimization and post-reordering respectively1. The fifth column contains BDD size for primary output functions and permutation functions after all the minimization. CPU time measured in seconds on DEC Alpha server 2100 is reported in Table 2. For the remaining 13 circuits2, the effect of TTPs was negligible.
This can be explained by the fact that the current TTPs extracted by the algorithms are not powerful enough due to the local hill climbing strategy. A more global view like the one in sifting is necessary to take full advantage of the power of TTPs.
In this experiment, TTPs are invoked only after all the primary output functions are computed. We are currently working on the idea of performing TTPs dynamically as BDDs are constructed to see how much additional improvement is achievable.
7 Conclusion
In this paper we have proposed a novel approach for minimizing the size of BDDs using the notion of truth table permutations originally given by Bern et al. The main contribution of this paper is a set of heuristic algorithms for constructing effective
1Note that post-reordering could increase BDD size of primary output functions since reordering is done in such a way that the BDD size of primary output functions and permutation functions is minimized.
2The circuits are C432, C880, C1908, C2670, C3540, C5315, dalu, frg2, i8, i9, k2, pair, and too large.
permutations given functions in BDDs. We have shown that variable reordering is just one instance of TTPs, so theoretically more powerful minimization can be expected with TTPs. We have also shown that TTPs can be the basis for the re- encoding problem of multi-valued functions. Experimental results showed that TTPs enable us to perform a different type of minimization than variable reordering although the minimization ability is currently somewhat limited due to the local hill-climbing strategy employed in our implementation. We are currently working on incorporating more global strateg ies into the algorithms to see how much minimization ability TTPs have.
References
[1] J. Bern, C. Meinel, and A. Slobodov´a. Efficient OBDD-based Boolean manipulation in CAD beyond current limits.
Technical report, Universit¨at Trier, 1994.
[2] M. Fujita, H. Fujisawa, and N. Kawato. Evaluation and improvements of Boolean comparison method based on binary decision diagrams. In Proceedings of IEEE International Conference on Computer-Aided Design, pages 2–5, November 1988.
[3] M. Fujita, Y. Matsunaga, and T. Kakuda. On variable ordering of binary decision diagrams for the application of multi-level logic synthesis. In Proceedings of European Design Automation Conference, pages 50–54, February 1991.
[4] S. Malik, A. R. Wang, R. K. Brayton, and A. Sangiovanni-Vincentelli. Logic verification using binary decision diagrams in a logic synthesis environment. In Proceedings of IEEE International Conference on Computer-Aided Design, pages 6–9, November 1988.
[5] S. Minato, N. Ishiura, and S. Yajima. Shared binary decision diagrams with attributed edges for efficient Boolean function manipulation. In Proceedings of 27th ACM/IEEE Design Automation Conference, pages 52–57, June 1990.
[6] R. Rudell. Dynamic variable ordering for ordered binary decision diagrams. In Proceedings of IEEE/ACM International Conference on Computer-Aided Design, pages 42–47, November 1993.