QuantumGhost
5/27/2014 - 5:31 AM

Quantum Full Adder

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