Skip to content

Instantly share code, notes, and snippets.

@antoinealb
Created November 8, 2012 16:38
Show Gist options
  • Save antoinealb/4039949 to your computer and use it in GitHub Desktop.
Save antoinealb/4039949 to your computer and use it in GitHub Desktop.
Generator of logisim table for EPFL's CS-171 course's 3rd lab
#include <stdio.h>
void print_number(char num, int bitsize) {
while(bitsize--) {
if(num & (1 << bitsize))
printf("1");
else
printf("0");
printf("\t");
}
}
void main(void) {
char a, b;
printf("A3\tA2\tA1\tA0\tB3\tB2\tB1\tB0\tQ\tC3\tC2\tC1\tC0\n");
for(a=0;a<16;a++) {
for(b=0;b<16;b++) {
print_number(a, 4);
print_number(b, 4);
print_number(a-b, 5);
printf("\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment