From 71e02fd0a086eb26fc06863df1e8c7f735914736 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 14 Feb 2016 14:44:18 +0100 Subject: [PATCH] com_linarize(), support load'ed vectors if there is no circuit loaded then command 'linearize' will take time data from transient analysis vector. (tstart, tstop, tstep) --- src/frontend/linear.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/frontend/linear.c b/src/frontend/linear.c index 8e8a218f6..749481f47 100644 --- a/src/frontend/linear.c +++ b/src/frontend/linear.c @@ -15,6 +15,8 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group /* Interpolate all the vectors in a plot to a linear time scale, which * 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. */ void @@ -26,18 +28,6 @@ com_linearize(wordlist *wl) struct dvec *oldtime; int len, i; - if (!ft_curckt || !ft_curckt->ci_ckt || - !if_tranparams(ft_curckt, &tstart, &tstop, &tstep)) { - fprintf(cp_err, - "Error: can't get transient parameters from circuit\n"); - return; - } - if (((tstop - tstart) * tstep <= 0.0) || ((tstop - tstart) < tstep)) { - fprintf(cp_err, - "Error: bad parameters -- start = %G, stop = %G, step = %G\n", - tstart, tstop, tstep); - return; - } if (!plot_cur || !plot_cur->pl_dvecs || !plot_cur->pl_scale) { fprintf(cp_err, "Error: no vectors available\n"); return; @@ -51,6 +41,30 @@ com_linearize(wordlist *wl) fprintf(cp_err, "Error: plot must be a transient analysis\n"); return; } + /* check if circuit is loaded and TSTART, TSTOP, TSTEP are available + if no circuit is loaded, but vectors are available, obtain + start, stop, step data from scale vector */ + if (!ft_curckt || !ft_curckt->ci_ckt || + !if_tranparams(ft_curckt, &tstart, &tstop, &tstep)) { + fprintf(cp_err, + "Warning: Can't get transient parameters from circuit.\n" + " Use transient analysis scale vector data instead.\n"); + int length = plot_cur->pl_scale->v_length; + if (length < 1) { + fprintf(cp_err, "Error: no data in vector\n"); + return; + } + tstart = plot_cur->pl_scale->v_realdata[0]; + tstop = plot_cur->pl_scale->v_realdata[length - 1]; + tstep = (tstop - tstart) / (double)length; + } + /* finally check if tstart, tstop and tstep are reasonable */ + if (((tstop - tstart) * tstep <= 0.0) || ((tstop - tstart) < tstep)) { + fprintf(cp_err, + "Error: bad parameters -- start = %G, stop = %G, step = %G\n", + tstart, tstop, tstep); + return; + } old = plot_cur; oldtime = old->pl_scale; new = plot_alloc("transient");