Example #1
0
int main(int argc, char* argv[])
{
	printf(" a | b | a NAND b | a NOR b | a XOR b | a XNOR b\n");
	printf("---+---+----------+---------+---------+----------\n");	
	for(int a = 0; a < 2; a++)
	{
		for(int b = 0; b < 2; b++)
		{
			printf(" %d | %d |     %d    |    %d    |    %d     |     %d\n",
				a, b, 
				nand_gate(a, b), 
				nor_gate(a, b),
				xor_gate(a, b),
				xnor_gate(a, b));
		}
	}
	return 0;
}
Example #2
0
File: main.c Project: kartik1507/sc
static PyObject *
ext_xor_gate(PyObject *self, PyObject *args)
{
    PyObject *py_a, *py_b;
    struct bit *a, *b, *out;

    if (!PyArg_ParseTuple(args, "OO", &py_a, &py_b))
        return NULL;

    a = (struct bit *) PyCapsule_GetPointer(py_a, NULL);
    if (a == NULL)
        return NULL;
    b = (struct bit *) PyCapsule_GetPointer(py_b, NULL);
    if (b == NULL)
        return NULL;

    out = (struct bit *) malloc(sizeof(struct bit));
    if (out == NULL)
        return NULL;

    xor_gate(out, a, b);

    return PyCapsule_New((void *) out, NULL, bit_destructor);
}