Simplify the NMOS or PMOS selection by setting only one parameter

'mostype'
ngspice-37+ is required.
This commit is contained in:
Holger Vogt 2022-07-24 15:51:59 +02:00
parent 8038021369
commit a69dd1bcde
2 changed files with 85 additions and 36 deletions

View File

@ -1,25 +1,29 @@
** NMOSFET: table generator with BSIM4 2D (Vdrain, Vgate)
* This file may be run by 'ngspice table-generator-b4-2d.sp'
* It will generate a 2D data table by simulating the MOS drain current
* It will generate a 2D data table by simulating the MOS drain current
* as function of drain and gate voltages. The simulation uses
* the ngspice BSIM4.6.1 MOS model and Berkeley model parameters.
* This table is an input file for the XSPICE 2D table model.
* You have to select NMOS or PMOS by manually editing this file: currently
* PMOS is selected. For NMOS change '*' in column 1
* for CSPARAM, m1, outfile, echo *table...
* You have to select NMOS or PMOS by manually editing parameter
* 'mostype'.
* In addition you may change the step sizes vdstep vgstep vbstep in CSPARAM
* to obtain the required resolution for the data.
* These tables will contain pure dc data. For transient simulation you may
* need to add some capacitors to the device model for a 'real world' simulation.
*NMOS
*.csparam vdstart=-0.1
*.csparam vdstop=1.8
*.csparam vdstep=0.05
*.csparam vgstart=-0.1
*.csparam vgstop=1.8
*.csparam vgstep=0.05
* setting the MOS type (NMOS or PMOS)
.param mostype = 2 ; NMOS, 2 for PMOS
.if (mostype == 1)
*NMOS
.csparam vdstart=-0.1
.csparam vdstop=1.8
.csparam vdstep=0.01
.csparam vgstart=-0.1
.csparam vgstop=1.8
.csparam vgstep=0.01
.csparam mtype=1
.elseif (mostype == 2)
*PMOS
.csparam vdstart=-1.8
.csparam vdstop=0.1
@ -27,22 +31,41 @@
.csparam vgstart=-1.8
.csparam vgstop=0.1
.csparam vgstep=0.01
.csparam mtype=2
.endif
** Circuit Description **
*m1 2 1 3 0 nbsim4 L=0.13u W=10.0u rgeoMod=1
.if (mostype == 1)
m1 2 1 3 0 nbsim4 L=0.13u W=10.0u rgeoMod=1
.elseif (mostype == 2)
m1 2 1 3 0 pbsim4 L=0.13u W=10.0u rgeoMod=1
.endif
vgs 1 0 1.8
vds 2 0 1.8
vss 3 0 0
.control
** output file **
*set outfile = "bsim4n-2d-1.table"
set outfile = "bsim4p-2d-1.table"
echo
if mtype = 1
set outfile = "$inputdir/bsim4n-2d-1.table"
echo nmos table generation , table is written to
echo $outfile
else
if mtype = 2
set outfile = "$inputdir/bsim4p-2d-1.table"
echo pmos table generation , table is written to
echo $outfile
end
end
echo
save i(vss)
*echo *table for nmos bsim 4 > $outfile
echo *table for pmos bsim 4 > $outfile
if mtype = 1
echo *table for nmos bsim 4 > $outfile
else
echo *table for pmos bsim 4 > $outfile
end
let xcount = floor((vdstop-vdstart)/vdstep) + 1
let ycount = floor((vgstop-vgstart)/vgstep) + 1
@ -95,7 +118,10 @@ end
.endc
.include ./modelcards/modelcard.pmos
.if (mostype == 1)
.include ./modelcards/modelcard.nmos
.elseif (mostype == 2)
.include ./modelcards/modelcard.pmos
.endif
.end

View File

@ -1,17 +1,20 @@
** NMOSFET: table generator with BSIM4 3D (Vdrain, Vgate, Vbulk)
* This file may be run by 'ngspice table-generator-b4-3d.sp'
* It will generate a 3D data table by simulating the MOS drain current
* It will generate a 3D data table by simulating the MOS drain current
* as function of drain and gate voltages. The simulation uses
* the ngspice BSIM4.6.1 MOS model and Berkeley model parameters.
* This table is an input file for the XSPICE 3D table model.
* You have to select NMOS or PMOS by manually editing this file: currently
* NMOS is selected. For PMOS change '*' in column 1
* for CSPARAM, m1, outfile, echo *table...
* You have to select NMOS or PMOS by manually editing parameter
* 'mostype'.
* In addition you may change the step sizes vdstep vgstep vbstep in CSPARAM
* to obtain the required resolution for the data.
* These tables will contain pure dc data. For transient simulation you may
* need to add some capacitors to the device model for a 'real world' simulation.
* setting the MOS type (NMOS or PMOS)
.param mostype = 1 ; NMOS, 2 for PMOS
.if (mostype == 1)
*NMOS
.csparam vdstart=-0.1
.csparam vdstop=1.8
@ -22,21 +25,27 @@
.csparam vbstart=-1.8
.csparam vbstop=0.4
.csparam vbstep=0.2
.csparam mtype=1
.elseif (mostype == 2)
*PMOS
*.csparam vdstart=-1.8
*.csparam vdstop=0.1
*.csparam vdstep=0.05
*.csparam vgstart=-1.8
*.csparam vgstop=0.1
*.csparam vgstep=0.05
*.csparam vbstart=-0.4
*.csparam vbstop=1.8
*.csparam vbstep=0.2
.csparam vdstart=-1.8
.csparam vdstop=0.1
.csparam vdstep=0.05
.csparam vgstart=-1.8
.csparam vgstop=0.1
.csparam vgstep=0.05
.csparam vbstart=-0.4
.csparam vbstop=1.8
.csparam vbstep=0.2
.csparam mtype=2
.endif
** Circuit Description **
.if (mostype == 1)
m1 2 1 3 4 nbsim4 L=0.13u W=10.0u rgeoMod=1
*m1 2 1 3 4 pbsim4 L=0.13u W=10.0u rgeoMod=1
.elseif (mostype == 2)
m1 2 1 3 4 pbsim4 L=0.13u W=10.0u rgeoMod=1
.endif
vgs 1 0 1.8
vds 2 0 1.8
vss 3 0 0
@ -44,12 +53,26 @@ vbs 4 0 0
.control
** output file **
set outfile = "bsim4n-3d-1.table"
*set outfile = "bsim4p-3d-1.table"
echo
if mtype = 1
set outfile = "$inputdir/bsim4n-3d-1.table"
echo nmos table generation , table is written to
echo $outfile
else
if mtype = 2
set outfile = "$inputdir/bsim4p-3d-1.table"
echo pmos table generation , table is written to
echo $outfile
end
end
echo
save i(vss)
echo * 3D table for nmos bsim 4 > $outfile
*echo * 3D table for nmos bsim 4 > $outfile
if mtype = 1
echo * 3D table for nmos bsim 4 > $outfile
else
echo * 3D table for nmos bsim 4 > $outfile
end
let xcount = floor((vdstop-vdstart)/vdstep) + 1
let ycount = floor((vgstop-vgstart)/vgstep) + 1