Skip to content

Instantly share code, notes, and snippets.

@akfish
Created May 27, 2014 05:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akfish/91b73348e2bc70d71fd7 to your computer and use it in GitHub Desktop.
Save akfish/91b73348e2bc70d71fd7 to your computer and use it in GitHub Desktop.
Quantum Full Adder
// This is a semi-quantum fulladder. It adds to b_in
// a c-number. Carry-in bit is c_in and carry_out is
// c_out. xlt-l and L are enablebits. See documentation
// for further information
proc muxfa a, b_in, c_in, c_out, xlt_l, L, total //a,
if a == 0//00
Toffoli b_in, c_in, c_out
CNot b_in, c_in
endif
if a == 3//11
Toffoli L, c_in, c_out
CNot L, c_in
Toffoli b_in, c_in, c_out
CNot b_in, c_in
endif
if a == 1//01
Toffoli L, xlt_l, b_in
Toffoli b_in, c_in, c_out
Toffoli L, xlt_l, b_in
Toffoli b_in, c_in, c_out
Toffoli L, xlt_l, c_in
Toffoli b_in, c_in, c_out
CNot b_in, c_in
endif
if a == 2//10
SigmaX xlt_l
Toffoli L, xlt_l, b_in
Toffoli b_in, c_in, c_out
Toffoli L, xlt_l, b_in
Toffoli b_in, c_in, c_out
Toffoli L, xlt_l, c_in
Toffoli b_in, c_in, c_out
CNot b_in, c_in
SigmaX xlt_l
endif
endproc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment