Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mosfet.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  mosfet.cpp
3  ------------
4  begin : Fri Jun 4 2004
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "mosfet.h"
19 #include "node.h"
20 
21 
23 {
24  // properties obtained from "Basic_MOSFET" in mosfet_sub.cpp
25  Description = QObject::tr("MOS field-effect transistor");
26  createSymbol();
27  tx = x2+4;
28  ty = y1+4;
29  Model = "_MOSFET";
30 }
31 
32 // -------------------------------------------------------
34 {
35  MOSFET* p = new MOSFET();
36  p->Props.first()->Value = Props.first()->Value;
37  p->Props.next()->Value = Props.next()->Value;
38  p->recreate(0);
39  return p;
40 }
41 
42 // -------------------------------------------------------
43 Element* MOSFET::info(QString& Name, char* &BitmapFile, bool getNewOne)
44 {
45  Name = QObject::tr("n-MOSFET");
46  BitmapFile = (char *) "nmosfet";
47 
48  if(getNewOne) return new MOSFET();
49  return 0;
50 }
51 
52 // -------------------------------------------------------
53 Element* MOSFET::info_p(QString& Name, char* &BitmapFile, bool getNewOne)
54 {
55  Name = QObject::tr("p-MOSFET");
56  BitmapFile = (char *) "pmosfet";
57 
58  if(getNewOne) {
59  MOSFET* p = new MOSFET();
60  p->Props.first()->Value = "pfet";
61  p->Props.next()->Value = "-1.0 V";
62  p->recreate(0);
63  return p;
64  }
65  return 0;
66 }
67 
68 // -------------------------------------------------------
69 Element* MOSFET::info_depl(QString& Name, char* &BitmapFile, bool getNewOne)
70 {
71  Name = QObject::tr("depletion MOSFET");
72  BitmapFile = (char *) "dmosfet";
73 
74  if(getNewOne) {
75  MOSFET* p = new MOSFET();
76  p->Props.first();
77  p->Props.next()->Value = "-1.0 V";
78  p->recreate(0);
79  return p;
80  }
81  return 0;
82 }
83 
84 // -------------------------------------------------------
86 {
87  Lines.append(new Line(-14,-13,-14, 13,QPen(Qt::darkBlue,3)));
88  Lines.append(new Line(-30, 0,-14, 0,QPen(Qt::darkBlue,2)));
89 
90  Lines.append(new Line(-10,-11, 0,-11,QPen(Qt::darkBlue,2)));
91  Lines.append(new Line( 0,-11, 0,-30,QPen(Qt::darkBlue,2)));
92  Lines.append(new Line(-10, 11, 0, 11,QPen(Qt::darkBlue,2)));
93  Lines.append(new Line( 0, 0, 0, 30,QPen(Qt::darkBlue,2)));
94  Lines.append(new Line(-10, 0, 0, 0,QPen(Qt::darkBlue,2)));
95 
96  Lines.append(new Line(-10,-16,-10, -7,QPen(Qt::darkBlue,3)));
97  Lines.append(new Line(-10, 7,-10, 16,QPen(Qt::darkBlue,3)));
98 
99  if(Props.first()->Value == "nfet") {
100  Lines.append(new Line( -9, 0, -4, -5,QPen(Qt::darkBlue,2)));
101  Lines.append(new Line( -9, 0, -4, 5,QPen(Qt::darkBlue,2)));
102  }
103  else {
104  Lines.append(new Line( -1, 0, -6, -5,QPen(Qt::darkBlue,2)));
105  Lines.append(new Line( -1, 0, -6, 5,QPen(Qt::darkBlue,2)));
106  }
107 
108  if((Props.next()->Value.stripWhiteSpace().at(0) == '-') ==
109  (Props.first()->Value == "nfet"))
110  Lines.append(new Line(-10, -8,-10, 8,QPen(Qt::darkBlue,3)));
111  else
112  Lines.append(new Line(-10, -4,-10, 4,QPen(Qt::darkBlue,3)));
113 
114  Ports.append(new Port(-30, 0));
115  Ports.append(new Port( 0,-30));
116  Ports.append(new Port( 0, 30));
117 
118  x1 = -30; y1 = -30;
119  x2 = 4; y2 = 30;
120 }
121 
122 // -------------------------------------------------------
124 {
125  QString s = "MOSFET:"+Name;
126 
127  // output all node names
128  for(Port *p1 = Ports.first(); p1 != 0; p1 = Ports.next())
129  s += " "+p1->Connection->Name; // node names
130  s += " "+Ports.at(2)->Connection->Name; // connect substrate to source
131 
132  // output all properties
133  for(Property *p2 = Props.first(); p2 != 0; p2 = Props.next())
134  s += " "+p2->Name+"=\""+p2->Value+"\"";
135 
136  return s + '\n';
137 }
Q3PtrList< Line > Lines
Definition: component.h:67
int y1
Definition: element.h:153
static Element * info_p(QString &, char *&, bool getNewOne=false)
Definition: mosfet.cpp:53
static Element * info_depl(QString &, char *&, bool getNewOne=false)
Definition: mosfet.cpp:69
int tx
Definition: component.h:78
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
int ty
Definition: component.h:78
Q3PtrList< Property > Props
Definition: component.h:72
QString netlist()
Definition: mosfet.cpp:123
Definition: mosfet.h:24
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
void recreate(Schematic *)
Definition: component.cpp:1250
Q3PtrList< Port > Ports
Definition: component.h:70
QString Name
Definition: component.h:80
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
MOSFET()
Definition: mosfet.cpp:22
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: mosfet.cpp:43
Component * newOne()
Definition: mosfet.cpp:33
int x2
Definition: element.h:153
void createSymbol()
Definition: mosfet.cpp:85