KarNet: An Efficient Boolean Function Simplifier

Shanka Subhra Mondal, Abhilash Nandy, Ritesh Agrawal, Debashis SenarXiv 2019

Abstract

Many approaches such as Quine-McCluskey algorithm, Karnaugh map solving, Petrick's method and McBoole's method have been devised to simplify Boolean expressions in order to optimize hardware implementation of digital circuits. However, the algorithmic implementations of these methods are hard-coded and also their computation time is proportional to the number of minterms involved in the expression. In this paper, we propose KarNet, where the ability of Convolutional Neural Networks to model relationships between various cell locations and values by capturing spatial dependencies is exploited to solve Karnaugh maps. In order to do so, a Karnaugh map is represented as an image signal, where each cell is considered as a pixel. Experimental results show that the computation time of KarNet is independent of the number of minterms and is of the order of one-hundredth to one-tenth that of the rule-based methods. KarNet being a learned system is found to achieve nearly a hundred percent accuracy, precision, and recall. We train KarNet to solve four variable Karnaugh maps and also show that a similar method can be applied on Karnaugh maps with more variables. Finally, we show a way to build a fully accurate and computationally fast system using KarNet.

Introduction

In digital circuit design, simplifying Boolean expressions is critical for reducing hardware costs and power consumption. Traditionally, this is done using rule-based methods like Karnaugh maps (visual grouping) or the Quine-McCluskey algorithm (tabular search).

Karnaugh Map representations for Sum of Products (SOP) and Product of Sums (POS).

However, these methods face two major hurdles: computational complexity and variable execution time. As NP-hard problems, the time required to find the simplest form grows exponentially with the number of variables. Furthermore, in traditional algorithms, the more "minterms" (the '1s' in a truth table) present, the longer the algorithm takes to run. KarNet addresses these issues by re-framing Boolean minimization as a multi-label image classification problem, ensuring constant-time inference.

Methodology

The core innovation of KarNet is treating a 4-variable Boolean function (a 4x4 K-map grid) as a 4x4 pixel image.

Architecture and Representation

Standard CNNs typically use square filters. In contrast, KarNet employs eight different rectangular filter sizes (1x1, 1x2, 2x1, 1x4, 2x2, 4x1, 2x4, 4x2, and 4x4) specifically chosen to correspond to the legal rectangular groupings in K-map simplification.

To handle "wrap-around" logic—where K-maps are logically toroidal—the authors introduced KarNet-2. This version uses specific zero-padding on the bottom and right edges to help the network learn "edge-crossing" rectangular groups.

A K-map represented with padding to facilitate the learning of wrap-around rectangular groups.

Datasets

The model was trained and validated using several extensive datasets:

  • 4-Variable Exhaustive Set: All 65,536 possible Boolean functions.
  • 5-Variable Set: Over 51 million K-maps to test generalizability.
  • Don't Care Dataset: Over 42 million K-maps containing "Don't Care" conditions.

Ground truth labels were generated using the gold-standard Quine-McCluskey algorithm to ensure high-quality training data.

Key Results and Insights

KarNet demonstrates a significant speed advantage, performing 10 to 100 times faster than traditional rule-based methods. On the exhaustive 4-variable dataset, KarNet-2 achieved 98.09% accuracy, with precision and recall both exceeding 99%.

A key insight is that solving a K-map is essentially a pattern recognition task—finding the largest possible rectangles of 1s—which CNNs are inherently designed to handle. Furthermore, unlike search algorithms, a CNN forward pass takes the same amount of time regardless of the K-map's complexity.

To achieve 100% accuracy, the authors propose a hybrid system. KarNet handles the majority of cases, while a small "look-up table" stores known failure cases. If a K-map is in this list, the system falls back to Quine-McCluskey, maintaining massive speed gains for the vast majority of inputs.

Conclusion and Future Work

While KarNet shows great promise, scaling to more variables increases the number of output classes and training data requirements significantly. Future work involves extending the architecture to larger variable sets and further refining the hybrid system to minimize the size of the error look-up table.

Summary updated

BibTeX
@misc{mondal2019karnet,
  author = {Shanka Subhra Mondal and Abhilash Nandy and Ritesh Agrawal and Debashis Sen},
  title = {{KarNet: An Efficient Boolean Function Simplifier}},
  year = {2019},
  eprint = {1906.01363},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1906.01363},
}
Figure