Next Article in Journal
Development of a Passive Prosthetic Hand That Restores Finger Movements Made by Additive Manufacturing
Previous Article in Journal
Paraphrase Identification with Lexical, Syntactic and Sentential Encodings
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Reversible Circuit Synthesis Time Reduction Based on Subtree-Circuit Mapping

Faculty of Engineering and Information Technology, Information and Computer Science Department, An-Najah National University, PO Box 7, Nablus, Palestine
*
Author to whom correspondence should be addressed.
Appl. Sci. 2020, 10(12), 4147; https://doi.org/10.3390/app10124147
Submission received: 30 March 2020 / Revised: 11 June 2020 / Accepted: 12 June 2020 / Published: 16 June 2020
(This article belongs to the Section Quantum Science and Technology)

Abstract

:
Several works have been conducted regarding the reduction of the energy consumption in electrical circuits. Reversible circuit synthesis is considered to be one of the major efforts at reducing the amount of power consumption. The field of reversible circuit synthesis uses a large number of proposed algorithms to minimize the overall cost of circuits synthesis (represented in the line number and quantum cost), with minimal concern paid for synthesis time. However, because of the iterative nature of the synthesis optimization algorithms, synthesis time cannot be neglected as a parameter which needs to be tackled, especially for large-scale circuits which need to be realized by cascades of reversible gates. Reducing the synthesis cost can be achieved by Binary Decision Diagrams (BDDs), which are considered to be a step forward in this field. Nevertheless, the mapping of each BDD node into a cascade of reversible gates during the synthesis process is time-consuming. In this work, we implement the idea of the subtree-based mapping of BDD nodes to reversible gates instead of the classical nodal-based algorithm to effectively reduce the entire reversible circuit synthesis time. Considering Depth-First Search (DFS), we convert an entire BDD subtree in one step into a cascade of reversible gates. A look-up table for all possible combinations of subtrees and their corresponding reversible gates has been constructed, in which a hash key is used to directly access subtrees during the mapping process. This table is constructed as a result of a comprehensive study of all possible BDD subtrees and considered as a reference during the conversion process. The conducted experimental tests show a significant synthesis time reduction (around 95% on average), preserving the correctness of the algorithm in generating a circuit realizing the required Boolean function.

1. Introduction

With the continuous shrinkage of Very Large Scale Integrated (VLSI) circuits, to keep pace with the performance and small-size requirements caused by the high dependence on personal computers (PCs) in individuals’ everyday lives, transistor dimensions are approaching the atomic scale. Therefore, quantum computers are expected to drive forward the advances in VLSI technology in the foreseeable future [1].
Quantum computations are inherently reversible; that is, it is possible to obtain the input vector from an output vector, and vice-versa. With such reversible computations, the number of input bits equals the number of outputs bits, and thus there is no information loss. This loss of information is one of the main sources of energy loss in circuits. The reversible computation avoids bit destruction and thus saves heat loss. Experiments have shown that energy loss can be reduced or even eliminated if computation does not lose information; i.e., if a computation is reversible. Reversible circuits can be built using reversible gates. Reversible logic computations can be easily applied to the field of quantum computing due to its natural reversibility in computations [2]. In this way, low power design requirements for VLSI chips are achieved [3,4].
Restrictions on the structure of the reversible circuits cause the process of its synthesis to differ significantly from synthesis using traditional irreversible gates. Mainly, fan out and feedback are not allowed; in addition, the input and output bits must be the same, and additional input and output lines might therefore be required to achieve reversibility of computation. Additional inputs are known as constant lines, whereas additional outputs are known as garbage lines [5].
Reversible circuit synthesis has been proposed using numerous algorithms and techniques, each of which improves the synthesis process in terms of speed and optimization [5]. The Boolean function and its companion truth table were the basis for set of these works in the process of synthesizing reversible circuits. However, the Binary Decision Diagram (BDD) forms the basis for other works, in which a reduction in both the time of the synthesis process and the size of the generated reversible circuit is obtained. These works emphasize the BDD size reduction in order to minimize the reversible circuit size, and they were based on the direct mapping between BDD nodes and the corresponding reversible gates in the process of reversible circuit synthesis. Due to the sequential process of this kind of mapping, the one-to-one mapping process consumes some time [6].
In this work, which is an extension of the work presented in [7], we deeply investigate and work on all details related to the idea proposed in the mentioned work as well as implementing the subtree-based mapping of BDD nodes to reversible gates, minimizing the synthesis time of reversible circuits, instead of using nodal-based mapping.
Our contributions can be summarized as follows: (1) Pre-prepared and well-studied combinations of all possible subtrees were created to form a look-up table that maps each possible subtree with its corresponding reversible gates. (2) Suitable hash keys were developed for all investigated possible subtrees in order to make the retrieval time of the corresponding reversible gates constant during the traversal time of a given BDD. (3) We traverse a given BDD (with an inherent Depth-First Search) and convert all its composing subtrees to their suitable reversible gates, forming a complete reversible circuit. (4) A subtree identification algorithm is developed to be used during the traversal time of the BDD subtree. This algorithm investigates a given subtree and constructs a suitable hashing key to be used to directly retrieve the subtree’s corresponding reversible gates from the look-up table. (5) More details were added in this work to extensively illustrate the idea presented in the previous work. These details were supported by suitable mathematical formulas and flowcharts. (6) In a previous work, we proposed the idea of minimizing synthesis time, but we did not mention where our work should be considered in the process of converting a Boolean function to a complete working reversible circuit. Here, we illustrated where our work is situated in terms of the steps of the conversion process. (7) A complete code is developed in order to test the work and measure the difference between nodal and subtree-based mapping. (8) Experimental tests were conducted to measure the accurate time of mapping in both nodal and subtree-based cases.
After introducing the work in this section, Section 2 provides several previous works related to the field. In Section 3, we detail some preliminary information about reversible circuits, while Section 4 illustrates their synthesis process. Section 5 discusses the time reduction methodology of the synthesis process. Experimental tests were conducted in Section 6, and finally, the conclusion of the work is presented in Section 7.

