Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/components/mosfet.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                                 mosfet.cpp
00003                                ------------
00004     begin                : Fri Jun 4 2004
00005     copyright            : (C) 2003 by Michael Margraf
00006     email                : michael.margraf@alumni.tu-berlin.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "mosfet.h"
00019 #include "node.h"
00020 
00021 
00022 MOSFET::MOSFET()
00023 {
00024   // properties obtained from "Basic_MOSFET" in mosfet_sub.cpp
00025   Description = QObject::tr("MOS field-effect transistor");
00026   createSymbol();
00027   tx = x2+4;
00028   ty = y1+4;
00029   Model = "_MOSFET";
00030 }
00031 
00032 // -------------------------------------------------------
00033 Component* MOSFET::newOne()
00034 {
00035   MOSFET* p = new MOSFET();
00036   p->Props.first()->Value = Props.first()->Value;
00037   p->Props.next()->Value = Props.next()->Value;
00038   p->recreate(0);
00039   return p;
00040 }
00041 
00042 // -------------------------------------------------------
00043 Element* MOSFET::info(QString& Name, char* &BitmapFile, bool getNewOne)
00044 {
00045   Name = QObject::tr("n-MOSFET");
00046   BitmapFile = (char *) "nmosfet";
00047 
00048   if(getNewOne)  return new MOSFET();
00049   return 0;
00050 }
00051 
00052 // -------------------------------------------------------
00053 Element* MOSFET::info_p(QString& Name, char* &BitmapFile, bool getNewOne)
00054 {
00055   Name = QObject::tr("p-MOSFET");
00056   BitmapFile = (char *) "pmosfet";
00057 
00058   if(getNewOne) {
00059     MOSFET* p = new MOSFET();
00060     p->Props.first()->Value = "pfet";
00061     p->Props.next()->Value = "-1.0 V";
00062     p->recreate(0);
00063     return p;
00064   }
00065   return 0;
00066 }
00067 
00068 // -------------------------------------------------------
00069 Element* MOSFET::info_depl(QString& Name, char* &BitmapFile, bool getNewOne)
00070 {
00071   Name = QObject::tr("depletion MOSFET");
00072   BitmapFile = (char *) "dmosfet";
00073 
00074   if(getNewOne) {
00075     MOSFET* p = new MOSFET();
00076     p->Props.first();
00077     p->Props.next()->Value = "-1.0 V";
00078     p->recreate(0);
00079     return p;
00080   }
00081   return 0;
00082 }
00083 
00084 // -------------------------------------------------------
00085 void MOSFET::createSymbol()
00086 {
00087   Lines.append(new Line(-14,-13,-14, 13,QPen(Qt::darkBlue,3)));
00088   Lines.append(new Line(-30,  0,-14,  0,QPen(Qt::darkBlue,2)));
00089 
00090   Lines.append(new Line(-10,-11,  0,-11,QPen(Qt::darkBlue,2)));
00091   Lines.append(new Line(  0,-11,  0,-30,QPen(Qt::darkBlue,2)));
00092   Lines.append(new Line(-10, 11,  0, 11,QPen(Qt::darkBlue,2)));
00093   Lines.append(new Line(  0,  0,  0, 30,QPen(Qt::darkBlue,2)));
00094   Lines.append(new Line(-10,  0,  0,  0,QPen(Qt::darkBlue,2)));
00095 
00096   Lines.append(new Line(-10,-16,-10, -7,QPen(Qt::darkBlue,3)));
00097   Lines.append(new Line(-10,  7,-10, 16,QPen(Qt::darkBlue,3)));
00098 
00099   if(Props.first()->Value == "nfet") {
00100     Lines.append(new Line( -9,  0, -4, -5,QPen(Qt::darkBlue,2)));
00101     Lines.append(new Line( -9,  0, -4,  5,QPen(Qt::darkBlue,2)));
00102   }
00103   else {
00104     Lines.append(new Line( -1,  0, -6, -5,QPen(Qt::darkBlue,2)));
00105     Lines.append(new Line( -1,  0, -6,  5,QPen(Qt::darkBlue,2)));
00106   }
00107 
00108   if((Props.next()->Value.trimmed().at(0) == '-') ==
00109      (Props.first()->Value == "nfet"))
00110     Lines.append(new Line(-10, -8,-10,  8,QPen(Qt::darkBlue,3)));
00111   else
00112     Lines.append(new Line(-10, -4,-10,  4,QPen(Qt::darkBlue,3)));
00113   
00114   Ports.append(new Port(-30,  0));
00115   Ports.append(new Port(  0,-30));
00116   Ports.append(new Port(  0, 30));
00117 
00118   x1 = -30; y1 = -30;
00119   x2 =   4; y2 =  30;
00120 }
00121 
00122 // -------------------------------------------------------
00123 QString MOSFET::netlist()
00124 {
00125   QString s = "MOSFET:"+Name;
00126 
00127   // output all node names
00128   foreach(Port *p1, Ports)
00129     s += " "+p1->Connection->Name;   // node names
00130   s += " "+Ports.at(2)->Connection->Name;  // connect substrate to source
00131 
00132   // output all properties
00133   for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next())
00134     s += " "+p2->Name+"=\""+p2->Value+"\"";
00135 
00136   return s + '\n';
00137 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines