blob: 113ebeccbfebd4594c3b7c7d7b2e0d23eba32793 [file] [log] [blame]
Tim Edwards367711e2021-01-27 10:35:12 -05001#! /bin/csh
2
3set spice = /usr/local/bin/ngspice
4
5if( $#argv != 3 ) then
6 echo "usage: getres nmodel_file pmodel_file dev_file"
7 exit 1
8endif
9
10if( ! -f $1 ) then
11 echo "can't open spice nfet model file '"$1"'"
12 exit 1
13endif
14
15if( ! -f $2 ) then
16 echo "can't open spice pfet model file '"$2"'"
17 exit 1
18endif
19
20if( -f $argv[3] ) then
21 source $argv[3]
22else
23 echo "can't open device configuration file '"$argv[3]"'"
24 exit 1
25endif
26
27set nmos = `grep -i "\.MODEL" $1 | grep -i NMOS`
28set pmos = `grep -i "\.MODEL" $1 | grep -i PMOS`
29
30if( $#nmos == 0 ) then
31 echo "can't find nmos .MODEL card in '"$1"'"
32 exit 1
33endif
34if( $#pmos == 0 ) then
35 echo "can't find pmos .MODEL card in '"$1"'"
36 exit 1
37endif
38
39cat $1 ckt.spi > tmp.spi
40
41ed - <<end tmp.spi >& /dev/null
42g/N_FET/s/N_FET/$nmos[2]/g
43g/P_FET/s/P_FET/$pmos[2]/g
44g/C_LOAD/s/C_LOAD/$cap/g
45g/N_WITH/s/N_WITH/$nwith/g
46g/N_LEN/s/N_LEN/$nlen/g
47g/P_WITH/s/P_WITH/$pwith/g
48g/P_LEN/s/P_LEN/$plen/g
49w
50q
51end
52
53$spice -n -b -r spi.out tmp.spi
54
55if( $status != 0 ) then
56 echo "something went wrong with spice, look at 'tmp.spi'"
57 exit 1
58endif
59
60./findr -c $cap -n $nwith,$nlen -p $pwith,$plen spi.out |& tee resists