2. Related Work

The creation of algorithms that are capable of producing smaller circuits has been the dominant goal of the literature in this field in recent years. We can easily find papers related to the optimization of the process of reversible circuit synthesis. Synthesis time reduction appears as a secondary goal.
Some works have used heuristic algorithms to try to find the best possible solution. For example, the work presented in [8] introduces a synthesis algorithm that uses Covering Set Partitions (CSP), with no garbage bits. Their work is based on mathematical properties of binary numbers, partially ordered sets and covering graph theory to construct input vectors that are guaranteed to converge. The CSP algorithm can be used to synthesize functions of a large number of variables (up to 30 bits) within a reasonable amount of time.
As a continuation of [8], the authors of [9] compared meta-heuristic algorithms on top of CSP algorithms. Restricted truth tables orders were explored by meta-heuristic algorithms. Genetic and Tabu searches were compared in the work, which also showed that both approaches outperform the typical random search. Quantum cost was used to compare algorithms, which was represented by the number of logical gates.
The authors of the work published in [3] tried to minimize the search space size of the solutions representing feasible reversible circuits by selectively generating permutations for a binary function representing some reversible circuit. Moreover, an Adaptive Genetic Algorithm (AGA) for synthesizing reversible circuits was proposed. The proposed algorithm is fed with a reversible specification of a given circuit and then produces a cascade of Toffoli gates. Several benchmark circuits were tested, and the experimental results showed that the proposed evolutionary algorithm enables optimal or near-optimal solutions with lesser gate counts.
Many recent works have used BDD to synthesize reversible circuits. BDD is a compact data structure that replaces truth tables in the process of building a reversible circuit. Converting binary functions to BDDs before building circuits opens the possibility of using new optimization techniques.
The work presented in [10] is related to the description and evaluation of how optimization techniques for decision diagrams can be exploited for the BDD-based synthesis of reversible and quantum logic. The authors of the work considered shared nodes, complement edges and ordering strategies and presented the gate cascades needed to support these methods. The effect of these techniques on the circuit sizes has been evaluated. The authors found that the BDD optimizations also led to improvements in the circuit sizes.
The effect of intermediate representations on different graph-based methods, such as BDD, inverter graphs and majority inverter graphs, in terms of their usability in making efficient circuit realizations is presented in the work of [11]. Three representations for huge binary functions were compared in this work, and the authors found that BDD is better for small functions due to the compact circuits it generates compared with the other two representations, which showed better improvements in cost compared with BDD with a cost reduction reaching 39% on average. However, effective BDD reordering is not considered in this work.
In the work presented in [12], the impact of different BDD reordering algorithms on the quantum cost of the synthesized reversible circuits was evaluated. This includes greedy, dynamic programming and meta-heuristic based reordering algorithms (Genetic and Simulated Annealing). The experimental results showed that meta-heuristic algorithms present a great deal of evidence for reducing the cost of a synthesized circuit, due to their effective exploration/exploitation in finding the near-optimal BDD size, which was found to be small-sized circuits.
The work conducted in [6] is related to the huge BDD sizes generated from complicated Boolean functions (more than 100 variables). A methodology to derive reversible circuits for a function by a given BDD is proposed in this work. The algorithm used to synthesize the reversible circuits exhibits linear behavior in terms of run-time and space features. Moreover, the BDD size affects the size of the resulting reversible circuit as it transfers the theoretical results known from BDDs to reversible circuits. However, the conducted experimental tests exhibited in better results (circuit cost) and significantly better scalability in comparison to previous synthesis approaches. A set of works have also been conducted regarding the consideration of all possible subtrees of a binary tree. The work presented in [13] is related to the analysis of the total number of subtrees of a tree. The authors of the work studied the number of possible subtrees in a given tree and the characterized set of factors that maximize/minimize the number of subtrees. However, the authors of the work presented in [14] developed algorithms to mine frequent subtrees from a database of rooted trees. They evaluated the use of two popular sequential encodings of trees to systematically generate and evaluate the candidate patterns. Experimental evaluation showed that their algorithms can achieve up to several orders of magnitude of increased speed for real data-sets when compared to state-of-the-art tree mining algorithms. However, the effectiveness of this algorithm has not been confirmed in the field of reversible circuit synthesis.
Although all of the previous works are related to minimizing the synthesis cost, the work of [15] is related to synthesizing exact minimal reversible circuits for various types of gates and costs. They used the algebraic software GAP to reduce reversible logic synthesis problems. Their group-related algorithm was applied to Peres gates and showed a better performance than for Toffoli gates in the process of increasing the speed of the synthesis of reversible circuits. However, Toffoli gates are simpler to use for manufacturing reversible circuits.
This work is considered to be a continuation of a previous work published in [7]. In that work, we proposed an algorithm to minimize the synthesis time of reversible circuits based on the consideration of subtrees instead of nodal-based mapping between BDD and reversible circuits. In this work, the proposed algorithm is implemented and tested to demonstrate the performance of the proposed algorithm in achieving a significant reduction in the synthesis time while preserving the correctness of the synthesized circuit.

3. Preliminaries and Basic Definitions

