1 Introduction

Conventional CMOS circuits have recently faced some challenges especially in nanoscale such as short channel effects, reduced gate controllability, and high leakage current density. The introduction of nanoscale devices such as nanomagnet logic (NML) has led to a promising solution for dealing with these challenges and difficulties [1, 2]. NML is based on the field-coupled nanocomputing principle that uses bistable and single-domain nanomagnets for storing, processing, and transferring data. Due to the magnetic nature of this emerging technology, NML circuits have very low power consumption [3, 4]. Moreover logic and memory can be combined with each other in the same device [5]. In addition, their high resistance to radiation and heat also makes them suitable for the employment in harsh operating environments [6, 7]. Finally, these circuits can operate at room temperature because of their relatively large magnetic energies [8]. Due to these special advantages, NML could be considered as an alternative or a complementary logic device to the customary CMOS technology.

NML circuits, like many other nanoscale circuits, are subject to process and environmental variations. Irregular distances between nanomagnetic cells, missing cells, and merging nanomagnets are the most common defects [9], each of them affects the energies of nanomagnets and their switching behavior, and consequently influences the overall performance of NML circuits [10]. Thermal fluctuation is another factor that might change the switching of nanomagnets [11, 12]. As a result, the design of testable NML circuits is of great importance.

Error detection is one of the primary tasks in test process either immediately after fabrication or during normal circuit operation. Thus, if the techniques that facilitate error detection are used, the efficiency of the test process as well as the fault tolerance will be increased. One of the difficulties with error detection in conventional circuits made from conventional gates is that they do not have the inherent capability of error detection and their designs need to be modified in order to provide error detection ability. For example, the triple modular redundancy is a well-known fault-tolerant method, in which three completely identical circuits are used, and the error occurrence is detected by an extra voter circuit.

In the conservative logic, first introduced in 1982 [13], there are equal numbers of 1s in the input and output vectors. Using this important feature, all unidirectional errors can be detected by comparing the number of 1s in the corresponding inputs and outputs. Furthermore, conservative circuits are parity preserving; therefore, any number of odd errors can be detected. One of the most famous conservative gates is Fredkin gate [13], which is also a universal gate. It means that all of the circuits made from it are also conservative. In this case, only two test vectors, all of which are zero or one, can detect all unidirectional errors, regardless of the implemented function [14].

Another unique feature of Fredkin gate is reversibility. In reversible logic, the number of inputs and outputs is equal and there is a one-to-one mapping between them. Therefore, having the values of the outputs, we can obtain the values of the inputs, and vice versa. Laundauer has shown that the cost of energy dissipation due to the missing of one bit is equal to KTln2 Joules [15], where ‘K’ is Boltzmann constant and ‘T’ is temperature. Then, Bennett has shown that reversible logic is a solution to this energy loss problem [16]. This feature of reversible logic makes it suitable for the design of ultra-low-power nanocircuits [16] and also facilitates the testing procedure of these circuits by improving their observability and controllability [17].

The QCA layout of the Fredkin gate has been proposed in [18,19,20]. There are also several approaches that have utilized Fredkin gate to design testable QCA circuits [14, 18, 19]. However, to the best of our knowledge, no complete design and micromagnetic simulations of nanomagnetic Fredkin gate have yet been presented in the literature.

The nature of nanomagnetic materials and their intrinsic properties, shapes, dimensions, and spacing are influential on their behavior and should be carefully investigated [21]. In addition, in order to design a real NML circuit, that contains a large number of nanomagnets, an appropriate clock signal should be used. Therefore, our goal is to design and evaluate nanomagnetic Fredkin gate as a fundamental conservative reversible gate, with the engineering of the properties of nanomagnetic materials and their geometry. This nanomagnetic gate can be used as the basic gate for testable ultra-low-power NML circuits.

The rest of this article is organized as follows: Sect. 2 provides background on NML and conservative logic. The clocking scheme required to NML circuits is also explained in this section. The proposed in-plane nanomagnetic logic design of Fredkin gate is presented in Sect. 3. Simulation results, based on OOMMF simulator, are presented in Sect. 4 and then conclusion appears in Sect. 5.

2 Background

2.1 NML

