creating a linearized cutout of the original vector

by defining the vectors lin-tstart, lin-tstop, and lin-tstep
before issuing the 'linearize' command
This commit is contained in:
Holger Vogt 2019-03-21 20:13:27 +01:00
parent b985472ac1
commit a89e5db571
2 changed files with 30 additions and 1 deletions

View File

@ -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

View File

@ -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,