The basic logical gates are not reversible by their nature (an exception is the case of a NOT gate). For example, considering AND and OR gates, it is impossible to determine the two input bits from the output one (in the case of AND, the output 0 comes from the inputs 00 or 10 or 01, while for OR, the output 1 comes from the input 11 or 10 and 01). However, the opposite is true with reversible gates: it is easy to determine the input bits from the output and vice versa because the mapping between the input and output vectors is always one-to-one. A reversible gate can be represented by a reversible function with n-bit data for both input and output, where n-bit data are a sequence of bits x 1 , x 2 , , x n of length n in which the mapping is bijective function on the set ( 0 , 1 ) n of n-bit data on itself [16].
The development of reversible gates and circuits started after Toffoli proposed reversible logic gates in 1977, where a unique input/output association was preserved [17]. Several reversible gates have been proposed, such as NOT, Feynman, Toffoli, Fredkin and Swap gates.
Of the previous circuits, the Toffoli gate became the most important of the reversible gates due to its simplicity of structure. Most of the related works depend on the Toffoli gate in their attempts to optimize reversible circuit synthesis. In this work—as before—we used this gate in our proposal and experiments. The Toffoli gate is a gate with a size of n × n , where the target line flips when all control lines are set to 1; otherwise, the target line signal remains the same. Figure 1 shows a block diagram and schematic representation of a 3 × 3 Toffoli gate [18] where A and B represent control lines and C represents the target line.
Table 1 represents the truth table that reflects the implementation of theToffoli gate, where values of A, B (control lines) and C (target line) are inputs while P, Q, and R are the outputs.
The following provides a brief description of the basic terminology behind reversible circuit synthesis in addition to a formulation for its cost metrics [19].
A reversible n n function f : B n B n is used such that B { 0 , 1 } is a bijective mapping of every n-bit input vector into an n-bit output vector and any input pattern maps to a unique output pattern. In other words, the output of a reversible function is a permutation of the set of inputs.
Let g be a logic gate that realizes a Boolean function f with n inputs and k outputs. If the function f is reversible, such that n = k with bijective mapping between input and output vectors, the logic gate g is said to be reversible. Notice that additional inputs and/or outputs might be required to be added to make a function f reversible.
A reversible circuit G = ( g 0 , g 1 , · , g d 1 ) is a cascade of reversible gates that realize some reversible function. An irreversible function can be embedded in a reversible circuit by adding constant inputs and garbage outputs, as shown in Figure 2, which represents a reversible full adder circuit to find the summation of three input bits ( x , y , C in ) with the sum output s u m and carry out C out . Notice that a constant input of 0 has been added with two garbage (“don’t care”) outputs.
Synthesizing a reversible circuit forms the first step in the design of quantum circuit since the latter is inherently reversible. The reversible gate is mapped into the equivalent functionality in terms of quantum gates. Thereafter, this quantum circuit undergoes an additional procedure to satisfy the required physical constraints and noise elimination. Finally, the quantum circuit undergoes the testing phase [20]. The effort needed to transform a given reversible gate into a set of quantum gates is called the quantum cost, which represents the number of elementary quantum operations needed to realize that reversible gate [21]. This metric is a key concern in the design of quantum circuits. Therefore, it has been used in this paper as an evaluation criterion for the synthesized reversible circuits.

4. BDD-Based Synthesis of Reversible Circuits

Designing reliable and dependable systems that consume minimal amounts of power and energy is considered to be an important challenge to tackle now and in the near future. This can be done by arranging the reversible logical gates in a way that causes the synthesized circuit to transmit signals with high integrity. A set of heuristics for a smart method of reversible logic synthesis has to be met in the process of synthesizing reversible circuits. The following considerations are examples of those that have to be considered by the synthesizing algorithms: (1) the minimization of the output gates or subgates as far as possible; (2) the reuse of these outputs as inputs to other gates; (3) the minimization of garbage signals; (4) the minimization of constants at the inputs of the gates; (5) the creation of an acyclic resulting circuit; and (6) the algorithm must be circuit size-independent and be possible to apply generally [22].
Since fan-out is not permitted, a reversible logic circuit can realize the inverse specification simply by applying the gates in the reverse order. Thus, synthesis can be carried out from the inputs toward the outputs or from the outputs toward the inputs. The literature provides us with a large number of technologies which have been used to synthesize reversible circuits, where both circuit size and synthesis time are of a great consideration. Some of these methods depend on the truth table of a given function as the origin of the synthesis process, while others start from BDD: composition methods, decomposition methods, EXOR logic based methods, genetic algorithms, search methods, group-theoretic methods, the synthesis of regular structures such as nets, lattices, and RPGAs, spectral techniques, exhaustive search and Binary Decision Diagram (BDD)-based methods in which a Boolean function can be represented by BDD [23].
A Binary Decision Diagram (BDD) is a data structure that is used to represent a Boolean function (following Shannon decomposition). It is a directed acyclic graph G ( V , E ) with a set of nodes where a given node v V is either a leaf (with values 0 or 1) or a non-terminal node. The latter node is labeled with one of the input variables of the Boolean function, where Shannon decomposition is applied following Equation (1), where x i and x i ¯ represent a Boolean variable and its complement, respectively. f represents the Boolean function (represented by BDD), f x i represents the value of the function f when x i = 1 and f x i ¯ represents the value of the function f when x i = 0 [24].
f = x i ¯ f x i ¯ + x i f x i
As an example, Figure 3 illustrates the BDD for the Boolean function f ( x 1 , x 2 , x 3 ) = x 1 x 2 · x 3 , where the symbol ⊕ reflects the XOR bitwise operation. However, each path in the BDD starting from the root node until some leaf represents one of the rows in the truth table of the given function represented by the BDD. For example, if we traverse the leftmost path in the graph, we see that the output of the input vector 110 equals 1 where the input vector is x 1 x 2 x 3 .
The size of a BDD is related to the number of the internal nodes it contains (the non-terminal ones). For example, the size of the BDD shown in Figure 3 equals 5. However, in order to reduce the size of the BDD, some reduction rules can be applied without altering its fidelity in representing the required Boolean function. Such rules include shared nodes, complemented edges and BDD node reordering. Notice that BDD reordering should be accompanied by reduction rules to effectively reduce its size. Therefore, both exact and heuristic approaches have been proposed to find the optimal or near-optimal order of the variables in the BDD [26].
The BDD-based algorithm of reversible circuit synthesis implemented in [27] is shown in Figure 4. First of all, the BDD of the input Boolean function is constructed; thereafter, an iterative BDD reordering algorithm followed by the application of BDD reduction rules is applied. Once a small-sized BDD is generated, it undergoes the mapping phase (which is the core of our work), where each node is substituted by a cascade of Toffoli gates following a pre-constructed look-up table. Finally, the synthesized reversible circuit that realizes the input Boolean function is outputted from this algorithm.
In the mapping phase, the BDD is traversed in a Depth-First Search (DFS) fashion, such that each node is substituted into a cascade of reversible gates. The algorithm investigates all variations of BDD nodes and maps each node to its corresponding reversible gates according to a previously prepared look-up table, as shown in Table 2 below. However, this process is a principal contributor to the entire synthesis time due to its linear relation with the number of nodes in the BDD.

