#!/bin/awk -f # convert an hspiceS flat netlist into sim format # assumes: last char of model name is N/P for nmos/pmos designation # length is in format xxxE-9 # width is in format xxxE-6 # 1 is vdd # 0 is vdd # does not care in any way for a scaling factor BEGIN { firstLine = 1 ; gotScale = 0; firstFet = 1; scale = -100; } $1 ~ /^[m|M]/ { sl = $7; sw = $8; ll = length(sl); lw = length(sw); l = substr(sl, 3, ll-5); l = l/1000; w = substr(sw, 3, lw-5); drain = $2; gate = $3; source = $4; if(drain=="0") drain="gnd"; if(drain=="1") drain="vdd"; if(gate=="0") gate="gnd"; if(gate=="1") gate="vdd"; if(source=="0") source="gnd"; if(source=="1") source="vdd"; model = $6; lmodel = length(model); mos = substr(model,lmodel,1); if(mos=="N") mos="n"; if(mos=="P") mos="p"; printf "%s %s %s %s %.2f %.2f\n", mos, gate, source, drain, l, w; }