Performance Evaluation of Quine-McCluskey Method On Multi-Core CPU
Performance Evaluation of Quine-McCluskey Method On Multi-Core CPU
Abstract—The Quine-McCluskey method is an algorithm to The run-time of the method also grows exponentially with the
minimize Boolean functions. Although the method can be input variable number. This slows down the process of analysis,
programmed on computers, it takes a long time to return the set design, and verification of digital logic circuits. The problem
of prime implicants, thus slowing the analysis and design of digital becomes more serious in the design of dynamic run-time
logic circuits. As a result, it slows down the dynamic reconfigurable hardware architectures or adapted hardware
reconfiguration process of programmable logic devices. In this architectures.
paper, we first propose a data representation for storing
implicants in memory to reduce the cache misses of the program. The Quine-McCluskey method consists of two steps:
We then propose an algorithm to find all prime implicants of a
Boolean function. The algorithm aims to reuse the data available Step 1: Finding all prime implicants of the Boolean function
on cache, thus decreasing cache misses. After that, we propose an Step 2: Selection of essential prime implicants that cover all
algorithm for step 2 of the Quine-McCluskey method to select the
minimal number of essential prime implicants. The evaluation the minterms of the function.
shows that our proposals achieve much higher performance than Both of the steps are memory-intensive applications since
the original Quine-McCluskey method. The number of essential they involve many repeated memory references. We believe that
prime implicants is a low percentage, less than 50%, of the total both of the steps can be accelerated on cached CPU by
prime implicants generated in step 1 of the method. exploiting the temporal and spatial data locality. The
contributions of this paper are as follows:
Keywords—Quine-McCluskey, prime implicant, multithreading,
Boolean function 1) We propose a bitarray-based data representation for
I. INTRODUCTION implicants that consume a small size of memory. This helps to
reduce the cache miss rate of the method running on the CPU.
A Boolean function is a function producing a Boolean output 2) We propose an algorithm for step 1 of the method to
by logical calculation of Boolean inputs. It is a key point in the
exploit data locality, thus minimizing the cache misses of the
analysis, design, and implementation of digital logic circuits.
Minimization of Boolean functions is to optimize the algorithm step running on the CPU.
of such functions to achieve a simpler structure of the algorithm. 3) We propose an algorithm for step 2 of the method to
Thus it simplifies the corresponding digital logic circuit. There minimize the number of required prime implicants covering all
are two popular methods to minimize Boolean functions. 1) The the minterms of the Boolean function.
Karnaugh method is based on a graphical representation of
The rest of the manuscript is organized as follows: Section
Boolean functions [1]. And 2) The Quine-McCluskey method
II discusses the related work. Section III presents the data
generates prime implicant lists using the tabulation method [2].
The method was first proposed by Quine [3, 4] and then representation of implicants. Section IV presents the proposed
improved by McCluskey. The Quine-McCluskey method is algorithms of the method. Section V shows the evaluation. The
functionally identical to the Karnaugh method. However, while conclusion is summarized in section VI.
the Karnaugh mapping is suitable to Boolean functions of a few
II. RELATED WORK
input variables, the Quine-McCluskey algorithm is dedicated to
Boolean functions with a large number of Boolean inputs [5]. Wegener et al. proved that the minimization of Boolean
Therefore, the Karnaugh method is often used in education. functions is a hard problem [7]. Prasad et al. analyzed the
Meanwhile, the Quine-McCluskey method is practically simplification of the Quine-McCluskey method for a different
employed in the analysis and design of digital logic circuits for number of product terms [8]. The complexity of the Quine-
real-world applications. McCluskey method was mathematically modelled in the
following equation [8]:
However, the computational complexity of the Quine-
McCluskey method is 𝑂(𝑁$%&' ( 𝑙𝑜𝑔, 𝑁), N - the input length [6].
Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on July 15,2023 at 18:52:57 UTC from IEEE Xplore. Restrictions apply.
61
2021 8th NAFOSTED Conference on Information and Computer Science (NICS)
Algorithm 2: Finding all prime implicants Algorithm 3: Selection of Essential Prime Implicants
1: m = # input variables 1: final-prime-list = []
2: list-1 = [minterms] 2: victim = None
3: list-x = [d-terms] 3: max-len = 1
4: implicant-list = list-1.append(list-x) 4: while max-len != 0:
5: prime-list = [] 5: max-len = 0
6: new-implicant-list = []
6: for prime in prime-list:
7: combined = True
7: prime.val-1.difference_update(victim.val-1)
8: while (combined):
8: if len(prime.val-1) > max-len:
9: combined = False
10: groups = make_groups(implicant_list) 9: max-len = len(prime.val-1)
11: for i in range(m): 10: temp = prime
12: reversed = False 11: prime-list.remove(temp)
13: for x1 in groups[i]: 12: victim = temp
14: if reversed: 13: final-prime-list.append(temp)
15: range-litst = groups[i+1].reverse()
16: else:
in Line 32. After that, the implicant-list is assigned to the new-
17: range-litst = groups[i+1]
implicant-list before going to the next round of the while loop.
18: for x2 in range-list:
19: pos = compare_2(x1, x2) B. Algorithm for Step 2: Selection of Essential Prime
20: if pos != -1: Implicants
21: combined = True In step 2 of the Quine-McCluskey method, essential prime
22: new-term = x1 implicants will be selected among the full set of prime
23: new-term[pos -1] = 1 implicants from step 1. In this step, we aim to choose the
24: new-term[pos] = 0 smallest number of prime implicants that cover all the minterms
25: x1.used = True of the Boolean function. For that perspective, we propose
26: x2.used = True Pseudo code as in Algorithm 3. After step 1 of the Quine-
27: new-implicant-list.append(new-term) McCluskey method, we have prime-list including all prime
28: reversed = not reversed implicants of the Boolean function.
29: for impl in implicant-list: • Let final-prime-list be the final list of essential prime
30: if impl.used: implicants covering all the minterms of the function.
31: implicant-list.remove(impl) • Let victim be the prime that is selected after each round of
32: prime-list.append(implicant-list) the while loop. victim is the prime implicant that is merged from
33: implicant-list = new-implicant-list the largest number of minterms.
• Let max-len be the maximum length of all minterm sets of
prime implicants.
‘1’. Therefore, there are at most m+1 groups. Implicants in • Let val-1 be the minterm set of a prime implicant.
each group are then compared with the implicants of the
consecutive group to find if they can be merged into a new In the while loop, max-len is assigned to zero in Line 5. max-
implicant as in Line 11 to Line 19. If there is any combination, len is found by iterating prime-list and comparing the length of
the variable combined is marked as True in Line 21. That means the minterm sets of all prime implicants. It is noted that after
at least one new implicant is generated, and the next round of finding out a victim in each round of the while loop, the victim
the while loop is required. At the same time, the two combined is removed from prime-list as in Line 11. Then, the minterm set
implicants are marked as used. of each prime implicants is also updated as in Line 7 before
finding max-len.
It is noted that in the first for loop, a variable named
reversed is used to indicate the third for loop should be iterated V. EVALUATION
in the reversed order or the normal order. This variable starts at
False as in Line 12. Iterating the loop in the reversed order helps Table 1 shows the experimental setup we used to evaluate
to utilize the data in cache memory that are fetched recently the proposed algorithms. In this evaluation, the number of input
from the lower-level memory before the data are replaced on variables in the Boolean function is scaled from 10 to 20. For
the k-input Boolean function, the number of possible input
the cache memory. As a result, the cache miss rate will be
decreased. That is also the key point in Algorithm 2. vectors is 2; , which evaluate to ‘0’, ‘1’, or ‘x’ – don’t care.
All the marked-as-used implicants are then removed from • Let fill-factor-1 be the ratio between the number of input
the implicant-list before the list is updated into the prime-list as vectors that evaluate to ‘1’ and the total number of input vectors
2; .
Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on July 15,2023 at 18:52:57 UTC from IEEE Xplore. Restrictions apply.
62
2021 8th NAFOSTED Conference on Information and Computer Science (NICS)
TABLE I. EVALUATION SETUP TABLE IV. EXECUTION TIME OF STEP 1 AND STEP 2 FOR DIFFERENT
FILL FACTOR
CPU Intel Core i3-7100
fill- Step 1 Step 1 (Our Step 1 Step 2
Number of cores 4 factor (Original) proposal) (Multi-
CPU operation frequency 800 MHz thread)
Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on July 15,2023 at 18:52:57 UTC from IEEE Xplore. Restrictions apply.
63
2021 8th NAFOSTED Conference on Information and Computer Science (NICS)
TABLE VI. NUMBER OF ESSENTIAL PRIME IMPLICANTS FOR DIFFERENT of prime implicants that becomes essential is quite small, less
FILL FACTOR
than 50%. This helps to reduce the hardware cost in the
fill- Minterms Primes Essential implementation of the Boolean function. In future work, we
factor primes will take into account the minimazation of multi-output
Boolean functions as well as a framework for design and
0.1 104 146 72 (49.3%) verification of Boolean functions.
0.2 205 673 106 (15.8%)
0.3 308 7,952 110 (1.4%) References
0.4 411 3,485,799 97 (0.003%) [1] M. Karnaugh, “The map method for synthesis of combinational logic
circuits,” Transactions of the American Institute of Electrical Engineers,
vol. 72 part I, pp. 593–598, 1953.
[2] E. J. McCluskey, “Minimization of boolean functions,” Bell System
TABLE VII. NUMBER OF ESSENTIAL PRIME IMPLICANTS FOR DIFFERENT Technical Journal, vol. 35, Issue 6, pp. 1417–1444, 1956.
NUMBER OF INPUT VARIABLES [3] W. V. Quine, “The problem of simplifying truth functions,” The
American Mathematical Monthly, vol. 59, no. 8, pp. 521–531,
Inputs Minterms Primes Essential Mathematical Association of America, 1952.
primes [4] W. V. Quine, “A way to simplify truth functions,” The American
Mathematical Monthly, vol. 62, no. 9, pp. 627–631, Mathematical
10 104 146 72 (49.3%) Association of America, 1955.
[5] M. Petrík, “Quine–McCluskey method for many-valued logical
15 3,278 6919 2048 (29.6%) functions,” Soft Computing, vol. 12, Issue 4, pp. 393–402, Springer-
Verlag, 2007.
20 104,857 296,035 60,682 (20.5%) [6] S. P. Tomaszewski, I. U. Celik, G. E. Antoniou, “WWW-based boolean
function minimization,” International Journal of Applied Mathematics
and Computer Science,vol. 13, no. 4, pp. 577–583, 2003.
[7] I. Wegener, “The complexity of boolean functions,” John Wiley & Sons,
C. Number of Essential Prime Implicants Inc. New York, NY, USA,1987.
Table VI and Table VII show the number of prime [8] P. W. Chandana Prasad, Azam Beg, Ashutosh Kumar Singh, “Effect of
implicants before and after step 2 of the Quine-McCluskey Quine-McCluskey simplification on boolean space complexity,” In:
Innovative Technologies in Intelligent Systems and Industrial
method. As can be seen from the tables, the number of essential Applications, CITISIA 2009, IEEE, 2009.
prime implicants achieved after step 2 decreases significantly [9] A. Dus ̧a, A. Thiem, “Enhancing the minimization of boolean and
compared to the number of prime implicants. The number of multivalue output functions with eQMC,” The Journal of Mathematical
essential prime implicants is always smaller than the number of Sociology, 39:2, pp. 92–108, 2015.
minterms and much smaller than the number of total prime [10] B. Gurunath, N.N. Biswas, “An algorithm for multiple output
implicants. Particularly, the number of essential prime minimization,” IEEE Transactions on Computer-Aided Design of
Integrated Circuits and Systems, vol. 8, Issue 9, pp. 1007–1013, IEEE,
implicants is less than 50% of the total number of prime 1989.
implicants. For the high fill factors, 0.3 and 0.4, the percentages [11] T. K. Jain, D. S. Kushwaha, A. K. Misra, “Optimization of the Quine-
are even lower than 2%, 1.4% at the fill factor 0.3 and 0.003% McCluskey method for the minimization of the boolean expressions,”
at the fill factor 0.4. Table VI reveals that the higher fill factor Fourth International Conference on Autonomic and Autonomous Systems
(ICAS’08), Gosier, 2008, pp. 165–168.
the lower percentage of total prime implicants that are essential.
[12] A. Majumder, B. Chowdhury, A. J. Mondai, K. Jain, “Investigation on
VI. CONCLUSION Quine McCluskey method: A decimal manipulation based novel approach
for the minimization of boolean function,” International Conference on
In this paper, we address the performance bottleneck of the Electronic Design, Computer Networks & Automated Verification
Quine-McCluskey method to the memory access since the (EDCAV), 2015, DOI: 10.1109/EDCAV.2015.7060531.
application is memory-intensive. We propose a bitarray-based [13] V. Siládi, T. Filo, “Quine-McCluskey algorithm on GPGPU,” In: AWER
data representation for implicants of Boolean functions and an Procedia Information Technology and Computer Science, vol. 4 3rd
World Conference on Innovation and Computer Science (INSODE-
algorithm to find all the prime implicants. The proposals exploit 2013), pp. 814–820, 2013.
the data locality of cache memories. The experimental results [14] V. Siládi, M. Povinsky, L. Trajtel, “Adapted parallel Quine-McCluskey
show that our proposal causes fewer cache load misses than the algorithm using GPGPU,” 14th International Scientific Conference on
original Quine-McCluskey method does, leading to higher Informatics, pp. 327-331, 2017.
performance. In this work, we also minimize the number of
essential prime implicants. The result shows that the percentage
Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on July 15,2023 at 18:52:57 UTC from IEEE Xplore. Restrictions apply.
64