5. Synthesis Time Reduction

Reducing the time required for synthesizing reversible circuits is essential to reduce the turnaround time for each reversible chip. Most works related to reversible circuit BDD-based synthesis are related to minimizing the quantum cost for a circuit through reversible circuit size minimization; only a minority of works considered the time consumed in the synthesis process [15]. However, the size of the BDD and the size of its resulting circuit depends mainly on the ordering of the corresponding BDD nodes. However, a smaller size of the reversible circuit is not guaranteed by a smaller size of the BDD. Therefore, BDD-based synthesis algorithms for reversible circuits sometimes include the mapping phase in the optimization process for BDD reordering (as shown in Figure 5) which abruptly increases the overall synthesis time [28]. Thus, it is necessary to minimize the time consumed in this mapping phase.
The one-to-one mapping between BDD nodes and their corresponding reversible gates is a time-consuming process, especially in the case of large reversible functions [27]. Because the algorithm has to traverse all nodes in the reduced BDD, the process of constructing the corresponding reversible circuit consumes a large amount of time. Instead of nodal-based mapping, our idea is to consider an entire subtree to be converted directly to a predefined set of reversible gates in the process of reversible circuit synthesis in an attempt to minimize the overall synthesis time. To develop this idea, a new look-up table has to be constructed that maps all possible subtrees to their corresponding reversible gates. This also includes altering the structure of the BDD nodes that form the parents for the considered subtrees by adding a special code to the node that represents the type of the subtree under consideration during the reduction process of the BDD. To do this, and depending on the possible nodes which appear in Table 2, all possible formations of subtrees that could be formed are studied and a new mapping table is constructed. During the traversal of a given BDD, and after studying its nodes, all subtrees are mapped to their corresponding reversible gates as they appear in the new look-up table. The following illustrates the process in detail.

5.1. Look-Up Table Construction

In this work, we implement and test the subtree considered in the process of synthesizing reversible circuits by mapping complete subtrees into their corresponding reversible gates instead of using nodal-based mapping.
Based on the works presented in [6,27], we studied all possible subtrees (35 possible different subtrees were constructed with the possibility of shared nodes) to obtain a complete look-up table of subtrees mapped to their corresponding cascaded reversible gates, taking into account all variations of leaf and non-leaf nodes. This look-up table is constructed one time only as a preprocessing stage and used whenever a circuit needs to be designed based on a BDD for some Boolean function. Each node which appears in the work presented in [6,27] and appears in Table 2 has been given a unique key starting from A to E. After forming all possible permutations of the nodes to form all possible subtrees, the investigation process studies the parent node and the two possible children nodes, taking into account the existence of 0 or 1 on both possible branches of the parent node as well as both possible branches of the two children nodes. Depending on this investigation, we assigned each possible subtree a unique key formed from the keys given to each node and converted each subtree to a set of suitable cascade reversible gates. The result of this process is a list of keys with their corresponding set of reversible gates, all of which are saved in a look-up table. Table 3 below contains two sample elements of the constructed look-up table during this pre-processing stage.
The pseudocode which appears in Listing 1 illustrates the creation of the look-up table discussed above. The code starts by identifying an empty table l o o k u p T a b l e and then invokes the method g e n e r a t e P e r m u t a t i o n s ( ) that takes A l l N o d e s as a parameter and generates all applicable permutations of nodes (thus forming different subtrees), as shown in Table 2. The reader may notice that not all nodes are able to be parents for other nodes, such as the last one in Table 2, since this node comes as a leaf only; this obviously limits the number of possible permutations. All possible node permutations (subtrees) are saved in the P e r m u t a t i o n s list as a result of executing the g e n e r a t e P e r m u t a t i o n s ( ) method. The code then continues to evolve all possible subtrees saved in the P e r m u t a t i o n s list to study each subtree and assigns it a suitable unique key by invoking the method g e n e r a t e K e y , which takes a permutation as a parameter, studies its inbounds/outbounds, parent(s) and children types in order to generate the suitable key for parameterized permutation. In the same loop, both the key and the possible permutation of nodes (subtree) are both saved inside the l o o k u p T a b l e by invoking the member method a d d that takes both k e y and p e r m u t a t i o n as parameters. Of course, the construction of the look-up table is done one time only, and used many times later on in the synthesis process.

5.2. Subtree-Based Mapping Process

