1 ## Copyright (C) 2006,2007,2008 Carlo de Falco
3 ## This file is part of:
4 ## OCS - A Circuit Simulator for Octave
6 ## OCS is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation.
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program (see the file LICENSE); if not,
17 ## see <http://www.gnu.org/licenses/>.
19 ## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
23 ## @deftypefn{Function File} @
24 ## {[@var{a},@var{b},@var{c}]=}Mnmosfet(@var{string},@var{parameters},@
25 ## @var{parameternames},@var{extvar},@var{intvar},@var{t})
27 ## SBN file implementing standard models for n-mosfets.
29 ## @var{string} is used to select among models. Parameters are listed
30 ## as inner items. Possible models are:
33 ## @item @var{string} = "simple" (Standard model for MOSFET)
35 ## @item rd -> parasitic resistance between drain and source
36 ## @item k -> k parameter for usual mosfet model
37 ## @item Vth -> threshold voltage
39 ## @item @var{string} = "lincap" (Adds RC parasitics)
41 ## @item rd -> parasitic resistance between drain and source
42 ## @item k -> k parameter for usual mosfet model
43 ## @item Vth -> threshold voltage
44 ## @item Rs -> parasitic source resistance
45 ## @item Rd -> parasitic drain resistance
46 ## @item Cs -> gate-source capacitance
47 ## @item Cd -> gate-drain capacitance
48 ## @item Cb -> gate-bulk capacitance
52 ## See the @cite{IFF file format specifications} for details about
53 ## the output structures.
55 ## @seealso{prs_iff,asm_initialize_system,asm_build_system}
58 function [a,b,c]=Mnmosfet(string,parameters,parameternames,extvar,intvar,t)
67 for ii=1:length(parameternames)
68 eval([parameternames{ii} "=",...
69 num2str(parameters(ii)) " ;"])
87 elseif (((vgs-Vth) >= (vds)) && (vds>=0))
89 id = k*((vgs-Vth)*vds-(vds^2)/2)+vds/rd;
91 gd = k*(vgs-Vth-vds)+1/rd;
93 elseif (((vgs-Vth) >= (vds)) && (vds<0))
99 else # (i.e. if 0 <= vgs-vth <= vds)
101 id = (k/(2))*(vgs-Vth)^2+vds/rd;
102 gm = (2*k/(2))*(vgs-Vth);
119 ## Default parameter values
123 Rs = 1e2; Rd = 1e2; Cs = 1e-15;
124 Cd = 1e-15; Cb = 1e-14;
125 rd = inf; k = 1e-3; Vth = .1;
127 ## parameters given in input
128 for ii=1:length(parameternames)
129 eval([parameternames{ii} "=",...
130 num2str(parameters(ii)) " ;"])
136 if isempty(tmpstruct)
138 mtdnmos = file_in_path(path,"Mtdnmos.cir");
139 mtdnmos(end-3:end)=[];
140 tmpstruct = prs_iff(mtdnmos);
145 tmpstruct.NLC.pvmatrix = [k Vth rd];
146 tmpstruct.LCR(1).pvmatrix = [Rs; Rd];
147 tmpstruct.LCR(2).pvmatrix = [Cs; Cd; Cb];
149 [A0,B,C] = asm_initialize_system(tmpstruct,[extvar;intvar]);
150 [A1,Jac,res] = asm_build_system(tmpstruct,[extvar;intvar],t);
154 c = res + B*[extvar;intvar] + C;
158 error(["unknown option:" string]);