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