This file is indexed.

/usr/share/octave/packages/ocs-0.1.5/sbn/Mshichmanhodgesmosfet.m is in octave-ocs 0.1.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
## Copyright (C) 2006-2009  Carlo de Falco, Massimiliano Culpo
##
## This file is part of:
## OCS - A Circuit Simulator for Octave
##
## OCS is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program (see the file LICENSE); if not,
## see <http://www.gnu.org/licenses/>.
##
## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>, culpo@math.uni-wuppertal.de

## -*- texinfo -*-
##
## @deftypefn{Function File} @
## {[@var{a},@var{b},@var{c}]=} Mshichmanhodgesmosfet(@var{string},@var{parameters},@
## @var{parameternames},@var{extvar},@var{intvar},@var{t})
##
## SBN file implementing Schichman-Hodges MOSFETs model.
##
## @var{string} is used to select among models. Possible models are:
##
## @enumerate
## @item @var{string} = "NMOS" (Schichman-Hodges n-MOSFET)
## @item @var{string} = "PMOS" (Schichman-Hodges p-MOSFET)
## @end enumerate
##
## Parameters for all the above models are:
## @itemize
## @item rd     -> parasitic resistance between drain and source
## @item W      -> MOSFET width
## @item L      -> channel length
## @item mu0    -> reference value for mobility
## @item Vth    -> threshold voltage
## @item Cox    -> oxide capacitance
## @item Cgs    -> gate-source capacitance
## @item Cgd    -> gate-drain capacitance
## @item Cgb    -> gate-bulk capacitance
## @item Csb    -> source-bulk capacitance
## @item Cdb    -> drain-bulk capacitance
## @item Tshift -> shift for reference temperature on MOSFETs (default 0)
## @end itemize
##
## See the @cite{IFF file format specifications} for details about 
## the output structures.
##
## @seealso{prs_iff,asm_initialize_system,asm_build_system}
## @end deftypefn

function [a,b,c]= Mshichmanhodgesmosfet (string,parameters,parameternames,extvar,intvar,t)   

  if isempty(intvar)
    ## If intvar is empty, then we are initializing the system
    ## and there is no need of a matrix evaluation
    a = sparse(10,10);
    b = [];
    c = [];
  else
    ## If intvar is NOT empty, then we are evaluating the 
    ## element stamp
    switch string
      case "NMOS"
	
	rd   = 1e6;
	W    = 1;
	L    = 1;
	mu0  = 1e-5;
	Vth  = .5;
	Cox  = 1e-9;
	Cgb  = Cox;
	Cgs=Cgd=Csb=Cdb=.1*Cox;
	Tshift = 0;

	for ii=1:length(parameternames)
	  eval([parameternames{ii} "=",...
		num2str(parameters(ii)) " ;"])	
	endfor

	[gm,gd,ids,didT,P,dPdT,dPdvgs,dPdvds] = ...
	    nmos(extvar,mu0,Cox,W,L,Vth,rd,Tshift);

	vg   = extvar(1);
	vs   = extvar(2);
	vd   = extvar(3);
	vb   = extvar(4);
	T    = max(extvar(5),0);
	
	if isempty(intvar)
	  intvar = zeros(5,1);
	endif
	
	Qgb  = intvar(1);
	Qgs  = intvar(2);
	Qgd  = intvar(3);
	Qsb  = intvar(4);
	Qdb  = intvar(5);
	
	a11 = a21 = a22 = zeros(5,5);
	a12 = [ 1  1  1  0  0; ...
	       0 -1  0  1  0; ...
	       0  0 -1  0  1; ...
	       -1  0  0 -1 -1; ...
	       0  0  0  0  0];

	a   = [a11 a12; a21 a22];

	b11 = [0        0                0      0     0; ...
	       -gm      (gm+gd)         -gd     0 -didT; ...
	       gm      -(gm+gd)          gd     0  didT; ...
	       0        0                0      0     0; ...
	       dPdvgs  -(dPdvgs+dPdvds)  dPdvds 0  dPdT];

	b12 = zeros(5,5);

	b21 = [Cgb  0        0   -Cgb  0; ...
	       Cgs -Cgs      0    0    0; ...
	       Cgd  0       -Cgd  0    0; ...
	       0    Csb      0   -Csb  0; ...
	       0    0        Cdb -Cdb  0];
	b22 = -eye(5);

	b   = [b11 b12; b21 b22];
	
	
	c1 = [0; -ids; ids; 0; P];

	c2 = [Cgb*(vg - vb) - Qgb;...
	      Cgs*(vg - vs) - Qgs;...
	      Cgd*(vg - vd) - Qgd;...
	      Csb*(vs - vb) - Qsb;...
	      Cdb*(vd - vb) - Qdb];
	
	c = [c1;c2];
	

	break;

      case "PMOS"
	
	rd   = 1e6;
	W    = 1;
	L    = 1;
	mu0  = 1e-5;
	Vth  = -.5;
	Cox  = 1e-9;
	Cgb=Cox;
	Cgs=Cgd=Csb=Cdb=.1*Cox;
	Tshift = 0;

	for ii=1:length(parameternames)
	  eval([parameternames{ii} "=",...
		num2str(parameters(ii)) " ;"])	
	endfor

	[gm,gd,ids,didT,P,dPdT,dPdvgs,dPdvds] = ...
	    pmos(extvar,mu0,Cox,W,L,Vth,rd,Tshift);

	
	vg   = extvar(1);
	vs   = extvar(2);
	vd   = extvar(3);
	vb   = extvar(4);
	T    = extvar(5);

	if isempty(intvar)
	  intvar = zeros(5,1);
	endif

	Qgb  = intvar(1);
	Qgs  = intvar(2);
	Qgd  = intvar(3);
	Qsb  = intvar(4);
	Qdb  = intvar(5);
	
	a11 = a21 = a22 = zeros(5,5);
	a12 = [ 1  1  1  0  0; ...
	       0 -1  0  1  0; ...
	       0  0 -1  0  1; ...
	       -1  0  0 -1 -1; ...
	       0  0  0  0  0];

	a   = [a11 a12; a21 a22];
	
	b11 = [0        0                0      0     0; ...
	       -gm      (gm+gd)         -gd     0 -didT; ...
	       gm      -(gm+gd)          gd     0  didT; ...
	       0        0                0      0     0; ...
	       dPdvgs  -(dPdvgs+dPdvds)  dPdvds 0  dPdT];

	b12 = zeros(5,5);

	b21 = [Cgb  0        0   -Cgb  0; ...
	       Cgs -Cgs      0    0    0; ...
	       Cgd  0       -Cgd  0    0; ...
	       0    Csb      0   -Csb  0; ...
	       0    0        Cdb -Cdb  0];
	
	b22 = -eye(5);

	b   = [b11 b12; b21 b22];
	
	
	c1 = [0; -ids; ids; 0; P];

	c2 = [Cgb*(vg - vb) - Qgb;...
	      Cgs*(vg - vs) - Qgs;...
	      Cgd*(vg - vd) - Qgd;...
	      Csb*(vs - vb) - Qsb;...
	      Cdb*(vd - vb) - Qdb];
	
	c = [c1;c2];
	
	break;

      otherwise
	error(["unknown option:" string]);
    endswitch
  endif
  
