def ex3(): a = Bit() b = Bit() c = Bit() x = (a & b) | (~c & nand(b, a)) y = ~x test_values = """\ 111 10 110 10 101 01 100 10 011 01 010 10 001 01 000 10""" inputs = '\n'.join(' '.join(line.split(' ')[0]) for line in test_values.splitlines()) outputs = ''.join(' ' + out + '\n' for out in (' '.join(line.split(' ')[1]) for line in test_values.splitlines())) write_test('ex3', inputs, outputs) compile_program([x, y])
def ex1(): a = Bit() b = Bit() c = Bit() x = ~a & (b | c) y = nand(b, x) test_values = """\ 000 01 001 11 010 10 011 10 100 01 101 01 110 01 111 01""" inputs = '\n'.join(' '.join(line.split(' ')[0]) for line in test_values.splitlines()) outputs = ''.join(' ' + out + '\n' for out in (' '.join(line.split(' ')[1]) for line in test_values.splitlines())) write_test('ex1', inputs, outputs) compile_program([x, y])