; Define helper functions procedure(isnull(value value_if_null) if(null(value) value_if_null value) ) ; Simulation Parameters T = 40.0 ; Temperature Ibias = 125u ; Integrator Amp Bias Current base_model_folder = strcat(getShellEnvVar("MODS"),"/") ;base_model_folder = "~/cds/PSDchip/MODS/mh/" model_file_no_path = "typ" model_file_no_path_0kf = strcat(model_file_no_path, ".0kf") model_file = strcat(base_model_folder, model_file_no_path) model_file_0kf = strcat(base_model_folder, model_file_no_path_0kf) results_file = "~/cds/PSDchip/excel.dat/jp/psd_opamp_specs_JP.txt" simulation_path = "~/cds/PSDchip/simulation/jp" ; Save simulation outputs to files declare(fid[2]) fid[0] = outfile(results_file "w") ; Start the simulator (Spectre). simulator( 'spectre ) total_time = listToVector(measureTime( ; Simulator open loop gain at CL = 0.5p. design(strcat(simulation_path, "/psd_opamp_measure_open_loop_gain/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_open_loop_gain/spectre/schematic")) modelFile(model_file) analysis('ac ?start ".01" ?stop "100G" ?log "1000") ;analysis('dc ?saveOppoint t) desVar("CL", 0.5p) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() ;plot( db(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac dB20(V)" ) ) ;plot( phaseDegUnwrapped(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac deg(V)" ) ) ;plot( db(v("/VOUT" ?result "ac")) '("Expr")) declare(DMGain[2]) declare(BeginIntg[2]) declare(EndIntg[2]) BestBW = bandwidth(v("/VOUT" ?result "ac"),3,"low") BestGBW = gainBwProd(v("/VOUT" ?result "ac")) WorstPM = phaseMargin(v("/VOUT" ?result "ac")) WorstGM = gainMargin(v("/VOUT" ?result "ac")) DMGain[0] = db(value(v("/VOUT" ?result "ac"), 0.1)) BeginIntg[0] = cross(phaseDegUnwrapped(v("/VOUT" ?result "ac")), -85, 1, 'falling) EndIntg[0] = cross(phaseDegUnwrapped(v("/VOUT" ?result "ac")), -95, 1, 'falling) ; Simulate open loop gain at CL = 1.5p desVar("CL", 1.5p) desVar("Ibias", Ibias) run() ;plot( db(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac dB20(V)" ) ) ;plot( phaseDegUnwrapped(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac deg(V)" ) ) WorstBW = bandwidth(v("/VOUT" ?result "ac"),3,"low") WorstGBW = gainBwProd(v("/VOUT" ?result "ac")) BestPM = phaseMargin(v("/VOUT" ?result "ac")) BestGM = gainMargin(v("/VOUT" ?result "ac")) DMGain[1] = db(value(v("/VOUT" ?result "ac"), 0.1)) BeginIntg[1] = cross(phaseDegUnwrapped(v("/VOUT" ?result "ac")), -85, 1, 'falling) EndIntg[1] = cross(phaseDegUnwrapped(v("/VOUT" ?result "ac")), -95, 1, 'falling) BestGain = max(DMGain[0], DMGain[1]) WorstGain = min(DMGain[0], DMGain[1]) delete('analysis 'ac) delete('analysis 'dc) ; Simulate common mode gain at CL = 0.5p. design(strcat(simulation_path, "/psd_opamp_measure_cm_gain/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_cm_gain/spectre/schematic")) modelFile(model_file) analysis('ac ?start ".01" ?stop "100G" ?log "1000") ;analysis('dc ?saveOppoint t) desVar("CL" 0.5p) desVar("VOS_DC" 0) desVar("VOS_AC" 0) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() ;plot(db(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac dB20(V)" ) ) ;plot(phaseDegUnwrapped(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac deg(V)" ) ) declare(CMGain[2]) declare(CMRR_1_DC[2]) CMGain[0] = db(value(v("/VOUT" ?result "ac"), 0.1)) CMRR_1_DC[0] = DMGain[0] - CMGain[0] ; Simulate common mode gain at CL = 1.5p. ;desVar("CL" 1.5p) ;run() ;plot(db(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac dB20(V)" ) ) ;plot(phaseDegUnwrapped(v("/VOUT" ?result "ac")) ?expr '( "v /VOUT; ac deg(V)" ) ) ;CMGain[1] = db(value(v("/VOUT" ?result "ac"), 0.1)) ;CMRR_1_DC[1] = DMGain[1] - CMGain[1] delete('analysis 'ac) delete('analysis 'dc) ; Simulate common mode rejection ratio at CL = 0.5p using method #1. design(strcat(simulation_path, "/psd_opamp_measure_cmrr/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_cmrr/spectre/schematic")) modelFile(model_file) analysis('ac ?start "1m" ?stop "100G" ?log "1000") ;analysis('dc ?saveOppoint t ) desVar("CL" 0.5p) desVar("VSET" 0) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() ;plot( dB20((1 / v("/VI" ?result "ac"))) ) declare(CMRR_2_DC[2]) CMRR_2_DC[0] = dB20(value((1 / v("/VI" ?result "ac")), 1m)) ; Simulate common mode rejection ratio at CL = 1.5p using method #1. ;desVar("CL" 1.5p) desVar("Ibias", Ibias) ;run() ;CMRR_2_DC[1] = dB20(value((1 / v("/VI" ?result "ac")), 1m)) ;plot( dB20((1 / v("/VI" ?result "ac"))) ) delete('analysis 'ac) delete('analysis 'dc) ; Simulate common mode rejection ratio at CL = 0.5p using method #2. design(strcat(simulation_path, "/psd_opamp_measure_cmrr_2/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_cmrr_2/spectre/schematic")) modelFile(model_file) analysis('ac ?start "1m" ?stop "100G" ?log "1000") ;analysis('dc ?saveOppoint t ) desVar("CL" 0.5p) desVar("VCM" 0) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() ;plot(db20(1 / v("/VOUT" ?result "ac")) ?expr '( "CMRR" ) ) declare(CMRR_3_DC[2]) CMRR_3_DC[0] = db20(value(1 / v("/VOUT" ?result "ac"), 1m)) delete('analysis 'ac) delete('analysis 'dc) ; Simulate power supply rejection ratio for VDD at CL = 0.5p using method #1. design(strcat(simulation_path, "/psd_opamp_measure_psrr/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_psrr/spectre/schematic")) modelFile(model_file) analysis('ac ?start "1m" ?stop "100G" ?log "1000" ) ;analysis('dc ?saveOppoint t ) desVar("CL" 0.5p) desVar("VSET" 0) desVar("PSRR_VDD" 1) desVar("PSRR_VSS" 0) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() ;plot( dB20((1 / v("/VI" ?result "ac"))) ) declare(PSRR_VDD_1_DC[2]) PSRR_VDD_1_DC[0] = dB20(value(1 / v("/VI" ?result "ac"), 1m)) ; Simulate power supply rejection ratio for VSS at CL = 0.5p using method #1. desVar("PSRR_VDD" 0) desVar("PSRR_VSS" 1) desVar("Ibias", Ibias) run() ;plot( dB20((1 / v("/VI" ?result "ac"))) ) declare(PSRR_VSS_1_DC[2]) PSRR_VSS_1_DC[0] = dB20(value(1 / v("/VI" ?result "ac"), 1m)) delete('analysis 'ac) delete('analysis 'dc) ; Simulate power supply rejection ratio for VDD at CL = 0.5p using method #2. design(strcat(simulation_path, "/psd_opamp_measure_psrr_2/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_psrr_2/spectre/schematic")) modelFile(model_file) analysis('ac ?start "1m" ?stop "100G" ) ;analysis('dc ?saveOppoint t ) desVar( "PSRR_VSS" 0 ) desVar( "PSRR_VDD" 1 ) desVar( "CL" 0.5p ) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() ;plot(db20(1 / v("/VOUT" ?result "ac")) ?expr '( "PSRR_VDD" ) ) declare(PSRR_VDD_2_DC[2]) declare(PSRR_VDD_2_BW[2]) declare(PSRR_VDD_2_40DB[2]) PSRR_VDD_2_DC[0] = db20(value(1 / v("/VOUT" ?result "ac"), 1m)) PSRR_VDD_2_BW[0] = bandwidth(1 / v("/VOUT" ?result "ac"),3,"low") PSRR_VDD_2_40DB[0] = cross(db20(1 / v("/VOUT" ?result "ac")), 40, 1, 'falling) ; Simulate power supply rejection ratio for VSS at CL = 0.5p using method #2. desVar( "PSRR_VSS" 1 ) desVar( "PSRR_VDD" 0 ) desVar("Ibias", Ibias) run() ;plot(db20(1 / v("/VOUT" ?result "ac")) ?expr '( "PSRR_VSS" ) ) declare(PSRR_VSS_2_DC[2]) declare(PSRR_VSS_2_BW[2]) declare(PSRR_VSS_2_40DB[2]) PSRR_VSS_2_DC[0] = db20(value(1 / v("/VOUT" ?result "ac"), 1m)) PSRR_VSS_2_BW[0] = bandwidth(1 / v("/VOUT" ?result "ac"),3,"low") PSRR_VSS_2_40DB[0] = cross(db20(1 / v("/VOUT" ?result "ac")), 40, 1, 'falling) delete('analysis 'ac) delete('analysis 'dc) ; Simulate output voltage swing. design(strcat(simulation_path, "/psd_opamp_measure_ovs/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_ovs/spectre/schematic")) modelFile(model_file) analysis('dc ?saveOppoint t ?param "VIN" ?start "-2.5" ?stop "2.5" ?lin "1000") desVar("R" 1G) desVar("RL" 1T) desVar("CL" 0.5p) desVar("VIN" 0) desVar("Ibias", Ibias) saveOption('currents "all") saveOption('pwr "all") saveOption('save "all") temp(T) run() T1 = deriv(v("/VOUT" ?result "dc")) T2 = (ymax(T1) + ymin(T1)) / 2 T3 = cross(T1, T2, 1, 'either) T4 = cross(T1, T2, 2, 'either) T5 = deriv(clip(v("/VOUT" ?result "dc"), T3, T4)) T6 = deriv(T5) T7 = 0.15 * (ymax(T6) - ymin(T6)) T8 = isnull(cross(T6, -T7, 1, 'either), xmin(T6)) T9 = isnull(cross(T6, T7, 1, 'either), xmax(T6)) T10 = value(v("/VOUT" ?result "dc"), T8) T11 = value(v("/VOUT" ?result "dc"), T9) MinOVS = min(T10, T11) MaxOVS = max(T10, T11) ;plot(v("/VOUT" ?result "dc") ?expr '("/VOUT")) ;plot(deriv(v("/VOUT" ?result "dc"))) ;plot(T5) ;plot(T6) ;printf("%f, %f\n", MinOVS, MaxOVS) delete('analysis 'dc) ; Simulate the output resistance. design(strcat(simulation_path, "/psd_opamp_measure_rout/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_rout/spectre/schematic")) modelFile(model_file) analysis('ac ?start "1u" ?stop "1T" ?log "1000" ) ;analysis('dc ?saveOppoint t) desVar("RL" 10k) desVar("CL" 0.5p) desVar("VIN" 0) desVar("Ibias", Ibias) saveOption( 'useprobes "yes" ) saveOption( 'currents "all" ) saveOption( 'pwr "all" ) saveOption( 'save "all" ) temp(T) run() ;selectResult( 'dc ) ;plot(getData("/VOUT2") getData("/VOUT1") ) ;selectResult( 'ac ) ;plot(getData("/VOUT2") getData("/VOUT1") ) ;ROUT = ((v("/VOUT2" ?result "ac") / i("/R2/PLUS" ?result "ac")) * ((v("/VOUT1" ?result "ac") / v("/VOUT2" ?result "ac")) - 1)) ;plot( ROUT ?expr '( "ROUT" ) ) ;plot(v("/VOUT1" ?result "dc")) ;plot(v("/VOUT2" ?result "dc")) ;plot(v("/VOUT1" ?result "ac")) ;plot(v("/VOUT2" ?result "ac")) ;plot(((v("/VOUT2" ?result "ac") / i("/R2/PLUS" ?result "ac")) * ((v("/VOUT1" ?result "ac") / v("/VOUT2" ?result "ac")) - 1)) ?expr '("ROUT")) ROUT = mag(value(((v("/VOUT2" ?result "ac") / i("/R2/PLUS" ?result "ac")) * ((v("/VOUT1" ?result "ac") / v("/VOUT2" ?result "ac")) - 1)), 1u)) delete('analysis 'ac) delete('analysis 'dc) ; Simulate settling time at CL = 0.5p. design(strcat(simulation_path, "/psd_opamp_measure_slew_rate_and_settling_time/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_slew_rate_and_settling_time/spectre/schematic")) modelFile(model_file) analysis('tran ?stop "400n" ?errpreset "conservative" ) desVar("RL" 1T) desVar("CL" 0.5p) desVar("VS" 100m) desVar("Ibias", Ibias) temp(T) run() ;plot(v("/VOUT" ?result "tran")) declare(SET_TM[2]) SET_TM[0] = settlingTime(v("/VOUT" ?result "tran"),0,t,400n,t,5) ; Simulate settling time at CL = 1.5p. desVar("CL" 1.5p) run() SET_TM[1] = settlingTime(v("/VOUT" ?result "tran"),0,t,400n,t,5) delete('analysis 'tran) ; Simulate settling time at CL = 0.5p. design(strcat(simulation_path, "/psd_opamp_measure_slew_rate_and_settling_time/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_slew_rate_and_settling_time/spectre/schematic")) modelFile(model_file) analysis('tran ?stop "400n" ?errpreset "conservative" ) desVar("RL" 1T) desVar("CL" 0.5p) desVar("VS" 2.5) desVar("Ibias", Ibias) temp(T) run() ;plot(v("/VOUT" ?result "tran")) declare(SLEW_RATE[2]) SLEW_RATE[0] = slewRate(v("/VOUT" ?result "tran"),0,t,400n,t,10,90) ; Simulate settling time at CL = 1.5p. desVar("CL" 1.5p) desVar("Ibias", Ibias) run() SLEW_RATE[1] = slewRate(v("/VOUT" ?result "tran"),0,t,400n,t,10,90) delete('analysis 'tran) BestSlewRate = SLEW_RATE[0] BestSettlingTime = SET_TM[1] WorstSlewRate = SLEW_RATE[1] WorstSettlingTime = SET_TM[0] ; Simulate all noise (1/f and thermal noise) at CL = 0.5p. design(strcat(simulation_path, "/psd_opamp_measure_noise/spectre/schematic/netlist/netlist")) resultsDir(strcat(simulation_path, "/psd_opamp_measure_noise/spectre/schematic")) modelFile(model_file) analysis('noise ?start "100k" ?stop "100G" ?log "1000" ?p "/VOUT" ?n "/gnd!" ?oprobe "" ?iprobe "VS") ;analysis('dc ?saveOppoint t) desVar("RL" 1T) desVar("CL" 0.5p) desVar("Ibias", Ibias) saveOption( 'useprobes "yes" ) saveOption( 'currents "all" ) saveOption( 'pwr "all" ) saveOption( 'save "all" ) temp(T) run() ;plot( VN() ) ;plot( VN2() ) declare(Intg_NV_All[2]) Intg_NV_All[0] = sqrt(integ(clip(VN2() 100e3 ((3.14/2)*1e7)))) ; Simulate thermal noise only at CL = 0.5p. modelFile(model_file_0kf) desVar("Ibias", Ibias) run() ;plot( VN() ) ;plot( VN2() ) declare(Intg_NV_Thermal[2]) declare(Intg_NV_FlickerOnly[2]) Intg_NV_Thermal[0] = sqrt(integ(clip(VN2() 100e3 3.14/2*1e7))) Intg_NV_FlickerOnly[0] = sqrt(Intg_NV_All[0]**2 - Intg_NV_Thermal[0]**2) ; Simulate all noise (1/f and thermal noise) at CL = 1.5p. modelFile(model_file) desVar("CL" 1.5p) desVar("Ibias", Ibias) run() ;plot( VN() ) ;plot( VN2() ) Intg_NV_All[1] = sqrt(integ(clip(VN2() 100e3 3.14/2*1e7))) ; Simulate thermal noise only at CL = 1.5p. modelFile(model_file_0kf) desVar("Ibias", Ibias) run() ;plot( VN() ) ;plot( VN2() ) Intg_NV_Thermal[1] = sqrt(integ(clip(VN2() 100e3 3.14/2*1e7))) ;Intg_NV_Thermal[1] = sqrt((integ VN2() 100e3 1e9)) delete('analysis 'noise) delete('analysis 'dc) Intg_NV_FlickerOnly[1] = sqrt(Intg_NV_All[1]**2 - Intg_NV_Thermal[1]**2) )) printf("\n") printf("\n") fprintf(fid[0], "Total user CPU time: %.1f s\n", total_time[0]) fprintf(fid[0], "Total kernel CPU time: %.1f s\n", total_time[1]) fprintf(fid[0], "Total elapsed time: %.1f s\n", total_time[2]) fprintf(fid[0], "Number of page faults: %d\n", total_time[3]) fprintf(fid[0], "\n") fprintf(fid[0], "\n") fprintf(fid[0], "For CL = 0.5p (sim)\n") fprintf(fid[0], "-----------------------\n") fprintf(fid[0], "f(-85deg): %.1f KHz \n", BeginIntg[0]*1e-3) fprintf(fid[0], "f(-95deg): %.1f MHz\n", EndIntg[0]*1e-6) fprintf(fid[0], "Intg_NV_All: %.1f uV (for f > 100 kHz)\n", Intg_NV_All[0]*1e6) fprintf(fid[0], "Intg_NV_Thermal: %.1f uV\n", Intg_NV_Thermal[0]*1e6) fprintf(fid[0], "Intg_NV_Flicker: %.1f uV\n", Intg_NV_FlickerOnly[0]*1e6) ;fprintf(fid[0], "SettlingTime: %.2f ns\n", SET_TM[0]*1e9) ;fprintf(fid[0], "SlewRate: %.1f V/us\n", SLEW_RATE[0]*1e-6) fprintf(fid[0], "DMGain: %.1f dB\n", DMGain[0]) fprintf(fid[0], "CMGain: %.1f dB\n", CMGain[0]) fprintf(fid[0], "CMRR_1_DC: %.1f dB\n", CMRR_1_DC[0]) fprintf(fid[0], "CMRR_2_DC: %.1f dB\n", CMRR_2_DC[0]) fprintf(fid[0], "CMRR_3_DC: %.1f dB\n", CMRR_3_DC[0]) fprintf(fid[0], "PSRR_VDD_1_DC: %.1f dB\n", PSRR_VDD_1_DC[0]) fprintf(fid[0], "PSRR_VDD_2_DC: %.1f dB\n", PSRR_VDD_2_DC[0]) fprintf(fid[0], "PSRR_VDD_2_BW: %.2f MHz\n", PSRR_VDD_2_BW[0]*1e-6) fprintf(fid[0], "PSRR_VDD_2_40DB: %.2f MHz\n", isnull(PSRR_VDD_2_40DB[0],0)*1e-6) fprintf(fid[0], "PSRR_VSS_1_DC: %.1f dB\n", PSRR_VSS_1_DC[0]) fprintf(fid[0], "PSRR_VSS_2_DC: %.1f dB\n", PSRR_VSS_2_DC[0]) fprintf(fid[0], "PSRR_VSS_2_BW: %.1f KHz\n", PSRR_VSS_2_BW[0]*1e-3) fprintf(fid[0], "PSRR_VSS_2_40DB %.1f KHz\n", PSRR_VSS_2_40DB[0]*1e-3) ;fprintf(fid[0], "MinOVS: %.2f V\n", MinOVS) ;fprintf(fid[0], "MaxOVS: %.2f V\n", MaxOVS) fprintf(fid[0], "OVS: %.2f - %.2f V\n", MinOVS, MaxOVS) fprintf(fid[0], "ROUT: %.3f MOhms\n", ROUT*1e-6) fprintf(fid[0], "\n") fprintf(fid[0], "\n") fprintf(fid[0], "For CL = 1.5p (sim)\n") fprintf(fid[0], "------------------------\n") fprintf(fid[0], "f(-85deg): %.1f KHz \n", BeginIntg[1]*1e-3) fprintf(fid[0], "f(-95deg): %.1f MHz\n", EndIntg[1]*1e-6) ;fprintf(fid[0], "SettlingTime: %.2f ns\n", SET_TM[1]*1e9) ;fprintf(fid[0], "SlewRate: %.1f V/us\n", SLEW_RATE[1]*1e-6) ;fprintf(fid[0], "DMGain: %.1f dB\n", DMGain[1]) ;fprintf(fid[0], "CMGain: %.1f dB\n", CMGain[1]) ;fprintf(fid[0], "CMRR_1_DC: %.1f dB\n", CMRR_1_DC[1]) ;fprintf(fid[0], "CMRR_2_DC: %.1f dB\n", CMRR_2_DC[1]) ;fprintf(fid[0], "CMRR_3_DC: %.1f dB\n", CMRR_3_DC[1]) ;fprintf(fid[0], "PSRR_1_DC: %.1f dB\n", PSRR_1_DC[1]) fprintf(fid[0], "Intg_NV_All: %.1f uV (for f > 100 kHz)\n", Intg_NV_All[1]*1e6) fprintf(fid[0], "Intg_NV_Thermal: %.1f uV\n", Intg_NV_Thermal[1]*1e6) fprintf(fid[0], "Intg_NV_Flicker: %.1f uV\n", Intg_NV_FlickerOnly[1]*1e6) fprintf(fid[0], "\n") fprintf(fid[0], "\n") ;fprintf(fid[0], "Best Case Specs\n") ;fprintf(fid[0], "----------------\n") ;fprintf(fid[0], "BW: %.1f KHz\n", BestBW*1e-3) ;fprintf(fid[0], "GBW: %.1f MHz\n", BestGBW*1e-6) ;fprintf(fid[0], "PM: %.1f deg\n", BestPM) ;fprintf(fid[0], "GM: %.1f dB\n", BestGM) ;fprintf(fid[0], "SET: %.2f ns\n", BestSettlingTime*1e9) ;fprintf(fid[0], "SR: %.1f V/us\n", BestSlewRate*1e-6) ;fprintf(fid[0], "\n") ;fprintf(fid[0], "\n") fprintf(fid[0], "Worst Case Specs\n") fprintf(fid[0], "----------------\n") fprintf(fid[0], "BW: %.1f KHz\n", WorstBW*1e-3) fprintf(fid[0], "GBW: %.1f MHz\n", WorstGBW*1e-6) fprintf(fid[0], "PM: %.1f deg\n", WorstPM) fprintf(fid[0], "GM: %.1f dB\n", WorstGM) fprintf(fid[0], "SET: %.2f ns\n", WorstSettlingTime*1e9) fprintf(fid[0], "SR: %.1f V/us\n", WorstSlewRate*1e-6) fprintf(fid[0], "\n") drain(fid[0]) close(fid[0]) inPort = infile(results_file) when(inPort while(gets(nextLine inPort) printf(nextLine) ) close(inPort) )