The fundamental cell of NML devices is an elongated magnetic material with a single-domain behavior (Fig. 1). If the size of the magnet is set from 100 to 10 nm, it will be in the single-domain area [22]. In the magnetic saturation conditions, where the nanomagnet is fully magnetized by an external field H, there are only two stable states that can be used to represent the binary logic values. By removing this external field, the nanomagnet maintains its magnetic state property along its longest axis, which is called the easy axis, where the magnet has the least anisotropy energy [23].

Fig. 1
figure 1

Hysteresis curve of a single-domain rectangular magnet

In NML circuits, the logical calculations and information transformations are done by magnetic interactions between adjacent cells. In order to drive the data flow from input to output, the nanomagnets are initially forced in the null state by applying an external magnetic field along their hard axis (the shortest axis). The input nanomagnet is then set to zero or one. In this case, the nanomagnets will drive information to the output under the influence of their previous magnet’s field. In fact, magnets that are in the null state have the most energy of anisotropy, thus they can easily change their positions with the small external field of their neighboring magnets. The magnitude of the external magnetic field should be large enough to force all the nanomagnets in the null state. A proper clocking system is necessary to ensure that data flows in the desired direction [24]. In Sect. 2.2, the clocking scheme is described as an appropriate solution for controlling data flow and the switching of complex NML circuits.

Like QCA, the fundamental logic gates in NML are inverter and majority gate. Different structures for these gates have been presented in the literature for both QCA and NML technologies [8, 24,25,26,27,28,29,30]. Unlike QCA, any variation in the shape of nanomagnets modifies their shape anisotropy, which in turn changes their energy barriers and the overall behavior of the circuit. Using this phenomenon, the non-majority-based AND/OR gates have been proposed in [31, 32]. For the correct functionality, the external field should only be applied to the middle right trapezoid nanomagnet, which is not possible in practice. To overcome this problem, the utilization of helper magnets as well as the shape engineering of input nanomagnets has been suggested in the literature [31].

2.2 Clocking operation

As mentioned before, the energy of adjacent nanomagnets affects each other, and it can cause some of the nanomagnets to be switched early and transmit data in the reverse direction. Therefore, to ensure unidirectional data flow, the energy of the entire system must be controlled properly. In addition, the magnetic field created by a single nanomagnet is not large enough to put the magnetization of all its neighbors in a new state. Hence, in order to help the correct switching of nanomagnets, an external magnetic field is required, which is called the clock [33,34,35].

A three-phase clocking system is the most commonly used scheme to control the propagation of data through NML circuits. In this method, the NML circuit is divided into small areas called clock zones, and a different overlapping clock signal is applied to each of these areas. Three-phase clocking systems have been presented in [12, 33, 34, 36]. In a three-phase clocking system, each of the clock zones has three stages of RESET, SWITCH, and HOLD (Fig. 2). The nanomagnets in the RESET stage are in their null states. At the SWITCH stage, the magnitude of the clock is zero, and the nanomagnets of this area can be in a new logical state due to the magnetic fields of adjacent nanomagnets that are in the HOLD state. Nanomagnets in the HOLD stage have a stable magnetic state.

Fig. 2
figure 2

The three-phase clocking system with a phase difference of 120° [37]

Different methods have been proposed to create a clock for NML. A common method is to use a magnetic field generated by an electric current whose wires are placed at the bottom of nanomagnets (Fig. 3). The material is a copper wire that is wrapped by a supermalloy on its sides and bottom to enclose its field [38]. The thickness of this wire should be such that it can create the necessary magnetic field to force the nanomagnets in a null state.

Fig. 3
figure 3

NML with the magnetic clock mechanism. The clock signal of each zone is provided by a magnetic field generated by the current flowed through separate copper wire, which is placed under the magnets’ plane [39]

2.3 Conservative logic

The conservative logic was first presented in [13]. In a conservative gate, the number of inputs and outputs is the same. One of the main advantages of conservative logic circuits is that they naturally support concurrent error detection [14]. In these circuits, all unidirectional stuck-at faults can be detected using only two test patterns. One of the most famous conservative gates is Fredkin gate, which is also a reversible gate [13]. It means that the number of 1’s in each input vector and in corresponding output is equal, and there is a one-to-one mapping between inputs and outputs. In addition, this gate is a universal gate and every conservative reversible circuit can be designed by using only a number of Fredkin gates. This gate and its truth table are shown in Fig. 4.

