On data manipulation of Boolean functions

On data manipulation of Boolean functions

Comput & Elect.Engng,Vol 8. No 2. pp 115-122.1981 O045-7906/811020115-Oa$ff2.00/O Printedm GreatBritain © 1981PergamonPressLtd. ON DATA MANIPULATI...

540KB Sizes 13 Downloads 162 Views

Comput & Elect.Engng,Vol 8. No 2. pp 115-122.1981

O045-7906/811020115-Oa$ff2.00/O

Printedm GreatBritain

© 1981PergamonPressLtd.

ON DATA MANIPULATION OF BOOLEAN FUNCTIONS N. K. NANDA Department of Electronics and Communication Engineering, University of Roorkee, Roorkee 247 672, India

and R. G. BENNETTSt Department of Electronics, The University, Southampton, SO9 5NH, England (Received[or publication 1 October 1980)

1. I N T R O D U C T I O N

This paper is concerned with the practical problems associated with the computer implementation of algorithms for manipulating Boolean data. The motivation for the study reported here came from a research programme to study the application of Boolean difference theory to digital circuit fault diagnosis problems[l]. A problem that arose in this study was to generate a reduced (but not necessarily minimal) sum-of-products (s-o-p) expression for a Boolean function, working either from its reverse Polish equivalent [2] or directly from the logic circuit. The solution to this problem is not difficult from a theoretical point of view and is based on the application of standard Boolean expansion and reduction identities. The difficulties arise when such procedures are converted into practical algorithms. The amount of computer memory required to hold the intermediate data becomes unpredictable and can grow rather alarmingly for seemingly modest circuits. This property of data-sensitivity tends to preclude useful solutions for practical problems and the objectives of this paper are to discuss the problem in more detail and to present results pertaining to the upper theoretical and experimental bounds on the amount of data generated for an n-variable function. Such information will be of value not only for logic synthesis and analysis problems that require the generation of reduced s-o-p expression (e.g. PLA-based design), but also to other function analysis problems such as fault-tree analysis [2]. Briefly, the problem can be stated thus. The manipulation of Boolean data involves the three basic operations of complementation, addition (OR) and multiplication (AND). Application of these operators produce varying amounts of redundant data that must eventually be removed to obtain a Boolean expression in a reduced form. This is essentially a two-level minimization problem aimed at reducing the complexity of Boolean functions. The conventional minimization process consists of generating a canonical representation of a function, and then generating all the prime implicants and finally selecting the essential prime implicants. This is obviously memory consuming and heuristics have been developed which eliminate the first two steps and generate the result in a reduced s-o-p form working directly from a non-canonical expression. This is achieved by the repetitive use of Boolean simplification identities. The commonly implemented identities are 1. 2. 3. 4.

xixj + xixj = xix i xl + xlxj = xi xixj + x~$~ = x~ x, + $,x~= xi + x~.

The first three identities are a straight-forward comparison of the literals in the terms of the tPresently with Cirrus Computers Ltd., 29/30 High St., Fareham, Hants, England. 115

116

N.K. NANDAand R. G. BENNETTS

function. However, the fourth identity may require reconfiguration of the Boolean expression[2]. This can involve an extensive search amongst the literals of the terms of the function to arrive at a form suitable for factoring. This identity is not usually implemented and it has been commented thatt "we have little to offer aside from exhausting all the possibilities for the grouping of variables. Even then we are not sure that we can do better by being a little more clever". Once a simplified expression has been reached there is no guarantee that it is the simplest form available. This, however, is dependent upon the identities implemented. The implementation of the heuristic approaches requires a judicious pre-ordering of the Boolean functions. This is generally a linear ordering based upon the cardinalities of the terms of the function. A logical conclusion from the preceding paragraphs is that the amount of data that needs to be manipulated is a function of the implementation approach. However, an important question that arises is, though implementation dependent, what is the extent of data that may be encountered and can it be quantified? The aim of this paper is to make a quantitative estimation of the data manipulation and reduction. The objectives are to: (i) Determine the upper bound of data that can possibly be encountered during the complementation of a Boolean function, and (ii) Assess the extent of reduction in the data involved, when two Boolean functions are logically multiplied or added. These objectives have been realized by performing experiments[l] using C-CAT (Combinational Circuit Analysis and Testing) suite of programs [3]. Two algorithms of the suite v/z. ORCHEK and MULTIPLY have been used. Details of these algorithms are given in [3], but a brief description follows to ensure continuity and readability of the paper. ORCHEK performs logical OR operations between disjunctive Boolean expressions each containing one or more conjunctive terms and the result is a reduced s-o-p expression. This is achieved by invoking the first three Boolean identities to remove the redundant terms. MULTIPLY is used for logical AND of two Boolean expressions, and will eliminate a conjunctive term formed by the two terms being multiplied which have a literal in a complemented form in one and in an uncomplemented form in the other term. ORCHEK can be applied independently, whereas MULTIPLY is always followed by ORCHEK to remove the redundant terms. The paper in general can be divided into two parts. Part A deals with the complementation aspect and part B with logical multiplication and addition of Boolean functions. PART A 2. DATA MANIPULATION IN THE COMPLEMENTATION OF A BOOLEAN FUNCTION Let a function F of n variables be a disjunction of k conjunctive terms each having a maximum cardinality of n. The iogical complementation consists of converting the function from a disjunctive to a conjunctive form through the use of De-Morgan's theorem. The process of complementation as such is straightforward. It is, however, the removal of redundant data during the transformation of a complemented function to a reduced disjunctive form that requires most of the computation. The upper bound for the number of terms of a complemented function in a disjunctive form is n k. This in fact represents the maximum bound and is achieved in k - 1 logical multiplication steps. Let T~° represent the maximum number of terms that are generated at the ith step Si, where i = 0, I . . . . . k - 1. The step by step determination of T~° is as follows. Step 0. This is a trivial case, i.e. when there is only one term in E Accordingly Too = n. Step 1. Consists of ANDing the first two terms of the conjunctive form of the complemented function. T l ° = n x n = n 2. tCaldwell,S. H., SwitchingCircuitsand LogicalDesign,Wiley,New York(1967).

On data manipulation of Boolean functions

117

Step 2. Consists of ANDing the 3rd term with the result of the Step 1. T2° = n2 x n = n 3.

Step k - 1. Consists of ANDing the kth term with the result of the ( k - 2)th step. T°_! n k. =

(1)

This above analysis does not consider the polarity of the literals in the terms of the function E tn practice the presence of opposite polarity literals will cause a reduction in the number of terms when the disjunctive terms of the complemented function are logically multiplied. This is because the product of two terms containing a common variable but with opposite polarities is zero. Let m~ represent the number of product terms that are removed in this way at the ith step, Tim the maximum number of terms that can practically be postulated and T/~ the number of terms that are actually generated. The new bounds for the generated terms are Step 0. T o m = rl, m i = O. Step 1. ?'1° = T1 m = n 2 TI a = n 2 - ml = Ti° - ml. Step 2. T2 m = n. 7'1 ~ = n ( n 2 - m O

= n 3 - nml

T2 a = n 3 - n m l - m 2

Step

k - 1. T ~ , - i = n k - m l n k-2 - m 2 n k-3 . . . . . . . . . -

n2mk-3 - nmk-2 - mk-l.

(2)

It is obvious that T/a _< T m _< ~ . The reduction mi at each step is data dependent and cannot be ascertained without performing the actual logical multiplication. However, it can be seen that the reductions m; are multiplied at subsequent steps by varying powers of n. Therefore, the greater the reductions at the initial steps, the lesser would be the value of TLt. It is also known from Switching Theory that logical multiplication may yield an expression which contains duplicated and therefore redundant terms. All such terms need to be removed after k - 1 multiplication steps have been completed. This is because the final complemented function should theoretically contain no more than 2n - k terms• Therefore, after the multiplication of all the disjunctive terms is complete, a minimum of T~,_t- (2n - k) terms must be removed from the final answer. An alternative is to remove redundant terms at each intermediate step rather than to delay their removal until all the disjunctive terms have been multiplied. Let di represent the number of redundant terms that are deleted at each ith step Si. Further, let T~, T~ and T~ respectively represent for the ith step, the maximum possible number of terms that can be practically postulated, the maximum number of terms obtained after m~ deletions and the maximum number of terms that remain after both m~ and d~ reductions. The modified bounds then would be:

So. Yo'= yob= Toi=n $1. T 1 P = n x n = n

2

7'1 b = n 2 -

7"iI =

ml

n 2 - ml -dl

$2. T2 p = T11 x n = n 3 - n ( m l + d l ) ?'2 b = n 3 - n ( m t + d O - m 2

T2/ = n 3 Sk-I.

n(ml + dl) - ( m 2 + d2)

T~-1 = n k -

nt-2(ml

+ dO-

nk-3(m2 +

- n(mk-2 + dk-2) - (mk-i +

d2) . . . . . . .

dk-l)

obviously T/-< T/b< - T/v, T/v< T/m,and T/b_< T/o. CAEE Vol. 8. No. 2--C

(3)

118

N. K. NANDAand R. G. BENNETrS

For a function of k terms, eqns (2) and (3) are derived in k - 1 steps. Results of an ith step Si represent the cumulative effect of the (i+ 1) number of disjunctive terms of the complemented conjunctive function. In general if i = k - 1, then Si gives the final answer, otherwise for i < k - 1 it is an intermediate step. For example, k = 3, $2 is the final step whereas for k = 5 it is an intermediate step. 2.1 Experimental results

In order to determine the upper bounds of the various parameters of Section 2, two experiments using ORCHEK and MULTIPLY algorithms were conducted[l]. In the first experiment only the deletion through MULTIPLY were considered and the redundant terms were removed by ORCHEK, only after ( k - l) multiplication steps have been completed. (This was achieved by modifying the programs so that ORCHEK does not follow MULTIPLY. This would ensure that the only reductions will be of x~ • ~?~= ~ type at each step). In the second experiment redundant terms were also removed by the use of MULTIPLY and ORCHEK at each step in a normal way. The experimental results yield the following information. (i) The maximum number of terms T,a that are generated without removal of redundant terms at intermediate stages, i.e. considering only m; deletions (eqn 2). (ii) Maximum number of terms T[ that are generated after removal of redundant data at each stage, i.e. involving both the m~ and d~ deletions (eqn 3). The data set for the experiments consisted of a function F of k canonical term that were selected from 2n canonical terms that can be postulated for n variables. All the possible 2~k combinations of canonical terms were considered in the formation of F. Consideration of F in a canonical form yields the maximum values of the parameters T/m, T/a, Tp, T/b and T,! that can possibly be encountered. These values are the maximum that are obtained from all the combinations of the function F. The functions that were complemented consisted of 3, 4 and 5 variables. Values of K up to 7 were considered. This value has been chosen because, this is the maximum possible value that can be selected when a function of 3 variables is complemented (if all the 23 terms are considered in an uncomplemented function, the complemented function will be ~t). For a relative comparison, this figure has been retained for complementation experiments with 4 and 5 variable cases as well. Table 1 provides a complete summary of the results--both with and without removal of redundant terms at the intermediate stages. Consider the results.corresponding to n = 4 in Table 1. The results in ith step indicate the maximum values that can be generated whether Si is an intermediate or the final step. With the number of terms k up to 7, there are 6 multiplication steps. At $1 two terms of 4 variables are logically multiplied. Therefore, TIa = T~m = 16. However, in a practical case the two terms must at least differ in one variable. Accordingly, reduction due to multiplication is ml= 1 and T~a = 15. Suppose there is no intermediate removal of redundant terms (no ORCHEK), then at $2, T2m = 15 × 4 = 60. But the experimental results give a maximum value of T~~ = 50. Similarly, T3m = 50 × 4 = 200 whereas actually T3a = 160. Continuing this way, at $6, T6" = 4128 and T6 a = 2340. On applying ORCHEK 2330 redundant terms were removed and the final number of terms in the reduced s-o-p expression of the complemented function was 10. Going back to Step 1 consider that the redundant terms are also removed at every step. Then T,e = 16, T~b = 15 and computed T,/= 12. At $2, T2p = 12 x 4 = 48. However, computed results show that T2b = 36 and T2! = 9. Similarly, T3p = 9 × 4 = 36, but experimentally Tab = 29 and /'31 = 8. In a similar way at $6, T6p = 48, but T6b = 27 and T61 = 10. The data sets of Table l corresponding to 3 and 5 variables can be interpreted similarly. Looking at the tables one gathers that for all the variables, i.e. n = 3, 4 and 5 and for all i, T/a < T/m < T,° and the ratios Tia/T,° are continuously decreasing for increasing k and n. This suggests that the maximum of data values that are actually generated (T,~) are less than the theoretical maximum bound (T~°). For example, for n = 4 and k = 4, T~° = 256, T~~ = 160 (Table l). Therefore, no more than 160 terms are ever generated whereas the theoretical maximum bound is 256. Hence for all practical purposes T,-a represents the upper bound of terms that can be generated during the com-

On data manipulation of Boolean functions

119

Table 1. Details of results during the complementation process for n = 3 to 5

t

s,

r,°

r,-

n=3 2 3 4 5 6 7

Sl S2 S3 S4 Ss S6

9 27 81 243 729 2187

9 24 51 99 120 132

St 82 $3 $4 Ss S~

16 64 256 1024 4096 16384

St S2 S3 84 $5 $6

25 125 625 3125 15625 78125

r,,

r,,

r,'

r/

8 17 33 40 44 24

9 18 12 12 9 6

8 12 9 6 4 2

6 4 4 3 2 1

16 60 200 640 1636 4128

15 50 160 409 1032 2340

16 48 36 32 52 48

15 36 29 28 32 27

12 9 8 13 12 10

25 120 535 2325 8810 32980

24 107 465 1762 6596 t

25 100 80 95 100 80

20 80 67 72 62 73

20 16 19 20 16 18

n=4 2 3 4 5 6 7 n=5 2 3 4 5 6 7

tThe complementation process remained incomplete even m the maximum available computer storage.

plementation of a Boolean function without removal of redundant terms. This is much less than the n k limit. Further investigation of the values of parameters with intermediate ORCHEK reveals that the parameter values do not explode (unlike the case when no intermediate ORCHEK is carried out) but rather remain within reasonable bounds during the intermediate steps. Again from the data set of Table 1 and for n = 4 M a x i m u m [T~pt6~l = 52

Maximum IT/bl~t = 36 Maximum

Ir/IL,

= 13.

These indicate that for n = 4 and k up to 7, no more than 36(T,.b) terms are generated, and hence need to be stored in practice during the intermediate stages; (and that the final answer T! will have less than or up to 13 terms). Therefore, an essential conclusion that can be drawn from the preceding analysis is that, it is imperative to perform the intermediate ORCHEK to keep the amount of storage requirements within reasonable limits, because this is a direct function of the maximum number of generated terms that need to be stored. This would also reduce the computer run time. A relative comparison of average run times to perform the complementation process for various values of n and k is given in Table 2. One last comment about the generated terms 7"/in the final answer. It may be found that sometimes 7"/> (2"-k) whereas from a switching theory point of view T ! _ (2"-k). This is due to the limitation of the C-CAT algorithm which implements only the first three identities given in Section 1, the reason for which is given by Bennetts [2]. PART B 3. DATA MANIPULATION IN LOGICAL MULTIPLICATION AND ADDITION

During the logical multiplication and addition operations, a certain amount of data reduction depending upon the Boolean functions can be expected. Discussions and results of Section 2 give an estimate of such reductions during the complementation of a function. These values are, however, for a specific case where one of the two functions to be logically multiplied at each step, consists of single literal terms.

120

N.K. NANDAand R. G. BENNETTS

Table 2. Average relative computer run-time with and without intermediate ORCHEK. The units of run time are the Notional seconds on ICL 1907

3 4 5 6 7

Number of variables = 3

Number of variables = 4

Number of variables = 3

2.8 3.6 4.3 4.6 5.9

4.3 5.7 7.0 8.5 10.6

6.4 9.3 12.7 16.7 20.7

2.8 3.6 5.0 6.8 9.0

4.7 9.9 23.3 53.0 103.0

8.1 26.5 95.3 201.0 217#

tThe complementation process remained incomplete even at the maximum available store and until then it had required run time given in the table.

Table 3. List of the circuits used in the statistical analysis Circuit type 1

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

SN7445 SN74153 SNS74157 SN74156 SN74154 SN7482 SN74280 SN74183 SN7483 SN7485 SN74138 SN74148 SN74182 SN74152 SN74181

No. of input variables Amar and Condulmari circuitt 4 bit parallel addert Binary coded Base-3 addert 55 Input 7 output MSI Packt Minimum multiple redundancy circuit~ BCDEC to decimal decoder§ Dual 4-to-I multiplexer§ Dual 2-to-I multiplexer§ Dual 2-1ine-to-4-1ine decoder§ 4-line-to-16-line decoder/demultiplexer§ 2-Bit binary full adder§ 9-Bit odd/even parity generator§ Dual carry save full adder§ 4-Bit binary full adder§ 4-Bit magnitude comparator§ 3-to-8 decoder/demultiplexer§ 8-1ine-to-3-1ine parity encoders§ Look ahead carry generator§ 8-to-1 multiplexer§ Arithmetic logic unit§

15 11 5 55 7 4 12 10 6 6 5 9 3 9 11 6 9 9 11 15

tTaken from R. G. Bennetts, Computer aided generation of test sequences for logical systems. Ph.D. Thesis, Department of Electronics, University of Southampton (1973). $IEEE Trans. Comput. C-23, 1070 (1974). §The TTL Data Book for Design Engineers, Texas Instruments (1973).

In order to assess the quantum of reduction involved in a general case, where the Boolean functions are not constrained to any specific form, another experiment using C-CAT programs was conducted. The programs transform the structural description of a combinational logic circuit into reduced equivalent Boolean expressions, which describe the input/output behaviour of the circuit. In mapping the circuits into equivalent expressions, the behaviour of the circuits is transformed into AND/OR operations in a Reverse Polish expression/2] which is then simplified. These logic operations can be performed at any stage in the program depending upon the placement of logic gates in the circuit. ORCHEK will be applied independently whenever an OR operator corresponding to an OR gate in the circuit appears in the Reverse Polish expression. Otherwise it will always follow MULTIPLY corresponding to AND gates in the circuit. The reductions involved with ORCHEK are a measure of the removal of redundant data. The data for the experiment consisted of 20 combinational circuits commonly used in logic design and are listed in Table 3. These circuits altogether involved 372 logical multiplication and 899 logical addition samples in the process of equation generations. The range of terms in the functions that were encountered, varied from 2-200 for logical multiplication and 2--400 for logical addition. The details of the experimental results of multiplication and addition are given in the following sections.

On data manipulationof Booleanfunctions 3.1

121

Experimental results for logical multiplication

Of the 372 samples for logical multiplication, 230 exhibited 0% reduction. The remaining 142 samples have varying amounts of reduction distributed over 5% range intervals and are given in Table 4. The statistics indicate that amongst the samples that do have reduction, the reduction is mainly centred around 10-35% and that very few samples have a reduction of more than 55%. StatisticaYf analysis was performed to determine the average reduction during the logical multiplication. L e t / ~ u represent this average reduction. For the statistical distribution of Table 4, the value of t~u is around 11% and 95% confidence limit is around 2%. The confidence interval of the statistical experiment is 1 1 % - 2%, i.e. 9%--13%. Therefore, average reduction due to logical multiplication is between 9% and 13% for the samples that have been considered. 3.2

Experimental results for logical addition

Out of a total of 899 samples only 189 have reduction of some order. The distribution of 189 samples over 5% reduction interval is given in Table 5. Unlike the reduction distribution in the previous section, the distribution of samples for logical addition peaks around 50-55% reduction. For about 55% of the samples that do have reduction, the quantum of reduction is more than 50%. Table 5. Logicaladditionstatistics Number of samplesconsidered= 899 Numberof sampleswhich have reduction= 189 Let x be the % reduction. The distribution of sampleshavingreductionis:

Table 4. Logicalmultiplicationstatistics Number of samples considered= 372 Number of samples which have reduction= 142 Lex x he the % reduction.The distribution of samples havingreductionis: Range of % reduction 0 O
Range of % reduction

No. of % no. of s a m p l e s samples 230 3 6 36 3 18 25 20 0 3 1 16 2 0 3 2 0 4

0 0 < x -<5 5
61.80 0.80 1.60 9.67 0.80 4.83 6.72 5.73 -0.80 0.26 4.30 0.54 -0.80 0.54 -1.08

No. of % no. of s a m p l e s samples 710 2 1 7 4 10 13 25 5 12 3 69 15 5 6 2 6 2 2

79.00 0.22 0.11 0.78 0.44 1.10 1.44 2.78 0.55 1.33 0.33 7.67 1.76 0.55 0.66 0.22 0.67 0.22 0.22

tLet N, represent the numberof samples associated with the meanvalue/x, of the reductionintervalchosen, then the mean reduction/~ over all the samples N is givenby #=

~x#~ ~N

'

The samplevarianceis definedby 0-2

/

where ¢ is the standard deviation.The standard formulafor 95% confidenceintervalfor N is [4]

where o-/~/N is the standard error.

122

N.K. NAND^ and R. G. BENNETI'S

3.3 G e n e r a l c o m m e n t s In Sections 3.1 and 3.2 reduction due to logical multiplication and addition have been considered based upon experimental results. Consider two functions of m and p terms that are logically multiplied. Then theoretically the product function should consist at worst of m p terms. To remove redundant terms from this function a maximum of rap(rap - 1) iterations will be required. (More usually the terms of the resultant function are pre-ordered according to their cardinalities before removal of redundant terms. This rearrangement of terms will require a maximum of [rap(rap - 1)/2] iterations amongst the m p terms. A maximum of [rap(rap - 1)/2] iterations would then be necessary to remove the redundant terms from amongst the ordered m p terms. The two steps add up to a maximum of m p ( m p - 1) iterations). The question arises; does the number of iterations ever approach this limit? The answer is, very unlikely, because the number of iterations are very much data and implementation dependent. The implementation would normally be considered because once a redundant term is found, it is not necessary to consider it for subsequent comparisons and the set of terms to be compared for other redundant terms is thereby reduced. Furthermore, the maximum number of rap(rap - 1) iterations will be performed if and only if (i) there is no reduction during logical multiplication, and (ii) no redundant terms are generated. The probability of both these conditions is dependent upon the ratio of terms m and p to 2n possible terms for the function of n variables and, furthermore, the variables in both the constituent functions should be partitioned into two groups, such that, if a variable is present in an uncomplemented form in one function, it should not be present in a complemented form in the other function. Such a possibility though not unlikely would make the function too restrictive. The practical limits, therefore, in general would be less than the theoretical maximum and the average reductions have been demonstrated to be 1I% for logical multiplication and 9.6% for logical addition. Nevertheless, one thing is obvious; that about 35% of the logical multiplication samples and 22% of the logical addition samples do have a reduction of some order. This will obviously reflect on the number of iterations to be performed, both during the pre-ordering as well as the removal of redundant terms. 4. CONCLUSIONS The problem of data manipulation in Boolean functions has been approached from an experimental point of view in both Part A and B. The results obtained strongly suggest that the maximum theoretical limits of data generated would probably not be reached. One might argue; why not approach the problem from a theoretical angle? The answer is that an attack on such a problem by theoretical analysis is not a trivial task because of the number of degrees of freedom involved; such as order of appearance of the terms, choice of polarity of literals, number of literals in complemented and uncomplemented forms, interterm relationships between the literals of terms etc. All these factors make the problem highly data dependent. It is precisely for these reasons that the problem of data manipulation was considered on an experimental basis. Acknowledgement--One of the authorswouldlike to expresshis thanksto the Associationof CommonwealthUniversities for providingfinancialassistance.

REFERENCES 1. N. K. Nanda, Applicationof Boolean differenceconcept to fault diagnosis. Ph.D. Thesis, Dept. of Electronics, Universityof Southampton,England,Nov. (1977). 2. R. G. Bennetts,On the analysisof fault-trees.IEEE Trans. R-24, 175-185(1975). 3. R. G. Bennetts, Combinationalcircuit analysis and testing (C-CAT). A suite of programs available at Dept. of Electronics,Universityof Southampton,England. 4. P. G. Hoel,Elementary Statistics. Wiley,New York(1967).