From a89e5db571b9149eeef818705946b87596779f83 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Thu, 21 Mar 2019 20:13:27 +0100 Subject: [PATCH] creating a linearized cutout of the original vector by defining the vectors lin-tstart, lin-tstop, and lin-tstep before issuing the 'linearize' command --- examples/soi/ring51_40.sp | 8 +++++++- src/frontend/linear.c | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/examples/soi/ring51_40.sp b/examples/soi/ring51_40.sp index b3ee80623..0c833466a 100644 --- a/examples/soi/ring51_40.sp +++ b/examples/soi/ring51_40.sp @@ -15,7 +15,7 @@ cout buf ss 1pF * this is needed .option reltol=1e-4 -.tran 0.2n 10n +.tran 0.2n 16n .print tran v(out25) v(out50) .include ./bsim4soi/nmos4p0.mod .include ./bsim4soi/pmos4p0.mod @@ -46,8 +46,14 @@ xinv5 dd ss sub 4 out inv5 if $?batchmode * do nothing else + save out25 out50 run plot out25 out50 + let lin-tstart = 4n $ skip the start-up phase + let lin-tstop = 14n $ end earlier(just for demonstration) + let lin-tstep = 5p + linearize out25 out50 + plot out25 out50 endif .endc diff --git a/src/frontend/linear.c b/src/frontend/linear.c index 749481f47..63c622b41 100644 --- a/src/frontend/linear.c +++ b/src/frontend/linear.c @@ -17,6 +17,8 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group * we determine by looking at the transient parameters in the CKT struct. * If no circuit is loaded, e.g. because the 'load' command has been used * to obtain data, try to get parameters from scale vector. + * Interpolation may be restricted to only a region of the input vector, + * thus creating a cutout of the original vector. */ void @@ -26,6 +28,7 @@ com_linearize(wordlist *wl) struct plot *new, *old; struct dvec *newtime, *v; struct dvec *oldtime; + struct dvec *lin; int len, i; if (!plot_cur || !plot_cur->pl_dvecs || !plot_cur->pl_scale) { @@ -58,6 +61,26 @@ com_linearize(wordlist *wl) tstop = plot_cur->pl_scale->v_realdata[length - 1]; tstep = (tstop - tstart) / (double)length; } + + /* if this plot contains special vectors lin-tstart, lin-tstop or lin-tstep, use these instead */ + lin = vec_fromplot("lin-tstart", plot_cur); + if (lin) { + fprintf(cp_out, "linearize tstart is set to: %8e\n", lin->v_realdata[0]); + tstart = lin->v_realdata[0]; + } + + lin = vec_fromplot("lin-tstop", plot_cur); + if (lin) { + fprintf(cp_out, "linearize tstop is set to: %8e\n", lin->v_realdata[0]); + tstop = lin->v_realdata[0]; + } + + lin = vec_fromplot("lin-tstep", plot_cur); + if (lin) { + fprintf(cp_out, "linearize tstep is set to: %8e\n", lin->v_realdata[0]); + tstep = lin->v_realdata[0]; + } + /* finally check if tstart, tstop and tstep are reasonable */ if (((tstop - tstart) * tstep <= 0.0) || ((tstop - tstart) < tstep)) { fprintf(cp_err,