Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

#include<stdio.

h>
#include<conio.h>
#include<math.h>
void main()
{
double vt0=1.0;
double gamma=0.00003;
double pif=0.65;
double vbs=0.0;
double w=0.0003;
double l=0.0006;
double kp=0.0003;
double xj1=0.0000008;
double lamda=.02;
double res=0.0;
double vt,fvbs,vgs,vds,ids,vr;
char opt;
clrscr();
printf("\n mosfet level");
printf("\n getchar");
scanf("%c",&opt);
//flushall();

if((opt=='y')||(opt=='Y'))
{

// give vbs

printf("\n vbs");
scanf("%lf",&vbs);
//flushall();
printf("\n vgs");

// give vgs

scanf("%lf",&vgs);
//flushall();
printf("vds");

//give vds

scanf("%lf",&vds);
//flushall();
}
fvbs=gamma*((sqrt(fabs(vbs)+(2*(fabs(pif)))))sqrt(2*(fabs(pif))));
printf("\n \n fvbs=%lf",fvbs);
vt=vt0+fvbs;
if(vgs<vt)
{
printf("\n\n cutt off");
ids=0.0;
res=1.0;
}

//cut off

if((vgs>vt) && (vds>(vgs-vt)))

//saturation

{
printf("\n \n satutation");
ids=(kp/2.0)*(w/(l-(2*xj1)))*(vgs-vt)*(1+(lamda*vds));
res=1.0;
}
if((vgs>vt)&&(vds<vt))
{
printf("\n \n linear");
ids=(kp)*(w/(l-2*xj1)) *(vgs-vt(vds/2.0))*(vds*(1+((lamda*vds))));
res=0.0;
}
if(res)
printf(" \n \n ids=%lf",ids);
else
printf("\n \n press any key");
getch();
}

You might also like