Example #1
0
def BL7(a, b, c):
    """
    Implementation of Block 7.
    """
    and1out = lg.AND(a, lg.NOT(b))
    and2out = lg.AND(b, c)
    s = lg.OR(and1out, and2out)
    return s
Example #2
0
def BL5(a, b, c):
    """
    Implementation of Block 5.
    """
    s0 = lg.XOR(b, c)
    andOut = lg.AND(b, c)
    s1 = lg.OR(a, andOut)
    return s0, s1
Example #3
0
def BL6(a, b):
    """
    Implementation of Block 6.
    """
    and1out = lg.AND(a, lg.NOT(b))
    and2out = lg.AND(lg.NOT(a), b)
    s = lg.OR(and1out, and2out)
    return s
Example #4
0
def BL4(a, b, c):
    """
    Implementation of Block 4.
    """
    and1out = lg.AND(a, b)
    and2out = lg.AND(lg.NOT(b), c)
    s = lg.OR(and1out, and2out)
    return s
Example #5
0
def BL1(a, b, c):
    """
    Implementation of Block 1.
    """
    and1out = lg.AND(a, c)
    and2out = lg.AND(b, lg.NOT(c))
    s = lg.OR(and1out, and2out)
    return s
Example #6
0
def BL3(a, b, c):
    """
    Implementation of Block 3.
    """
    and1out = lg.AND(lg.NOT(a), b)
    and2out = lg.AND(a, c)
    s = lg.OR(and1out, and2out)
    return s
Example #7
0
def BL2(a, b):
    """
    Implementation of Block 2.
    """
    orOut = lg.OR(a, b)
    s0 = orOut
    andOut = lg.AND(a, b)
    s1 = andOut
    xorOut = lg.XOR(a, b)
    s2 = xorOut
    return s0, s1, s2
Example #8
0
# Read Program File
file = open('Program.txt', 'r')

# Make it an Array
program = file.readlines()

for i in xrange(0, len(program)):
    command = program[i].split()
    if command[0] == '#':
        print 'comment'
        print command
    elif command[0] == 'NOT':
        print 'NOT'
        #print command
        QBits[int(command[1]) - 1] = LogicGates.NOT(QBits[int(command[1]) - 1])
        print QBits

    elif command[0] == 'CNOT':
        print 'CNOT'
        #print command
        QBits[int(command[2]) - 1] = LogicGates.CNOT(
            QBits[int(command[1]) - 1], QBits[int(command[2]) - 1])
        print QBits

    elif command[0] == 'CCNOT':
        print 'CCNOT'
        #print command
        QBits[int(command[3]) - 1] = LogicGates.CCNOT(
            QBits[int(command[1]) - 1], QBits[int(command[2]) - 1],
            QBits[int(command[3]) - 1])