In this section, we illustrate the process of the subtree-based mapping process in detail. Given an OUT file (OUT files are textual representations of the reduced BDDs that originally represent some Boolean functions, taken from the Rivkit project as testing materials for our work), we intended to construct the reduced BDD from its OUT file in order to alter the data structure of the nodes to make them suitable for the subtree-based mapping. During the BDD construction, our algorithm marks the nodes that represent the parents of all composing BDD subtrees (the marking process is simply used to update the node data structure with a suitable hash key, as mentioned above), taking into account the fact that each subtree is composed of at most three nodes (one parent and two children). During this process, our algorithm studies these subtrees, taking into account the possibilities that were previously investigated during the look.up table construction illustrated above. As a result, each parent node of the subtrees of the BDD is given a code similar to that given to the similar subtree (the key) during the construction of the look-up table. A link to each parent node is saved in a special table with its corresponding hash key. The result of this process is a table (parent table) containing links to all possible parents (with their corresponding keys) of all composing subtrees for the given BDD.
However, in this work, and because the time consumed in altering the data structure of the parental nodes is beyond the scope of this study since this alteration can be done during the reduction process of BDDs, we intended to execute the alteration process in order to make the BDD structure suitable for our subtree-based mapping process.
We therefore obtain a smaller set of nodes (parent table) as in Figure 6, where each node represents its subtree as well as its corresponding hash key; we can search for the keys of all nodes in the look-up table, and for each matched key, the algorithm adds the corresponding cascade of reversible gates and adds them to the generated reversible circuit. Figure 7 below represents the activities related to the subtree-based mapping process.
For example, Figure 6 represents the BDD for the Boolean function f ( x ) = x 1 x 2 x 3 ¯ x 4 ¯ + x 1 ¯ x 2 x 3 x 4 + x 1 x 2 ¯ x 3 x 4 ¯ + x 1 x 2 x 3 ¯ x 4 ¯ , where the dashed, numbered subtrees represent the sequence of their determination in order to convert them into suitable cascade reversible gates. Figure 8 represents the generated reversible circuit of the BDD, where the numbers 1, 2 and 3 associated with a set of reversible gates correspond to the same numbers representing the subtrees in Figure 6.
The pseudocode which appears in Listing 2 below illustrates the abstracted process of reversible circuit synthesis operation based on subtree mapping. The code starts by calling the method c o n s t r u c t P a r a n e t s T a b l e ( ) , which takes b d d as a parameter; using a Depth-First Search method, it visits all BDD nodes, and during the visit, the method decides weather the visited node is a parent for a a subtree or only one of the two children that it might have. The output of this method is the table p a r e n t s T a b l e that contains all subtree parents nodes with their keys. The keys are computed in the same way as that during the construction of the look-up table, taking into account the number of inbound and outbound links. The C o n v e r t ( ) method is then executed, which takes the parents table p a r e n t s T a b l e and l o o k u p T a b l e as parameters. The loop evolves p a r e n t s T a b l e , and for each key which appears in the table, the member method g e t G a t e s ( k e y ) on the object l o o k u p T a b l e is executed; upon a key match, the method adds the cascade of reversible gates to the g a t e s [ ] vector, where the latter is used as a parameter for the member method i n s e r t on the object c i r c u i t to add the generated gates to the constructed circuit. Finally, the object c i r c u i t is returned as a return value from the C o n v e r t method.

5.3. Algorithm Run Complexity

The basic operation of the one-to-one based algorithm is to map each BDD node to its corresponding reversible gates (previously Toffoli gates). Conventionally, the algorithm relies on a table that maps each possible case (node type) to its corresponding reversible gate. The size of the table is seven entries, as mentioned earlier. The number of times that one-to-one mapping repeats the mapping process depends on the number of BDD nodes (n). The number of the nodes n depends on the number of variables of the reversible circuit. The worst-case scenario happens when we have an irreducible BDD; in this case, the number of BDD nodes is the same as the number of nodes in a binary tree n = 2 v + 1 1 nodes, where v represents the number of variables. Thus, we can say that the worst case in the one-to-one algorithm is 2 v + 1 1 operations. The paradigm we used to reduce the algorithm complexity can be categorized as prepossessing. We first prepare a hash table that maps all the possible—up to three nodes—subtrees to their corresponding reversible gates. The preparation of the table is performed only once. The same table can be used to realize any reversible circuit. Therefore, the table can be considered as a fixed part of the algorithm. It does not depend on the input size (in our case, the number of variables). In this case, the size of the look-up table is 35 entries instead of seven entries as in the one-to-one algorithm. This addition of space usage is constant and negligible.
The BDD is divided into subtrees. As described above, each subtree is defined by its parent (or root) node. The parents are defined by starting from the bottom and skipping one level each time. This process can be viewed as creating a new tree of subtrees. The number of levels of the new tree is half of the number of levels of the original tree. The new tree is not binary. Each node on the new tree has four children. The number of resulting nodes—which is the number of subtrees—can be calculated in terms of the number of circuit variables by Equation (2), where s represents the number of subtrees and v again is the number of variables.
s = k = 0 1 2 v 4 k = 4 v + 1 2 1 4 1 = 2 v + 1 1 3
This results in a reduction of the number of searches using the subtree-based algorithm to three.
The look-up table is a hash table, and so the retrieval speed is constant; i.e., O ( 1 ) . Therefore, the entry access time using the one-to-one algorithm with seven entries is the same as the access time from the look-up table with 35 entries.

6. Experimental Tests