Fig. 4
figure 4

Fredkin gate and its truth table [13]

3 The proposed structure for nanomagnetic Fredkin gate

Majority gate and inverter are the basic logic gates of QCA and NML. A 3-input majority gate can be converted to AND/OR (or NAND/NOR) by permanently fixing one of the inputs to logic 0/1. However, this fixed input values might cause a stuck-at fault in NML circuits [31]. In addition, the majority gate can increase the number of connections and nanomagnets. Therefore, non-majority based AND/OR gates are utilized in the proposed layout of nanomagnetic Fredkin gate (Fig. 5). In Fig. 5, red and green nanomagnets are, respectively, used to display the 2-input AND and OR gates. Additionally, yellow, black, and gray colors represent helper, input, and AF ordered nanomagnets, respectively. The AND and OR gates are put in the second and fourth clock zones (zone2 and zone4). The inputs are duplicated and applied at multiple positions with the aim of avoiding wire crossings.

Fig. 5
figure 5

Proposed layout for nanomagnetic Fredkin gate and its clock zones (Color figure online)

As mentioned in Sect. 2.1, for the proper operation of AND/OR gates, the external field must be applied only to their central magnet. However, it is not feasible to do so in real circuits, which contain a large number of nanomagnets. It is therefore very important to design proper clock signals. In addition to affecting the accuracy of circuit operation, choosing the appropriate clock period, overlaps, and rise and fall time has also major effects on reducing dynamic power and increasing the speed of NML circuits. The speed of NML circuits generally depends on the clock frequency. On the other hand, the number of nanomagnets in a clock zone directly affects the clock frequency. The larger the number of nanomagnets in a clock zone, the greater the time it takes to change the state of all of them from null to a stable state. Furthermore, the probability of random switching of nanomagnets inside a clock zone due to thermal fluctuations increases with the number of nanomagnets [8]. Therefore, to increase the speed and reliability of the circuit, only two nanomagnets have been situated in every clock zone of the proposed clocking system.

In this paper, we assume that the magnitude of the magnetic field inside a clock zone in the RESET state is constant and the value outside it is zero. In a real clock line, due to the fabrication issues, the cross section areas are not completely rectangular and due to the need for additional oxide layers, the gap between two adjacent clock lines increases. Therefore, the magnitude of the magnetic field clock within a zone is not exactly constant and is lower at the boundaries between zones. Furthermore, the value of this field in an adjacent clock line in the HOLD state does not immediately reach zero. The nanomagnets located between the two clock zones receive a smaller field. If this gap widens between the two adjacent clock zones, there is a possibility of an error in data transmission. In [40, 41], by using the Maxwell 2D and OOMMF tools and the actual implementation of clock lines, it has been shown that the smaller the gap, the lower the probability of error occurring.

In addition, if the two nanomagnets have the same dimensions, in the SWITCH phase, the right nanomagnet may be changed sooner than the left one due to the fluctuations. To avoid this problem, we take the aspect ratio (length to width ratio) of the nanomagnet in the right-hand side smaller than the left-hand one, as proposed in [12]. In addition, this implies that the nanomagnets could switch from null to a stable state with a fast fall time.

The energy of the nanomagnets, in addition to their size and shape, depends on their material. Therefore, the material must be properly selected. This selection will also affect the magnitude and period of the clock. In this paper, cobalt with biaxial anisotropy, suggested in [42], is used to increase the stability of the hard axis of the nanomagnets. Therefore, magnets that are in the null state will be more stable against thermal fluctuations and marginal fields of adjacent nanomagnets. Furthermore, lower clock signal magnitude is required to keep these magnets in the null state. The hysteresis curves from OOMMF simulations for two distinct rounded rectangular biaxial cobalt nanomagnets, with K1 = 6 × 104 J/m3 and dimensions of 45 × 90 × 20 nm3 and 45 × 70 × 20 nm3 in the presence of a gradually increasing and decreasing external field along their easy axes show that the smaller nanomagnet has a coercivity of 112 mT, while the larger one has a coercivity of 182 mT. As a result, when a clock is applied to the hard axis of two AF ordered nanomagnets inside a clock zone, the smaller nanomagnet enters to the null state earlier than the larger one. The magnitude of the clock should certainly be such that it can force the nanomagnets into the null state. In addition, the difference between aspect ratios causes the larger nanomagnet to be switched earlier than the smaller one when the clock signal changes from the RESET to the SWITCH phase. Therefore, data is transmitted in the correct direction.

