A control method of an addition circuit, configured to implement an addition operation of n-bit numbers an, . . . , a2a1, bn, . . . , b2b1, and a 1-bit carry input c1;
- wherein n≥2, the addition circuit comprises n parallel branches and switch modules m1, m2, . . . , mn−1 configured to control connection or disconnection between adjacent two branches, an i-th switch module mi is configured to control connection or disconnection between an i-th branch and a (i+1)-th branch, i=1, 2, . . . , n−1;
- the i-th branch comprises an i-th resistor Ri and three memristors whose negative electrodes are connected to a terminal of a resistor Ri;
- a n-th branch comprises a n-th resistor Rn and four memristors whose negative electrodes are connected to a terminal of a resistor Rn;
- all memristors of the addition circuit are identical, all resistors are identical, and a resistance value indicates is R=√{square root over (RH·RL)};
- RH and RL are a high resistance state value and a low resistance state value of the memristor respectively;
- wherein the control method comprises:
- S1:
- sequentially executing n−1 rounds of a carry calculation subprocesses;
- in an i-th round of the carry calculation subprocess, controlling the i-th switch module mi to conduct to connect the i-th branch with the (i+1)-th branch, and disconnecting other switch modules;
- when i=1, selecting one memristor from the i-th branch as a memristor M1 in the i-th round of the carry calculation subprocess, and setting the memristor to a resistance state corresponding to c1;
- when i≥2, using a memristor M2 from a previous round of the carry calculation subprocess as the memristor M1 in a current round of the carry calculation subprocess;
- selecting one memristor from the (i+1)-th branch as a memristor M2 in the i-th round of the carry calculation subprocess, a resistance state of the memristor M2 being a high resistance value state at this time, and making positive electrodes of other memristors except the memristors M1, M2 in the current round of the carry calculation subprocess be in floating states;
- connecting a voltage −V(bi)−Vp to a positive electrode of the memristor M1 in the current round of the carry calculation subprocess, connecting a voltage V(ai) to a positive electrode of the memristor M2 in the current round of the carry calculation subprocess, connecting a voltage −V(bi) to a terminal of a resistor Ri or a resistor Ri+1 not connected to the memristors, thereby obtaining a majority operation result of ai, bi, ci corresponding to the resistance state of the memristor M2 in the current round of the carry calculation subprocess, and using the majority operation result of ai, bi, ci as a carry result of the i-th round of the addition operation;
- S2:
- disconnecting all switch modules, so that all branches are not connected;
- executing the n-th round of the carry calculation subprocess, and executing n rounds of sum calculation subprocesses in parallel;
- wherein executing the n-th round of the carry calculation subprocess comprises:
- using the memristor M2 from the previous round of the carry calculation subprocess as the memristor M1 in the current round of the carry calculation subprocess, selecting one unselected memristor from the n-th branch as the memristor M2 in the n-th round of the carry calculation subprocess, the resistance state of the memristor M2 being the high resistance value state at this time;
- and making the positive electrodes of other memristors in the n-th branch except the memristors M1, M2 in the current round of the carry calculation subprocess be in floating states;
- connecting a voltage −V(bn)−Vp to the positive electrode of the memristor M1 in the current round of the carry calculation subprocess, connecting a voltage V(an) to the positive electrode of the memristor M2 in the current round of the carry calculation subprocess, connecting a voltage −V(bn) to a terminal of the resistor Rn not connected to the memristors, thereby obtaining a majority operation result of an, bn, cn corresponding to the resistance state of the memristor M2 in the current round of the carry calculation subprocess, and using the majority operation result as a carry result of the n-th round of the addition operation;
- executing n rounds of sum calculation subprocesses in parallel comprises:
- for a j-th branch, using the memristor selected as the memristor M1 in a j-th round of the carry calculation subprocess as a memristor Mj1;
- and selecting two unselected memristors from the j-th branch as memristors Mj3 and Mj4, and j=1, 2, . . . , n;
- making a positive electrode of each memristor Mj4 be in a floating state, connecting a corresponding voltage V(aj)−2Vp to a positive electrode of each memristor Mji in parallel, connecting a voltage with an amplitude of 0 to a positive electrode of each memristor Mj3 in parallel, connecting a corresponding voltage −V(aj)−Vp to a terminal of each resistor Rj not connected to the memristors in parallel, thereby obtaining an XOR operation result of aj and cj corresponding to a resistance state of each memristor Mj3 in parallel;
- and
- making the positive electrode of each memristor Mji be in a floating state, after obtaining the XOR operation result of aj and cj, connecting a corresponding voltage V(bj)−2Vp to the positive electrode of each memristor Mj3 in parallel, connecting a voltage with an amplitude of 0 to the positive electrode of each memristor Mj4 in parallel, connecting a corresponding voltage −V(bj)−Vp to the terminal of each resistor Rj not connected to the memristors in parallel, thereby obtaining an XOR operation result of aj, bj, and cj corresponding to a resistance state of each memristor Mj4 in parallel, and using the XOR operation result of aj, bj, and cj as a sum result of the addition operation;
- wherein a high resistance state of a memristor corresponds to a logic value “0”, a low resistance state corresponds to a logic value “1”;
- when bj is 1, V(bj) is Vp;
- when bj is 0, V(bj) is a voltage with an amplitude of 0;
- when aj is 1, V(aj) is Vp;
- when aj is 0, V(aj) is a voltage with an amplitude of 0;
- a voltage Vp satisfies:
- Vset/2<Vp<Vset, and Vp<2|Vreset|/3;
- Vset is a threshold for the memristor to transform from the high resistance state to the low resistance state, and Vreset is a threshold for the memristor to transform from the low resistance state to the high resistance state.