Wednesday, January 11, 2012

Modeling of MOSFET using ‘C’.


#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

//global input variables declaration
float vg, vs,vd,W,L;

//global constant declaration
float Vt=0.6;
float e0=3.45*pow(10,-11);
float Tox=10*pow(10,-9);
float q=1.6*pow(10,-19);
int u=700;

//global variable declaration
float Vgs,Vds,Cox,Beta,Ids;

void main()
{
          W=60*pow(10,-6);
          L=6*pow(10,-6);
          clrscr();
          printf("%e",e0);
          getchar();
          printf("\nModelling of nMOSFET\n");
          printf("\-----------------------\n");
          printf("\n Enter the value of vg:\t");
          scanf("%f",&vg);
          printf("\n Enter the value of vs:\t");
          scanf("%f",&vs);
          printf("\n Enter the value of vd:\t");
          scanf("%f",&vd);
          Vgs=vg-vs;
          Vds=vd-vs;
       printf("==========================\n");
          printf("VGS:\t%f",Vgs);
          printf("\nVDS:\t%f",Vds);
          Cox=e0/Tox;
          printf("\nCox:\t%e",Cox);
          Beta=(u*e0*W)/(Tox*L);
          printf("\nBeta:\t%e", Beta);

          if((Vds>0) && Vds< (Vgs-Vt))
          {
                      printf("\n====================\n");
                      printf("\n NMOS in linear region\n");
                      Ids=Beta*(((Vgs-Vt)*Vds)-((Vds*Vds)/2));
                      printf("\nIds:\t%e",Ids);
          }
          else if((Vgs-Vt)>0 && (Vgs-Vt)<Vds)
          {
                      printf("\n=========================\n");
                      printf("\n NMOS in saturation region\n");
                      Ids=Beta*(((Vgs-Vt)*(Vgs-Vt))/2);
                      printf("\nIds:\t%e",Ids);
          }
          else
          {
                      printf("\n===========================\n");
                      printf("\n NMOS in Cutoff Region\n");
                      Ids=0;
                      printf("\nIds:\t%e",Ids);
          }
          getch();
          }

No comments:

Post a Comment