Mega Code Archive
Prog to implement a boolean function using a multiplexer logic
#include
#include
#include
#include
#include
#include
#define N 500
int function[35];
int strobe[5] = { 0,0,0,0,0 };
int store[16] = { 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 };
int inputs[16];
int output=0,count=0,decieq,choice;
int driver=DETECT,mode;
/***********FUNCTIONS FOR BEGINING GUI***************/
struct stars
{
int x,y,x1,y1,z,c;
}STARS[N];
void init()
{
int i,t;
for(i=0;i325) {STARS[i].z=1;} */
void move()
{
int i;
for(i=0;i1 || strobe[ctr2]<0)
{
printf("
Invalid select input");
exit(2);
}
}
void decide_output(int count) //decides whether output is 1 or 0
{ //for normal mux implementation
int ctr2;
for(ctr2=0;ctr232)
{
printf("
Invalid function input.inputs can't be greater than 32");
exit(1);
}
clrscr();
printf("Enter the function to be implemented : ");
for(ctr=0;ctr31)
{
printf("
Invalid function input");
exit(1);
}
}
printf("
Only first %d inputs considered.rest rejected(if any)",count);
fflush(stdin);
if(function[count-1] <= 1)
{
two_is_to_one();
common_gui(2);
}
else if(function[count-1] <= 3)
{
label1:
printf("
Implement using:-
1.)4:1 Mux
2.)2:1 Mux
Enter your choice?");
scanf("%d",&choice);
switch(choice)
{
case 1: four_is_to_one();
common_gui(4);
break;
case 2: complex_two_is_to_one();
common_complex_gui(2);
break;
default : printf("
Invalid choice");
goto label1;
}
}
else if(function[count-1] <= 7)
{
label2:
printf("
Implement using:-
1.)8:1 Mux
2.)4:1 Mux
Enter your choice?");
scanf("%d",&choice);
switch(choice)
{
case 1: eight_is_to_one();
common_gui(8);
break;
case 2: complex_four_is_to_one();
common_complex_gui(4);
break;
default : printf("
Invalid choice");
goto label2;
}
}
else if(function[count-1] <= 15)
{
label3:
printf("
Implement using:-
1.)16:1 Mux
2.)8:1 Mux
Enter your choice?");
scanf("%d",&choice);
switch(choice)
{
case 1: sixteen_is_to_one();
common_gui(16);
break;
case 2: complex_eight_is_to_one();
common_complex_gui(8);
break;
default : printf("
Invalid choice");
goto label3;
}
}
else if(function[count-1] <= 31)
{
label4:
printf("
Implement using:-
1.)32:1 Mux
2.)16:1 Mux
Enter your choice?");
scanf("%d",&choice);
switch(choice)
{
case 1: thirtytwo_is_to_one();
common_gui(32);
break;
case 2: complex_sixteen_is_to_one();
common_complex_gui(16);
break;
default : printf("
Invalid choice");
goto label4;
}
}
getch();
}