I want to implement a controlled operation that involves the following: we have the following qubits: $|x_0\rangle,|x_1\rangle,|0\rangle,|1\rangle,|z_0\rangle,|z_1\rangle$. I want to add the first four qubits as $|x_0x_1\rangle$ and $|01\rangle$ where each $x_i\in\{0,1\}$ conditioned on the $|z_1\rangle$ being $0$. If the control is $1$ then do not perform the adder mod operation. So the circuit for this that I constructed is given in the figure:

Controlled ADD MOD 4

Is this circuit correct?

Edit: Just to elaborate what this circuit does. It takes $3$ non-negative integer inputs $x=|x_0x_1\rangle$, $1=|01\rangle$, $z=|z_0z_1\rangle$ and adds the first two integers that are stored in the register $|x_0x_1\rangle$ and $|10\rangle$. The third integer $|z\rangle$ gives a remainder of $2$ when divided by $4$, but this can be thought of as the least significant bit being equal to $0$. Is the problem statement and circuit construction matching?

  • $\begingroup$ What does $z_0$ do? $\endgroup$ May 16, 2019 at 19:08
  • $\begingroup$ $z_0$ is not required for this computation but it will he used for further operation. at this moment it does not play a part $\endgroup$
    – Upstart
    May 16, 2019 at 19:11
  • $\begingroup$ @Upstart I'm curious what the larger project you are working on is. $\endgroup$
    – psitae
    Mar 23, 2020 at 18:14

1 Answer 1


The second from the top wire should probably be marked $|x_1 \rangle$ instead of $|x_0 \rangle$ (right now you have two $|x_0 \rangle$s). Other than that, the circuit looks correct for the described task.

  • $\begingroup$ yes that is $|x_1\rangle$ $\endgroup$
    – Upstart
    May 16, 2019 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.