The stability of nanomagnets that are vertically and ferromagnetically arranged is much less than the stability of the nanomagnets placed in the form of AF ordered. As shown in Fig. 5, in order to increase their stability, the helper nanomagnets are utilized on their left- or right-hand side(s) [43]. The geometric shape and dimensions of these nanomagnets are determined in such a way that the external field can hold up the vertical nanomagnets in a null state until the signal arrives from adjacent nanomagnets.

4 Simulations and results

The object-oriented micromagnetic framework (OOMMF) provided by NIST [44] is used to simulate the proposed nanomagnetic Fredkin gate. This tool solves the nonlinear equation of Landau–Lifshitz–Gilbert [45, 46], which describes the magnetization under an effective magnetic field. The simulation results of the OOMMF tool are very similar to those obtained from experimental conditions [31].

The proper choice of the aspect ratio and thickness of the nanomagnets inside a clock zone is important to provide a correct operating situation. The excessive aspect ratio of the nanomagnets results in an unstable null state and, as a result, incorrect operation of the circuit. To tackle this problem, on the one hand, the clock magnitude has to be increased. This will increase dynamic power as a consequence. On the other hand, if the aspect ratio is too small, the switching process will be difficult due to the excessive stability of the nanomagnets in their hard axes. Different simulations are done in this paper to obtain the appropriate aspect ratio of the nanomagnets. According to our investigations, the appropriate ratios for small and large nanomagnets are 1.5 and 2, respectively. The dimensions of these nanomagnets are 45 × 70 nm2 and 45 × 90 nm2 with the thickness of 20 nm. Note that the excessive increase in thickness will increase the probability of the vortex magnetization.

In addition, the proper distance between the nanomagnets is of importance for their correct switching. If this inter-nanomagnet distance is high, coupling strength between nanomagnets decreases and the probability of occurring switching error increases. On the other hand, if this distance is greatly reduced, although it increases the strength of the interaction between the nanomagnets, the probability of merging the nanomagnets, because of their high proximity, increases. Based on our OOMMF simulations, 20 nm and 30 nm are appropriate for horizontal and vertical inter-nanomagnet distances, respectively.

In addition, for correct operation of the AND/OR gates, the slanted edge nanomagnet cutting angle (θ) must be in an appropriate range. To determine the proper range of this angle, different input combinations as well as clock signal must be considered. In the case of AND gate, the minimum value of θ is determined by a state in which only of the inputs is solely ‘1.’. In this case, if this angle is too low, the gate output may be in the incorrect state when the clock field is removed. On the other hand, the maximum allowed θ is related to the state where both inputs are in logic ‘1.’ If this angle is too large, then the computational slanted edge nanomagnet cannot settle down to the correct magnetization state. In addition, the larger the angle is, the greater the clock range needed to reset this magnet.

Similarly, the minimum θ value for OR gate is determined by a condition where one of the input values is exclusively ‘1.’ The maximum value of this angle is also determined by a state whose inputs are ‘0.’

Based on the simulations performed by OOMMF, an angle of about 45° seems to be an appropriate choice, although the AND/OR gates are also capable of working properly with slightly smaller or larger angles.

In our OOMMF simulations, single-domain cobalt nanomagnets with the cell size of 4 × 4 × 4 nm3, saturation magnetization of Ms = 1 × 106 A/m, exchange coefficient of A = 1.3 × 10−11 J/m, biaxial anisotropy constant of K1 = 6 × 104 J/m3 and temperature of 300 K (room temperature) are considered. In order to achieve more consistency with experimental results, we assumed that the damping coefficient is 0.1 [31]. Table 1 summarizes the design and simulation parameters. In this paper, the three-phase overlapping clocking systems with the phase difference of 120° and nonzero rise and fall time have been taken into consideration. The parameters and waveforms of this clocking system are shown in Table 2 and Fig. 6, respectively.