In order to measure the amount of time reduction by moving from one-to-one to subtree mappings, we conducted an experimental test and recorded the time expended in both approaches. In our test, we used the circuit files that come with the Revkit package (40 files) as testing data. These files contain data regarding the set of BDDs generated by the Revkit. The files contain enough information with respect to the nodes and links of sample BDDs to construct the entire BDD in computer memory. Our algorithm takes these files as an input, works on them to construct the BDD for each file, then converts these BDDs to their corresponding reversible circuits once by considering the one-to-one approach and by considering the subtree. In each approach, the running time (in microseconds) is recorded for the comparison process. The result of the run is a table containing the file name and the running times of both approaches. In order to get rid of the machine dependency and to be sure that results are accurate, we repeated the process for all files 100 times and computed the average time for each file and for each approach.
With respect to benchmark 30, the reduction time is 100% due to the huge size of the related BDD, so the difference between the one-to-one synthesis and subtree-based times is significant. Table 4 contains the collected data (the bold ones represent the most significant results), where the Quantum Cost (QC) has been found to be the same for both one-to-one and subtree-based approaches. This confirms the correctness of the proposed algorithm. Figure 9 depicts the reduction of time between the two mappings (the time values that appear in Table 4 are normalized here to achieve a better graph visualization).
Figure 10 illustrates the BDD for one of the benchmarks (Benchmark 9) and its resultant reversible circuit (Figure 11) after applying our proposed algorithm. It is very important to mention that the deeper the BDD, the more Toffoli gates are needed to realize that circuit. It is also important to mention that the source code of our algorithm, along with the benchmarks, is available in [29].

7. Conclusions

The time required for reversible circuit synthesis is crucial, especially for huge circuits or those need to be synthesized several times for optimization purposes. In this work, we studied the method of BDD subtree mapping to reversible gates instead of using the nodal-based method. A look-up table has been constructed to map different permutations of possible BDD subtrees to their corresponding cascade of reversible gates. Our algorithm and methodology were examined by experimental tests that gave interesting results. In future works, we are planning to investigate whether the existence of certain subtrees enhances the quantum cost of reversible circuits. In addition, we will consider the reduction of the time required for the performed procedures to satisfy the required physical constraints on the resultant quantum circuit, especially in terms of noise.

Author Contributions

Conceptualization, A.H., A.A. and B.A.; methodology, A.H., A.A. and B.A.; software, A.H.; validation, A.H.; formal analysis, A.H., A.A. and B.A.; investigation, A.H. and A.A.; resources, A.H.; data curation, A.H.; writing—original draft preparation, A.H.; writing—review and editing, A.H., A.A. and B.A.; visualization, A.H. and A.A.; supervision, A.H. and A.A.; project administration, A.H.; funding acquisition, A.H., A.A. and B.A. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by An-Najah National University under grant number ANN-1920-Sc006.

Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analysis, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

