Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
alihakimtaskiran authored Aug 29, 2021
1 parent fee1b2d commit ca1c5ec
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions qalu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def nor_(circ,a,b,out):
circ.cx(b,out)
circ.ccx(a,b,out)
circ.x(out)

def xnor_(circ,a,b,out):
circ.cx(a,out)
circ.cx(b,out)
Expand All @@ -34,6 +34,10 @@ def full_adder(circ,a,b,c_in,t_0,t_1,t_2,c_out,sum_):
and_(circ,a,b,t_1)
and_(circ,c_in,t_0,t_2)
or_(circ,t_1,t_2,c_out)
circ.ccx(c_in,t_0,t_2)
circ.cx(a,t_0)
circ.cx(b,t_0)
circ.ccx(a,b,t_1)

def half_subtractor(circ, a, b, carry, diff):
xor_(circ,a,b,diff)
Expand All @@ -44,7 +48,12 @@ def full_subtractor(circ,a,b,c_in,t_0,t_1,t_2,c_out,diff):
xor_(circ,t_0,c_in,diff)
circ.x(a)
circ.ccx(a,b,t_1)
circ.x(a)
circ.x(t_0)
circ.ccx(t_0,c_in,t_2)
or_(circ,t_1,t_2,c_out)
circ.ccx(c_in,t_0,t_2)
circ.ccx(a,b,t_1)
circ.x(t_0)
circ.x(a)
circ.cx(a,t_0)
circ.cx(b,t_0)

0 comments on commit ca1c5ec

Please sign in to comment.