endfunction

function [gm,gd,ids,didT,P,dPdT,dPdvgs,dPdvds] = nmos(extvar,mu0,Cox,W,L,Vth,rd,Tshift)
  ##Computes values for nmos case
  
  vg   = extvar(1);
  vs   = extvar(2);
  vd   = extvar(3);
  vb   = extvar(4);
  T    = max(extvar(5),0);

  k    = mu0*Cox*((T + Tshift)/300)^(-3/2)*W/L;
  dkdT = mu0*Cox*W*(-3/2)*((T + Tshift)/300)^(-5/2)*(1/300)/L;
  
  vgs  = vg-vs;
  vds  = vd-vs;
  
  if (vgs < Vth)
    
    gm  = 0;
    gd  = 1/rd;
    ids = vds*gd;
    didT= 0;
    
  elseif (((vgs-Vth) >= (vds)) && (vds >= 0))
    
    ids = k*((vgs-Vth)*vds-(vds^2)/2)+vds/rd;
    gm  = k*vds;
    gd  = k*(vgs-Vth-vds) + 1/rd;
    didT= dkdT*((vgs-Vth)*vds-(vds^2)/2);
    
  elseif (((vgs-Vth) >= (vds)) && (vds < 0))
    
    gm  = 0;
    gd  = 1/rd;
    ids = vds*gd;
    didT= 0;
    
  else # (i.e. if 0 <= vgs-vth <= vds)
    
    ids = (k/2)*(vgs-Vth)^2+vds/rd;
    gm  = k*(vgs-Vth);
    gd  = 1/rd;
    didT= (dkdT/(2))*(vgs-Vth)^2;
    
  endif
  
  P       = -ids * vds;
  dPdT    = -didT* vds;
  dPdvgs  = -(gm*vds);
  dPdvds  = -(gd*vds + ids);

endfunction

function [gm,gd,ids,didT,P,dPdT,dPdvgs,dPdvds] = pmos(extvar,mu0,Cox,W,L,Vth,rd,Tshift)
  ##Computes values for pmos case

  vg   = extvar(1);
  vs   = extvar(2);
  vd   = extvar(3);
  vb   = extvar(4);
  T    = extvar(5);

  k    = - mu0 * Cox * ((T + Tshift)/300)^(-3/2) *W/L;
  dkdT = - mu0 * Cox * W *(-3/2)*((T + Tshift)/300)^(-5/2)*(1/300)/L;

  vgs  = vg-vs;
  vds  = vd-vs;

  if (vgs > Vth)
    
    gm  = 0;
    gd  = 1/rd;
    ids = vds*gd;
    didT= 0;

  elseif (((vgs-Vth) <= (vds)) && (vds <= 0))
    
    ids = k*((vgs-Vth)*vds-(vds^2)/2)+vds/rd;
    gm  = k*vds;
    gd  = k*(vgs-Vth-vds)+1/rd;
    didT= dkdT*((vgs-Vth)*vds-(vds^2)/2);

  elseif (((vgs-Vth) <= (vds)) && (vds > 0))
    
    gm  = 0;
    gd  = 1/rd;
    ids = vds*gd;
    didT= 0;

  else 

    ids = (k/2)*(vgs-Vth)^2+vds/rd;
    gm  = k*(vgs-Vth);
    gd  = 1/rd;
    didT= (dkdT/(2))*(vgs-Vth)^2;

  endif
  
  P    = -ids * vds;
  dPdT = -didT* vds;
  dPdvgs  = -(gm*vds);
  dPdvds  = -(gd*vds + ids);
  
endfunction