Table 1 OOMMF simulation and design parameters
Table 2 Clock parameters
Fig. 6
figure 6

OOMMF simulation of clock signals

The magnetization states of the nanomagnets after different switching stages of each clock zone for the input combination of ABC = 001 are shown in Fig. 7.

Fig. 7
figure 7figure 7

OOMMF simulation of the proposed gate, for the input combination of ‘001,’ a after the switching of clock zone1 nanomagnets, b after the switching of clock zone2 nanomagnets, c after the switching of clock zone3 nanomagnets, d after the switching of clock zone4 nanomagnets (final state) (Color figure online)

After all input nanomagnets are forced in a desired logic level by applying a large magnetic field, the clock system is introduced into the circuit nanomagnets in accordance with Fig. 6 in the direction of + x. By applying a gradually increasing clock signal from 0 to 170 mT to the zone2 nanomagnets, these nanomagnets switch from HOLD to RESET. At this moment, the nanomagnets of the first (and fourth) and third clock zones are in RESET and HOLD stages, respectively. After the nanomagnets of the zone2 are stabilized in their null state, the clock applied to the first (and fourth) zones is gradually removed so that their nanomagnets are switched to a stable state under the influence of the coupling field of the input nanomagnets (and zone3 nanomagnets).

Please note that if the clock signal is removed abruptly, thermal fluctuations might change the state of unstable null nanomagnets randomly. Based on our simulations, 1 ns fall time is sufficient to switch the nanomagnets of a clock zone correctly. Due to the high aspect ratio of the input nanomagnets, this clock does not affect their magnetization states.

Figure 7a shows the status of the nanomagnets at the end of the SWITCH stage of the clock zone1. After the amplitude of the clock in zone1 (and also zone4) reaches zero, zone3 nanomagnets are forced into the RESET stage with an incremental clock. It is worth it to mention again that zones 1 and 4 receive the same clock signal. Then, zone2 nanomagnets switch to their stable states by gradually removing the clock (Fig. 7b). This procedure is repeated for the first/fourth and third clock zones, and then for the second and first (fourth) clock zones. The states of the nanomagnets at the end of the switching stage of these steps are shown in Fig. 7c and d, respectively. In addition, white, red, and blue cells in Fig. 7 indicate the null, logic 1, and logic 0 states, respectively.

To demonstrate more vividly, the magnetization evolution through a clock cycle is illustrated in Fig. 8. Additionally, Fig. 8 shows waveforms with the consideration of thermal fluctuation analysis. We performed 10 simulations at room temperature with different random seeds using the OOMMF extension developed by the University of Hamburg called ThetaEvolve [47]. Simulation results illustrated in Fig. 8a–f correspond to the AND and OR gates in Fig. 5. The red, blue, and green signals in Fig. 8 indicate waveforms of the first input, the second input, and the output cells of the AND/OR gates, respectively. The waveforms of computational nanomagnets (y1, y2, y3, Q, and R) are only presented in this figure for the sake of simplicity. The change in the state of the all computational nanomagnets in the switching stage is always slightly after the change in the input magnets of the gates. For example, considering the AND gate with the inputs a and b and the output y1 (Fig. 5), the final state of y1 at the end of the switching stage is determined slightly after the change of the input magnets a and b to 0 and 1, respectively.

Fig. 8
figure 8

Simulation results of the magnetization of AND/OR components in Fig. 5 over time, at room temperature in the presence of thermal fluctuations, a AND1, b AND2, c AND3, d AND4, e OR1, f OR2 (Color figure online)

As shown in Fig. 8e and f, the P and Q outputs of the Fredkin gate enter their stable state after 16.2 ns. Therefore, the operating frequency of this circuit is about 62 MHz.

Similarly, all the other seven input combinations are tested as well. The simulation results confirm the correct functionality of the proposed design for all of the input combinations.

5 Conclusion

In this paper, we have considered the design of testable NML circuits using conservative logic. For this purpose, nanomagnetic Fredkin gate as a universal conservative reversible gate has been designed and simulated. We have considered the effects of physical parameters of nanomagnets, as well as inter-nanomagnet distances and clocking system on the functionality of the proposed NML gate by utilizing the OOMMF tool. The simulation results indicate the correct functionality of the proposed gate for all of the possible input combinations at room temperature.