References

  1. Rubinstein, B.I.P. Evolving quantum circuits using genetic programming. In Proceedings of the 2001 Congress on Evolutionary Computation (IEEE Cat. No.01TH8546), Seoul, Korea, 27–30 May 2001; Volume 1, pp. 144–151. [Google Scholar] [CrossRef]
  2. Piyush Gau, T. Development of Tool for Mapping Conventional Circuit to Reversible Logic. arXiv 2014, arXiv:1407.0632. [Google Scholar]
  3. Sasamal, T.N.; Singh, A.K.; Mohan, A. Reversible Logic Circuit Synthesis and Optimization Using Adaptive Genetic Algorithm. Procedia Comput. Sci. 2015, 70, 407–413. [Google Scholar] [CrossRef] [Green Version]
  4. Landauer, R. Irreversibility and Heat Generation in the Computing Process. IBM J. Res. Dev. 1961, 5, 183–191. [Google Scholar] [CrossRef]
  5. Mohammadi, M.; Eshghi, M. Heuristic methods to use don’t cares in automated design of reversible and quantum logic circuits. Quantum Inf. Process. 2008, 7, 175–192. [Google Scholar] [CrossRef]
  6. Wille, R.; Drechsler, R. BDD-based Synthesis of Reversible Logic for Large Functions. In Proceedings of the 46th Annual Design Automation Conference, DAC ’09, San Francisco, CA, USA, 26–31 July 2009; ACM: New York, NY, USA, 2009; pp. 270–275. [Google Scholar] [CrossRef] [Green Version]
  7. Hawash, A.; Awad, A.; Abdalhaq, B. Towards Reducing Reversible Circuit Synthesis Time. In Proceedings of the 2019 IEEE Jordan International Joint Conference on Electrical Engineering and Information Technology (JEEIT), Amman, Jordan, 9–11 April 2019; pp. 538–543. [Google Scholar] [CrossRef]
  8. Hawash, M.; Perkowski, M.; Bleiler, S.; Caughman, J.; Hawash, A. Reversible Function Synthesis of Large Reversible Functions with No Ancillary Bits Using Covering Set Partitions. In Proceedings of the 2011 Eighth International Conference on Information Technology: New Generations, Las Vegas, NV, USA, 11–13 April 2011; pp. 1008–1013. [Google Scholar] [CrossRef]
  9. Hawash, M.; Abdalhaq, B.; Hawash, A.; Perkowski, M. Application of Genetic Algorithm for Synthesis of Large Reversible Circuits using Covered Set Partitions. In Proceedings of the Fourth IEEE International Symposium on Innovation in Information Communication Technology (ISIICT 2011), Amman, Jordan, 29 November–1 December 2011; Volume 1. [Google Scholar]
  10. Wille, R.; Drechsler, R. Effect of BDD Optimization on Synthesis of Reversible and Quantum Logic. Electr. Notes Theor. Comput. Sci 2010, 253, 57–70. [Google Scholar] [CrossRef] [Green Version]
  11. Biswal, L.; Das, R.; Bandyopadhyay, C.; Chattopadhyay, A.; Rahaman, H. A template-based technique for efficient Clifford+T-based quantum circuit implementation. Microelectron. J. 2018, 81, 58–68. [Google Scholar] [CrossRef]
  12. Awad, A.; Abdalhaq, B.; Hawash, A.; Johnson, D. A Comparative Analysis of Binary Decision Diagram Reordering Algorithms for Reversible Circuit Synthesis. In Proceedings of the 2018 IEEE Symposium Series on Computational Intelligence (SSCI), Bangalore, India, 18–21 November 2018; pp. 104–111. [Google Scholar] [CrossRef]
  13. Li, S.; Wang, S. Further analysis on the total number of subtrees of trees. arXiv 2012, arXiv:1204.6152. [Google Scholar] [CrossRef]
  14. Tatikonda, S.; Parthasarathy, S.; Kurc, T. TRIPS and TIDES: New Algorithms for Tree Mining. In Proceedings of the 15th ACM International Conference on Information and Knowledge Management, CIKM ’06, Arlington, VA, USA, 6–11 November 2006; Association for Computing Machinery: New York, NY, USA, 2006; pp. 455–464. [Google Scholar] [CrossRef]
  15. Yang, G.; Song, X.; Hung, W.N.N.; Perkowski, M.A. Fast synthesis of exact minimal reversible circuits using group theory. In Proceedings of the ASP-DAC 2005. Asia and South Pacific Design Automation Conference, Los Angeles, CA, USA, 23–25 January 2005; Volume 2, pp. 1002–1005. [Google Scholar] [CrossRef] [Green Version]
  16. Mia, M.; Mukib, M.; Islam, M. An Extended Review on Reversible Logic Gates and their Implementation. Int. J. Latest Eng. Res. Appl. 2015, 1, 8–18. [Google Scholar]
  17. Sarvaghad-Moghaddam, M.; Orouji, A.A. A new design and simulation of reversible gates in quantum-dot cellular automata technology. arXiv 2018, arXiv:1803.11017. [Google Scholar]
  18. Monz, T.; Kim, K.; Hänsel, W.; Riebe, M.; Villar, A.S.; Schindler, P.; Chwalla, M.; Hennrich, M.; Blatt, R. Realization of the Quantum Toffoli Gate with Trapped Ions. Phys. Rev. Lett. 2009, 102, 040501. [Google Scholar] [CrossRef] [PubMed]
  19. Kanth, B.R.; Krishna, B.M.; Sridhar, M.; Swaroop, V.G.S. A distinguish between reversible and conventional logic gates. CiteSeerX 2012. [Google Scholar]
  20. Wille, R.; Chattopadhyay, A.; Drechsler, R. From reversible logic to quantum circuits: Logic design for an emerging technology. In Proceedings of the 2016 International Conference on Embedded Computer Systems: Architectures, Modeling and Simulation (SAMOS), Samos, Greece, 17–21 July 2016; pp. 268–274. [Google Scholar]
  21. Podlaski, K. Reversible circuit synthesis Using Binary Decision Diagrams. In Proceedings of the 2016 MIXDES-23rd International Conference Mixed Design of Integrated Circuits and Systems, Łódź, Poland, 23–15 June 2016; pp. 235–238. [Google Scholar] [CrossRef]
  22. Taha, S. Reversible Logic Synthesis Methodologies with Application to Quantum Computing, 1st ed.; Springer: Berlin, Germany, 2016. [Google Scholar] [CrossRef]
  23. Yang, C.; Singhal, V.; Ciesielski, M. BDD Decomposition for Efficient Logic Synthesis; IEEE: Piscataway, NJ, USA, 1999; pp. 626–631. [Google Scholar] [CrossRef] [Green Version]
  24. Gerez, S.H. Algorithms for VLSI Design Automation, 1st ed.; John Wiley & Sons, Inc.: New York, NY, USA, 1999. [Google Scholar]
  25. Wille, R.; Drechsler, R. Towards a Design Flow for Reversible Logic; Springer: Berlin, Germany, 2010; pp. 1–184. [Google Scholar]
  26. Brace, K.S.; Rudell, R.L.; Bryant, R.E. Efficient Implementation of a BDD Package. In Proceedings of the 27th ACM/IEEE Design Automation Conference, DAC ’90, San Diego, CA, USA, 24–28 June 1990; ACM: New York, NY, USA, 1990; pp. 40–45. [Google Scholar] [CrossRef]
  27. Drechsler, R.; Wille, R. Synthesis of Reversible Circuits Using Decision Diagrams. In Proceedings of the 2012 International Symposium on Electronic System Design (ISED), Kolkata, India, 19–22 December 2012; pp. 1–5. [Google Scholar] [CrossRef] [Green Version]
  28. Patel, K.N.; Markov, I.L.; Hayes, J.P. Optimal Synthesis of Linear Reversible Circuits. Quantum Inf. Comput. 2008, 8, 282–294. [Google Scholar]
  29. Hawash, A.; Awad, A.; Abdalhaq, B. Rebersible Circuits Subtree Mapping Code. 2020. Available online: https://github.com/ahmedawad119/Reversible-Circuits (accessed on 23 May 2020).
