CONSTRUCTION OF LINEARLY TRANSFORMED PLANAR BDD BY WALSH COEFFICIENTS \author{ \begin{tabular}[t]{c@{\extracolsep{1em}}c@{\extracolsep{1em}}c} Mark G. Karpovsky & Radomir S. Stankovi\' c \thanks{This work was supported by the Academy of Finland, Finnish Center of Excellence Programme, Grant No. 44876, and the EXSITE Project No. 51520.} & Jaakko T. Astola \\ Dept. of Electrical and & Dept. of Computer Science & Tampere Int. Center \\ Computer Engineering & Faculty of Electronics & for Signal Processing \\ 8 Saint Marry's Street & Beogradska 14 & Tampere University of \\ Boston University & 18 000 Ni\v s & Technology \\ Boston, Ma 02215 & Serbia & Tampere \\ USA & & Finland \end{tabular}} ABSTRACT In VLSI design, crossings of interconnections occupy space and cause delay. In particular, it is desirable to have planar networks in FPGA synthesis and sub-micron LSIs, since delay in the interconnections and crossings are comparable to the delay for logic circuits. Decision diagrams (DDs) provide a simple technology mapping, and planar DDs result in planar networks. In this paper, we present a deterministic method to construct planar Linearly Transformed Binary Decision Diagrams (BDDs) by Walsh transform spectral coefficients. 1. INTRODUCTION Binary Decision Diagrams (BDDs) are a standard part of many CAD systems in logic design, signal processing, and other areas where efficient, in terms of space and time, manipulation with switching functions is required. Complexity of BDD representation of a given function $f$ is usually estimated by the number of non-terminal nodes in the BDD for $f$, denoted as the size of BDD($f$). The size of BDDs is very sensitive to the order of variables in the functions represented, ranging from the polynomial to the exponential complexity for the same function for different order of variables. Therefore, majority of approaches to the reduction of size of BDDs is related to development of efficient algorithms for reordering of variables, see for example, \cite{[FujitaKukimotoBrayton]}, \cite{[Rudell]}. Linearly transformed BDDs are defined by allowing linear combinations of variables \cite{[GuntherDrechslerexactmethod]}. In this way, the number of possible transformation over variables is increased from $n!$ to $\prod_{i=0}^{n-1}(2^{n}-2^{i})$ for reordering and linear transformation of variables, respectively. There are many algorithms proposed to determine order and linear transformation of variables, which exploit some good heuristics and when integrated in widely used sifting algorithms for BDD minimization \cite{[Rudell]} appear quite efficient see a discussion in \cite{[MeinelSomenziTheobald2000]}. However, a disadvantage of heuristic algorithms is that they cannot guarantee the quality of the results produced. A deterministic algorithm for construction of linearly transformed DDs exploiting properties of switching functions and features of related operators for switching functions in the original and spectral transform domain is proposed in \cite{[KarpovskyStankovicAstola]}. An algorithm for exact minimization of of BDDs by linear transformation of variables has been proposed in \cite{[GuntherDrechslerexactmethod]}. The algorithm takes advantages from features of sifting procedures and properties of linear transformation over the Galois field $GF(2)$. However, for the huge search space, this method is limited to functions of a small number of variables, 6 and in some examples 7 variables. This number of variables is consider sufficient for applications as FPGA synthesis and similar applications. 1.1 Planar decision diagrams Networks without crossings are useful in synthesis with Field Programmable Gate Arrays (FPGAs) \cite{[MurgaiBraytonSangiovanni-Vincentelli]}, since crossings produce considerable delay and in FPGAs delay of interconnections is among the most important problems. Further, planar networks are desirable in sub-micron LSIs, since delay in the interconnections and crossings are comparable to the delay for logic circuits. Decision diagrams provide a simple mapping to technology, since a network is easily derived from a DD by replacing each node with the logic elements realizing the decomposition rules used to assign a given function $f$ to the corresponding DD for $f$. Planar DDs \cite{[ButlerNowlinSasao]}, \cite{[SasaoButlerplanarbdd]} result in planar networks. Definition 1 A Binary Decision Diagram (BDD) is planar if there is no crossing of edges connecting non-terminal nodes, under assumption that edges labelled by $\overline{x}_{i}$ and $x_{i}$ emerge to the left and right of a node, respectively, constant node 0 is to the left of the constant node 1, and all edges are directed down throughout their length, which precludes arcs that extend around the root node or constant nodes. Notice that a planar decision diagram can be derived by the reduction of a decision tree if sharing of isomorphic subtrees is restricted to subtrees rooted at neighboring nodes at a level in the DT. The restrictions for order of labels and values of constant nodes can be removed to enlarge the class of functions with planar diagrams. However, in what follows, these restrictions will be applied to the decision diagrams considered. In this paper, we consider construction of linearly transformed planar Binary Decision Diagrams (LT-BDDs) through Walsh transform coefficients. We assume that switching functions are given in $\{1,-1\}$ encoding to exploit properties of Walsh spectrum. When a LT-BDD constructed, we replace values of constant nodes by logic 0 and 1. 2. BACKGROUND THEORY Switching functions can be viewed as functions defined on finite dyadic groups $C_{2}^{n}$, where $C_{2}=(\{0,1\}, \oplus)$, is the basic cyclic group of order 2, with the group operation $\oplus$, defined as the addition modulo 2, logic EXOR, and $n$ is the number of variables. Walsh functions are group characters of $C_{2}^{n}$, see for example, \cite{[Karpovsky]}, and can be expressed as products of the Rademacher functions $rad(i,x)$, $i=0,1, \ldots , n$, $w = 0, 1, \ldots, 2^{n}-1$, which can be related to switching variables %\begin{eqnarray*} $rad(i,w)= 1-2x_{i}(w)$, %\end{eqnarray*} where $x_{i}(w)$ is the switching function $f(x_{1}, \ldots , x_{n}) = x_{i}$. In this relation, it is assumed that logic values 0 and 1 for switching variables and functions are interpreted as integers 0 and 1. Therefore, it may be said that Rademacher functions are equal to switching variables in $(0,1)_{GF(2)} \rightarrow (1,-1)_{Z}$ encoding, where $GF(2)$ is the Galois field of order 2, and $Z$ is the set of integers. It follows that Walsh functions can be expressed as %\begin{eqnarray*} $wal(r,w) = \prod_{i=1}^{n} (1-2x_{i})^{r_{i}}$, %\end{eqnarray*} where $r_{i}$ are coordinates in the binary representation of the index $r = (r_{1}, \ldots , r_{n})$. Since the set of $2^{n}$ Walsh functions endorse the structure of a multiplicative group $\Gamma$ with the group operations defined as multiplication in $Z$, which is isomorphic to the finite dyadic group $C_{2}^{n}$, a relationship between Walsh functions and linear switching functions, defined as EXOR sum of switching variables, follows directly \cite{[AgaianAstolaEgiazarian]}. We exploit this property to determine linear combination of variables in LT-BDDs. 3. LT-BDD Due to the relationship between Walsh functions and linear switching functions, the following algorithm to construct LT-BDDs can be deduced. Algorithm (Construction of LT-BDD) 1. Given an $n$-variable function $f$ in $\{1,-1\}$ encoding. Calculate the Walsh spectrum. 2. Find the Walsh coefficient $S_{f,max}(w)$ of the maximum absolute value. Declare $w = w_{max}$ and write its binary representation, i.e., $w_{max} = (w_{1}, \ldots , w_{n})$. 3. Determine a linear function $\tau = \bigoplus_{r} x_{i}$, where $r$ goes over the indices of $w_{i}=1$. 4. Determine co-factors for $f$ with respect to $\tau$, i.e., determine the subfunction of $n-1$ variables where $\tau = 0$ and 1, respectively. 5. Create a node whose outgoing edges point to the co-factors $f_{0}$ and $f_{1}$ and label its edges by $\overline{\tau}$ and $\tau$, respectively. 6. Repeat the Steps 1 to 5, for $i = 1$, to $n$. Assignment of variables to the edges in LT-BDDs can be performed by using the following algorithm. Algorithm(Assignment of labels to the edges) 1. If at a node at the $i$-th level the decomposition with respect to a linear combination $x_{k} \oplus x_{q} \oplus \cdots \oplus x_{r}$, where $k < q < \ldots < r$, is performed, relate the variable $x_{r}$ to the level $i$ and eliminate if from further considerations. 2. Repeat the Step 1 to all the levels in the BDD starting from the root node. Example 1 For a four-variable function $f$, defined as ${\bf F} = [1,1,-1,1,-1,1,1,1,-1,1,1,-1,1,-1,1,1]^{T}$, the Walsh spectrum is ${\bf S}_{f} = [6,-2,-2,-2,-2,-2,6,-2,2,-6,2,2,2,2,2,10]^{T}$, and the coefficient with the maximum value is $S_{f_{1}}(15) = 10$, and since $w_{max} = (1111)$, we determine a linear function $\tau_{1} = x_{1} \oplus x_{2} \oplus x_{3} \oplus x_{4}$, where each $x_{i}$ corresponds to the appearance of a coordinate with the value 1 in the binary representation for $w_{max}$. The cofactors of $f$ with respect to $\tau_{1}$ are ${\bf F}_{0} = [1,1,1,1,1,1,1,1]^{T}$, and ${\bf F}_{1} = [1,-1,-1,1,-1,-1,-1,1]^{T}$. We create a node where outgoing edges point to subfunctions ${\bf F}_{0}$ and ${\bf F}_{1}$ and edges are labelled by $\overline{x_{1} \oplus x_{2} \oplus x_{3} \oplus x_{4}}$ and $x_{1} \oplus x_{2} \oplus x_{3} \oplus x_{4}$, respectively. The variable $x_{4}$ is eliminated from further considerations. Since ${\bf F}_{0}$ is a constant function, the edge $\overline{x_{1} \oplus x_{2} \oplus x_{3} \oplus x_{4}}$ points to the constant node 1 directly. The Walsh spectrum for ${\bf F}_{1}$ is ${\bf S}_{f_{1}} = [-2,-2,-2,6,2,2,2,2]^{T}$. The maximum Walsh coefficient for ${\bf F}_{1}$ is 6 for $w_{max} = (011)$, we determine $\tau_{2} = x_{2} \oplus x_{3}$, and perform decomposition of $f_{1}$ into subfunctions of two variables ${\bf F}_{1,0} = [1,1,-1,1]^{T}$ and ${\bf F}_{1,1} = [-1,-1,-1,-1]^{T}$. Since $f_{1,1}$ is a constant function, we proceed with decomposition of $f_{1,0}$. The cofactors depend on variables $x_{1}$ and $x_{2}$, since $x_{3}$ was the last variable in $\tau_{2}$. The Walsh spectrum of it is ${\bf S}_{f_{1,0}} = [2,-2,2,2]^{T}$. Since all the coefficients have the equal absolute value, we freely chose and determine $\tau_{3} = x_{1}$ and do not continue decomposition since we have subfunction of a single variable. In this way, we derive the LT-BDD for $f$ as shown in Fig.~\ref{fig-ltmtbdd}. This LT-BDD represents $f$ as $f = (x_{1} \oplus x_{2} \oplus x_{3} \oplus x_{4})(\overline{(x_{2} \oplus x_{3})}x_{1}\overline{x}_{2} \oplus (x_{2} \oplus x_{3}))$. Since this LT-BDD has 4 nodes, the linearization by Walsh coefficients provided for the reduction of 5 nodes compared to the BDD for $f$ which has 9 nodes. \begin{figure} \begin{center} \epsfysize=4.5cm \leavevmode \epsfbox{ltmtbddltar.eps} % \epsfile{file=structures.eps,height=10cm} \caption{{\sf LT-BDD for $f$ in Example~\ref{ex-ltmtbdd}.}} \label{fig-ltmtbdd} \end{center} \end{figure} 4. FEATURES OF LT-BDD Table~\ref{tbl-benchmarks} compares the sizes of BDDs for the initial (BDD) and optimal (BDDv) order of variables, planar BDDs (BDDr), and planar LT-BDDs produced by decomposition with respect to Walsh coefficients (LT-BDD). For BDDs and BDDs optimized by reordering of variables, sizes are determined by allowing sharing of all isomorphic subtrees, thus, these are not planar decision diagrams. It should be noticed that planar decision diagrams necessarily have larger sizes, since may contain some redundant information at the price of avoiding crossing of edges, which may be an important feature in circuit synthesis and some other applications as explained in \cite{[SasaoButlerplanarbdd]}. With this comparison we estimate impact of keeping decision diagrams planar and efficiency of the linearization of BDDs by Walsh coefficients under this restriction as in the definition of planar DDs. Each output of a multi-output benchmark function is considered as a separate single output function $f-i$, where $f$ is the name of the benchmark and $i$ is the number of the output. The experiments are for small benchmarks, since we compared sizes of LT-BDDs with the sizes of BDDs for the optimal order or variables, which are determined by the brute force method examining all possible $n!$ combinations. However, there is no restrictions to the number of variables in functions to which the method can be applied, due to the existence of fast calculation methods for Walsh transform, including methods over BDDs \cite{[ClarkeZhao]}, and various other classes of decision diagrams, see a discussion in \cite{[JankovicStankovicDrechsler]}. Notice that in applications as FPGA synthesis, even a small gain in the number of reduced nodes count may tremendously simplify the architecture \cite{[MurgaiBraytonSangiovanni-Vincentelli]}. It is worth mentioning that LT-BDD constructed by Walsh coefficients have sizes comparable to the sizes of BDDs for the optimal order of variables. This could be considered as an important feature of LT-BDDs constructed by decomposition with respect to Walsh coefficients. For many functions planar LT-BDDs are smaller than planar BDDs, in this example, for 18 functions. In some cases, the reduction is considerable. Examples are clip-2, clip-3, clip-4, ex1010-2, ex1010-8, rd84-2, sao2-1, sao2-2. There are exceptions where the linearization by Walsh coefficients increases the size of BDDs compared to the size of planar BDDs, since some regular structure in the truth-vectors of these functions is destroyed by the decomposition with respect to the Walsh coefficients. Under the regular structure, we assume appearance of some constant or identical subvectors with my repeat with some regularity. Examples are 9sym, rd84-1, and rd84-4, however, for rd84-2 a considerable reduction is achieved. In 12 cases, the size of planar LT-BDDs is smaller than that of BDDs for the initial ordering of variables. In 6 examples, size of planar LT-BDDs is smaller than size of BDDs for optimal order of variables. Examples are clip-2, clip-4, and sao2-2. Table 1 \caption{\sf Sizes of BDDs, BDDs with optimal order of variables, planar BDD, and planar LT-BDDs.} \label{tbl-benchmarks} \begin{center} \begin{tabular}{lrrrrr} \hline $f$ & $n$ & BDD & BDDv & BDDr & LT-BDD \\ \hline 5xp1-1 & 7 & 14 & 11 & 35 & 13 \\ 5xp1-4 & 7 & 16 & 11 & 19 & 15 \\ 9sym & 9 & 33 & 33 & 33 & 57 \\ apex4-10 & 9 & 95 & 91 & 193 & 148 \\ % apex4-14 & 9 & 94 & - & 213 & 59 \\ clip-1 & 9 & 37 & 34 & 67 & 35 \\ clip-2 & 9 & 58 & 42 & 156 & 45 \\ clip-3 & 9 & 73 & 32 & 196 & 51 \\ clip-4 & 9 & 76 & 36 & 169 & 27 \\ clip-5 & 9 & 36 & 36 & 36 & 22 \\ con1-1 & 7 & 12 & 11 & 11 & 16 \\ con1-2 & 7 & 8 & 7 & 8 & 8 \\ ex1010-2 & 10 & 155 & 148 & 390 & 156 \\ ex1010-8 & 10 & 154 & 147 & 377 & 209 \\ % misex1-3 & 8 & 13 & - & 13 & 14 \\ % msex1-6 & 8 & & 12 & 12 & 9 \\ rd73-3 & 7 & 16 & 16 & 16 & 16 \\ rd84-1 & 8 & 32 & 25 & 54 & 82 \\ rd84-2 & 8 & 25 & 22 & 169 & 15 \\ rd84-4 & 8 & 19 & 19 & 22 & 59 \\ sao2-1 & 10 & 46 & 32 & 75 & 32 \\ sao2-2 & 10 & 48 & 34 & 85 & 31 \\ squar5-1 & 5 & 5 & 5 & 6 & 5 \\ %squar5-2 & 5 & 6 & 6 & 4 \\ %squar5-3 & 5 & 8 & 7 & 8 \\ %squar5-4 & 5 & 11 & 9 & 11 \\ %squar5-5 & 5 & 11 & 9 & 12 \\ z5xp1-3 & 7 & 20 & 14 & 22 & 12 \\ z5xp1-6 & 7 & 15 & 9 & 21 & 9 \\ \hline % z9sym & 9 & 33 & 33 & - & 44 \\ \hline av. & & 45 & 36 & 96 & 46 \\ \hline \end{tabular} \end{center} \end{table} From Table~\ref{tbl-benchmarks}, it follows that on the average LT-MTBDDs are for 48\% smaller than Planar BDD, and for 2\% and 26\% larger than BDDs for initial and optimal order of variables. It should be noticed that compared to planar BDDs, when smaller, planar LT-BDDs are considerably smaller, for 70\%, and when larger, they are just for 20\% larger. This should be pointed out as an useful feature of the method proposed. 6. CLOSING REMARKS Experimental results show that planar LT-BDDs with linear combination of variables determined from maximum value of Walsh coefficients have interesting features, which can be considered as a justification for application of this method. References \begin{thebibliography}{99} {\small {\itemsep=-1.2mm \bibitem{[AgaianAstolaEgiazarian]} S. Agaian, J. Astola, K. Egiazarian, {\em Binary Polynomial Transforms and Nonlinear Digital Filters}, Marcel Dekker, 1995. %\bibitem{[BolligWegener]} %B. Bollig, I. Wegener, "Improving the variable ordering of OBDDs %is NP-complete", {\em IEEE Trans. Comput.}, Vol. C-45, No. 9, %1996, 993-1002. %\bibitem{[BrownFrencisRoseVranesic]}, %S.D. Brown, R.J. Frencis, J. Rose, Z.G. Vranesic, {\em %Field-Programmable Gate Arrays}, Kluwer Academic Publishers, 1992. \bibitem{[ButlerNowlinSasao]} J. T. Butler, J. L. Nowlin, and T. Sasao, "Planarity in ROMDD's of Multiple-Valued Symmetric Functions", {\em 26th IEEE International Symposium on Multiple-Valued Logic}, Santiago de Compostela, Spain, May 29-31, 1996, 236-241. \bibitem{[ClarkeZhao]} E.M. Clarke, K.L. Mc Millan, X. Zhao, M. Fujita, ``Spectral transforms for extremely large Boolean functions'', in %Kebschull, %U., Schubert, E., Rosenstiel, W., Eds., {\em Proc. %IFIP WG 10.5 Workshop on Applications of the %Reed-Muller Expression in Circuit Design}, Hamburg, Germany, Reed-Muller Workshop, RM-1993}, September 16-17, 1993, 86-90. %\bibitem{[Fine]} %N.J. Fine, ``On the Walsh functions'', {\em Trans. Amer. Math. %Soc.}, No.3, 1949, 372-414. \bibitem{[FujitaKukimotoBrayton]} M. Fujita, Y. Kukimoto, R.K. Brayton, ``BDD minimization by truth table permutation'', {\em Proc. Int. Symp. on Circuits and Systems, ISCAS'96}, May 12-15, 1996, Vol. 4, 596-599. %\bibitem{[FujitaMatsunagaKukuda]} %M. Fujita, Y. Matsunaga, T. Kukuda, ``On variable ordering of %binary decision diagrams for the optimization in multi-level %synthesis'', {\em European Conf. on Design Automation}, 1991, %50-54. %\bibitem{[FujitaYangClarkeZhaoMcGeer]} %M. Fujita, J. C.-H. Yang, E.M. Clarke, X. Zhao, P. McGeer, "Fast %spectrum computation for logic functions usign binary decision %diagrams", {\em ISCAS-94}, 1994, 275-278. \bibitem{[GuntherDrechslerexactmethod]} W. G\"{u}nther, R. Drechsler, "Linear transformations and exact minimization of BDDs", {\em Proc. 8th Great lake Symp. on VLSI}, February 19-21, 1998, 325-330. %\bibitem{[GuntherDrechsler]} %W. G\"{u}nther, R. Drechsler, "BDD minimization by linear %transforms", in {\em Advanced Computer Systems}, 1998, 525-532. \bibitem{[GuntherDrechslerVictoria]} W. G\"{u}nther, R. Drechsler, "Efficient manipulation algorithms for linearly transformed BDDs", {\em Proc. %4th Int. Workshop on %Applications of Reed-Muller Expansion in Circuit Design}, Reed-Muller Workshop, RM 1999}, Victoria, Canada, May 20-21, 1999, 225-232. %\bibitem{[GuntherDrechsler1999]} %W. G\"{u}nther, R. Drechsler, "Minimization of BDDs using linear %transformations based on evolutionary techniques", {\em Proc. Int. %Symp. Circuit and Systems}, 1999. \bibitem{[JankovicStankovicDrechsler]} D. Jankovi\' c, R.S. Stankovi\' c, R. Drechsler, "Decision diagram method for calcualtion of pruned Walsh transform", {\em IEEE Trans. on Comput.}, Vol. 50, No. 2, 2001, 1478-151. \bibitem{[Karpovsky]} M.G. Karpovsky, {\em Finite Orthogonal Series in the Design of Digital Devices}, John Wiley, 1976. \bibitem{[KarpovskyStankovicAstola]} M.G. Karpovsky, R.S. Stankovi\' c, J.T. Astola, "Reduction of sizes of decision diagrams by autocorrelation functions", {\em IEEE Trans. on Computers}, Vol. 52, No. 5, 2003, 592-606. %\bibitem{[LaiPedramVrudhula]} %Lai, Y.F., Pedram, M., Vrudhula, S.B.K., ``EVBDD-based algorithms %for integer linear programming, spectral transformation, and %functional decomposition'', {\em IEEE Trans. Computer-Aided Design %of Integrated Circuits and Systems}, Vol.13, No.8, 1994, 959-975. %\bibitem{[MeinelSomenziTheobald1997]} %Ch. Meinel, F. Somenzi, T. Theobald, "Linear sifting of decision %diagrams", {\em Design Automation Conf.}, 1997, 202-207. \bibitem{[MeinelSomenziTheobald2000]} Ch. Meinel, F. Somenzi, T. Tehobald, "Linear sifting of decision diagrams and its application in synthesis", {\em IEEE Trans. CAD}, Vol. 19, No. 5, 2000, 521-533. \bibitem{[MurgaiBraytonSangiovanni-Vincentelli]} R. Murgai, R.K. Brayton, A.L. Sangiovanni-Vincentelli, {\em Logic Syunthesis for Field-Programmable Gate Arrays}, Kluwer Academic Publishers, 1995. %\bibitem{[Rademacher]} %H. Rademacher, ``Einige S\"{a}tze von allgemeinen %Orthogonalfunktionen'', {\em Math. Annalen}, 87, 1922, 122-138. \bibitem{[Rudell]} Rudell, R., "Dynamic variable ordering for ordered binary decision diagrams", {\em Proc. IEEE Conf. Computer Aided Design}, Santa Clara, CA, 1993, 42-47. \bibitem{[SasaoButlerplanarbdd]} T. Sasao and J. T. Butler, "Planar Multiple-Valued Decision Diagrams", {\em 25th IEEE International Symposium on Multiple-Valued Logic}, Bloomington, Indiana, May 23-25, 1995, 28-35. %\bibitem{[SasaoFujita]} %T. Sasao, M. Fujita, (ed.), {\em Representations of Discrete %Functions}, Kluwer Academic Publishers, 1996. %\bibitem{[SauerhoffWegenerWerchner]} %M. Sauerhoff, I. Wegener, R. Werchner, "Optimal ordered binary %decision diagrams for read-once formulas", {\em Discrete Applied %Mathematics}, Vol. 103, 2000, 237-258. %\bibitem{[Sieling]} %D. Sieling, "On the existence of polynomial time approximation %schemes for OBDD minimization", {\em Proc. STACS'98}, Lecture %Notes in Computer Sci., Vol. 1373, Springer, Berlin, 1998, %205-215. %\bibitem{[StankovicAstola]} %R. S. Stankovi\' c, J.T. Astola, {\em Spectral Interpretation of %Decision Daigrams}, Springer, 2003. %\bibitem{[Wegener]} %I. Wegener, "Worst case examples for operations over OBDDs", {\em %Information Processing Letters}, 74, 2000, 91-94.