Figure 1. Toffoli gate: block and schematic representations where ⊕ represents the target line and • represents the control lines.
Figure 1. Toffoli gate: block and schematic representations where ⊕ represents the target line and • represents the control lines.
Applsci 10 04147 g001
Figure 2. A reversible full added circuit with one constant input and two garbage outputs.
Figure 2. A reversible full added circuit with one constant input and two garbage outputs.
Applsci 10 04147 g002
Figure 3. Binary Decision Diagram (BDD) representation of the Boolean function f = x 1 x 2 · x 3 [25].
Figure 3. Binary Decision Diagram (BDD) representation of the Boolean function f = x 1 x 2 · x 3 [25].
Applsci 10 04147 g003
Figure 4. BDD-based synthesis for reversible circuits following the algorithm published in [27].
Figure 4. BDD-based synthesis for reversible circuits following the algorithm published in [27].
Applsci 10 04147 g004
Figure 5. BDD-based synthesis for reversible circuits, integrating the mapping phase in the BDD optimization process.
Figure 5. BDD-based synthesis for reversible circuits, integrating the mapping phase in the BDD optimization process.
Applsci 10 04147 g005
Figure 6. BDD representation of the Boolean function f ( x ) = x 1 x 2 x 3 ¯ x 4 ¯ + x 1 ¯ x 2 x 3 x 4 + x 1 x 2 ¯ x 3 x 4 ¯ + x 1 x 2 x 3 ¯ x 4 ¯ , where three subtrees are investigated and the construction of their suitable hash keys was performed as long as their parental nodes were identified.
Figure 6. BDD representation of the Boolean function f ( x ) = x 1 x 2 x 3 ¯ x 4 ¯ + x 1 ¯ x 2 x 3 x 4 + x 1 x 2 ¯ x 3 x 4 ¯ + x 1 x 2 x 3 ¯ x 4 ¯ , where three subtrees are investigated and the construction of their suitable hash keys was performed as long as their parental nodes were identified.
Applsci 10 04147 g006
Figure 7. Subtree-based realization of reversible circuits.
Figure 7. Subtree-based realization of reversible circuits.
Applsci 10 04147 g007
Figure 8. Generated reversible circuit constructed for the BDD in Figure 6 where 1, 1, 0 and 1 are control lines and f represents the output of the circuit. The three labels 1, 2, and 3 are related to the investigated subtrees in Figure 6.
Figure 8. Generated reversible circuit constructed for the BDD in Figure 6 where 1, 1, 0 and 1 are control lines and f represents the output of the circuit. The three labels 1, 2, and 3 are related to the investigated subtrees in Figure 6.
Applsci 10 04147 g008
Figure 9. One-to-one vs. subtree time mapping comparison.
Figure 9. One-to-one vs. subtree time mapping comparison.
Applsci 10 04147 g009
Figure 10. BDD of Benchmark 9.
Figure 10. BDD of Benchmark 9.
Applsci 10 04147 g010
Figure 11. Circuit of Benchmark 9.
Figure 11. Circuit of Benchmark 9.
Applsci 10 04147 g011
Table 1. Toffoli gate truth table.
Table 1. Toffoli gate truth table.
InputOutput
ABCPQR
000000
001001
010010
011011
100100
101101
110111
111110
Table 2. One-to-one mapping from BDD nodes to cascades of reversible gates.
Table 2. One-to-one mapping from BDD nodes to cascades of reversible gates.
NodeCircuitNodeCircuit
Applsci 10 04147 i001 Applsci 10 04147 i002 Applsci 10 04147 i003 Applsci 10 04147 i004
Applsci 10 04147 i005 Applsci 10 04147 i006 Applsci 10 04147 i007 Applsci 10 04147 i008
Applsci 10 04147 i009 Applsci 10 04147 i010 Applsci 10 04147 i011 Applsci 10 04147 i012
Applsci 10 04147 i013 Applsci 10 04147 i014
Table 3. Sample subtrees with their mapped reversible gates and assigned hash codes.
Table 3. Sample subtrees with their mapped reversible gates and assigned hash codes.
KeySubtreeCircuit
AEE Applsci 10 04147 i015 Applsci 10 04147 i016
BE Applsci 10 04147 i017 Applsci 10 04147 i018
.........
Table 4. One-to-one vs. subtree mapping time comparison.
Table 4. One-to-one vs. subtree mapping time comparison.
Benchmark ## of Variables# of NodesQuantum Cost (QC)One-to-One Average TimeSubtree Average TimeTime Reduction Rate
1629259761,446.55440.24199.28%
2814411669.58233.90297.96%
316241333625.39143.88498.78%
4711171252.96618.21298.54%
5595957.44615.45398.38%
6711171087.19917.87598.35%
761010899.32417.65698.03%
871119869.43818.08597.91%
961012889.87817.65998.01%
10815521386.82614.9598.92%
1114211091966.97715.04899.23%
121711206791.60310.57198.66%
1327362061760.4720.61298.82%
14138318209521,679.91115.899.46%
1539753412874.42423.23299.19%
161624143951.77210.36298.91%
1728321391010.01710.31298.97%
1814724120789749.40553.32999.45%
191001399625216.57738.62399.25%
20725120910,197127,494.95487.20699.61%
21111973978.8839.33399.04%
225586713064,4906,614,297.3711639.35899.97%
23562937846033,181.406195.199.41%
242384271724,511424,256.475945.05799.77%
2515721015423337.23248.13198.55%
26911189651407.76231.06197.79%
27101654274.0125.52697.98%
2839173202521.04612.9197.52%
2915223419124737.33751.01298.92%
3065,811131,0941,112,8937.33449651848 × 10818,500.089100.00%
31891016171161.14123.71597.91%
3220339433995378.02831.97897.95%
335159293687.9786.21999.40%
342226117349.1583.27399.09%
35132282260.9712.37199.06%
363750237456.6325.0899.09%
374953188429.6624.4398.88%
382743159390.9873.62598.96%
391624109288.1673.01699.07%
405369373538.9225.36698.95%
Listing 1. Look-up table construction pseudocode.
Listing 1. Look-up table construction pseudocode.
Applsci 10 04147 i021
Listing 2. Subtree-based mapping pseudocode.
Listing 2. Subtree-based mapping pseudocode.
Applsci 10 04147 i022

Share and Cite

MDPI and ACS Style

Hawash, A.; Awad, A.; Abdalhaq, B. Reversible Circuit Synthesis Time Reduction Based on Subtree-Circuit Mapping. Appl. Sci. 2020, 10, 4147. https://doi.org/10.3390/app10124147

AMA Style

Hawash A, Awad A, Abdalhaq B. Reversible Circuit Synthesis Time Reduction Based on Subtree-Circuit Mapping. Applied Sciences. 2020; 10(12):4147. https://doi.org/10.3390/app10124147

Chicago/Turabian Style

Hawash, Amjad, Ahmed Awad, and Baker Abdalhaq. 2020. "Reversible Circuit Synthesis Time Reduction Based on Subtree-Circuit Mapping" Applied Sciences 10, no. 12: 4147. https://doi.org/10.3390/app10124147

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop