exampels/poweramp.sch and examples/cmos_example.sch show how to use dynamuc ngspice simulation data backannotation, optimized fix of previous bbox bug

This commit is contained in:
Stefan Schippers 2020-10-20 19:48:59 +02:00
parent 3bbba8601f
commit 7e845db5df
14 changed files with 382 additions and 176 deletions

View File

@ -194,7 +194,7 @@ const char *add_ext(const char *f, const char *ext)
return ff;
}
void resetwin(int create_pixmap, int clear_pixmap)
void resetwin(int create_pixmap, int clear_pixmap, int preview_window)
{
int i;
XWindowAttributes wattr;
@ -241,8 +241,14 @@ void resetwin(int create_pixmap, int clear_pixmap)
}
XSetTile(display,gctiled, save_pixmap);
#else
Tk_Window mainwindow = Tk_MainWindow(interp);
HWND hwnd = Tk_GetHWND(Tk_WindowId(mainwindow));
HWND hwnd;
if (preview_window) {
hwnd = Tk_GetHWND(pre_window);
}
else {
Tk_Window mainwindow = Tk_MainWindow(interp);
hwnd = Tk_GetHWND(Tk_WindowId(mainwindow));
}
RECT rct;
if (GetWindowRect(hwnd, &rct))
{

View File

@ -183,7 +183,7 @@ int callback(int event, int mx, int my, KeySym key,
dbg(1, "callback(): Expose\n");
break;
case ConfigureNotify:
resetwin(1, 1);
resetwin(1, 1, 0);
draw();
break;
@ -954,7 +954,9 @@ int callback(int event, int mx, int my, KeySym key,
}
if(key=='o' && state == ControlMask) /* load */
{
if(semaphore >= 2) break;
tcleval("catch { ngspice::resetdata }");
ask_new_file();
break;
}

View File

@ -555,6 +555,9 @@ void copy_objects(int what)
{
int firstw, firsti;
int save_draw;
/* if the copy operation involved flip or rotations the original element bboxes were changed.
restore them now */
update_symbol_bboxes(0, 0);
save_draw = draw_window;
draw_window=1; /* temporarily re-enable draw to window together with pixmap */
draw_selection(gctiled,0);
@ -855,9 +858,6 @@ void copy_objects(int what)
break;
case ELEMENT:
if(k==0) {
/* if the copy operation involved flip or rotations the original element bboxes were changed.
restore them now */
update_symbol_bboxes(0, 0);
if(firsti) {
prepared_hash_instances = 0;
firsti = 0;

View File

@ -64,7 +64,7 @@ proc ngspice::read_ngspice_raw {arr fp} {
}
}
proc ngspice::get_voltage {arr n } {
proc ngspice::get_voltage_probe {arr n } {
upvar $arr var
set m "v($n)"
if { ! [info exists var([string tolower $m])] } {
@ -78,7 +78,7 @@ proc ngspice::get_voltage {arr n } {
# return DELETE
}
proc ngspice::get_diff_voltage {arr p m } {
proc ngspice::get_diff_probe {arr p m } {
upvar $arr var
set pp "v($p)"
set mm "v($m)"
@ -92,7 +92,7 @@ proc ngspice::get_diff_voltage {arr p m } {
# return DELETE
}
proc ngspice::get_current {arr n } {
proc ngspice::get_curr_probe {arr n } {
upvar $arr var
if { [xschem get currsch] > 0 } {
set n "i(v.$n)"
@ -108,23 +108,64 @@ proc ngspice::get_current {arr n } {
}
proc get_ngspice_node {n} {
proc ngspice::get_current {n} {
set n [string tolower $n]
if { [regexp -all \\. $n] == 1} {
regsub {@.\.} $n {@} n
set prefix [string range $n 0 0]
set path [string range [xschem get sch_path] 1 end]
set n $path$n
if { $path ne {} } {
set n $prefix.$n
}
if { ![regexp $prefix {[ve]}] } {
set n @$n
}
set n i($n)
set err [catch {set ::ngspice::ngspice_data($n)} res]
if { $err } {
if { $err } {
set res {?}
} else {
set res [ format %.4g $res ]
}
# puts "$n --> $res"
return $res
}
proc ngspice::get_voltage {n} {
set n [string tolower $n]
set path [string range [xschem get sch_path] 1 end]
set n v($path$n)
set err [catch {set ::ngspice::ngspice_data($n)} res]
if { $err } {
# puts "get_ngspice_node: $res"
set res {}
set res {?}
} else {
set res [ format %.4g $res ]
}
return $res
}
proc annotate {} {
proc ngspice::get_node {n} {
set n [string tolower $n]
if { [regexp -all \\. $n] == 1} {
regsub {@.\.} $n {@} n
}
set err [catch {set ::ngspice::ngspice_data($n)} res]
if { $err } {
# puts "get_ngspice_node: $res"
set res {?}
} else {
set res [ format %.4g $res ]
}
return $res
}
proc ngspice::resetdata {} {
array unset ::ngspice::ngspice_data
}
proc ngspice::annotate {} {
upvar ::ngspice::ngspice_data arr
set rawfile "[xschem get netlist_dir]/[file rootname [file tail [xschem get schname 0]]].raw"
if { ![file exists $rawfile] } {
@ -157,19 +198,19 @@ proc annotate {} {
set type [xschem getprop instance $i cell::type]
if { $type eq {probe} } {
set net $path[xschem instance_net $i p]
if {[catch {xschem setprop $i voltage [ngspice::get_voltage arr $net] fast} err]} {
if {[catch {xschem setprop $i voltage [ngspice::get_voltage_probe arr $net] fast} err]} {
puts "Warning 1: ${err}, net: $net"
}
}
if { $type eq {current_probe} } {
if {[catch {xschem setprop $i current [ngspice::get_current arr $path$name] fast} err]} {
if {[catch {xschem setprop $i current [ngspice::get_curr_probe arr $path$name] fast} err]} {
puts "Warning 2: $err"
}
}
if { $type eq {differential_probe} } {
set netp $path[xschem instance_net $i p]
set netm $path[xschem instance_net $i m]
if {[catch {xschem setprop $i voltage [ngspice::get_diff_voltage arr $netp $netm] fast} err]} {
if {[catch {xschem setprop $i voltage [ngspice::get_diff_probe arr $netp $netm] fast} err]} {
puts "Warning 3: $err"
}
}
@ -191,4 +232,4 @@ proc annotate {} {
}
}
if { ![info exists no_x] } {bind .drw <Alt-a> {puts {Annotating...}; annotate} }
if { ![info exists no_x] } {bind .drw <Alt-a> {puts {Annotating...}; ngspice::annotate} }

View File

@ -1252,6 +1252,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"load") )
{
tcleval("catch { ngspice::resetdata }");
if(argc==3) {
if(!has_x || !modified || !save(1) ) { /* save(1)==1 --> user cancel */
dbg(1, "xschem(): load: filename=%s\n", argv[2]);

View File

@ -820,7 +820,7 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
/* if not set heuristics is done in xschem.tcl to ensure it is an xschem file */
load_schematic(1,filename, 0);
window = pre_window;
resetwin(1, 0);
resetwin(1, 0, 1);
zoom_full(1, 0); /* draw */
check_version = 0;
@ -840,15 +840,16 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
#ifdef __unix__
XFreePixmap(display,save_pixmap);
#else
Tk_FreePixmap(display, save_pixmap);
if (save_pixmap != save_save_pixmap)
Tk_FreePixmap(display, save_pixmap);
#endif
window = save_window;
save_pixmap = save_save_pixmap;
/* reset window, but don't delete and create a pixmap since we
/* reset window (back to main window), but don't delete and create a pixmap since we
have preserved the main window pixmap and already erased the preview pixmap
the goal of this complicated pixmap saving is to avoid a draw() call in the main window
to regenerate the save_pixmap every time user browses a new symbol */
resetwin(0, 0);
resetwin(0, 0, 0);
change_linewidth(-1.);
/* not needed: event loop takes care of this and don't need to regenerate save_pixmap. */
/* draw(); */

View File

@ -816,7 +816,7 @@ extern int Tcl_AppInit(Tcl_Interp *interp);
extern int source_tcl_file(char *s);
extern int callback(int event, int mx, int my, KeySym key,
int button, int aux, int state);
extern void resetwin(int create_pixmap, int clear_pixmap);
extern void resetwin(int create_pixmap, int clear_pixmap, int preview_window);
extern void find_closest_net(double mx,double my);
extern void find_closest_box(double mx,double my);
extern void find_closest_arc(double mx,double my);

View File

@ -1870,7 +1870,7 @@ proc tclpropeval2 {s} {
regsub {^tcleval\(} $s {} s
regsub {\)([ \n\t]*)$} $s {\1} s
if { [catch {subst $s} res] } {
puts "tclpropeval2 warning: $res"
# puts "tclpropeval2 warning: $res"
set res {?}
}
return $res

View File

@ -0,0 +1,14 @@
v {xschem version=2.9.8 file_version=1.2}
G {}
K {type=raw_data_show
vhdl_ignore=true
spice_ignore=false
verilog_ignore=true
tedax_ignore=true
template="name=r1 node=xxx"}
V {}
S {}
E {}
A 15 0 0 1.875 90 360 {fill=true}
T {tcleval(@node\\)} 6.875 -8.59375 0 0 0.2 0.2 {vcenter=true layer=15}
T {@descr} 6.875 -21.09375 0 0 0.2 0.2 {vcenter=true layer=15}

View File

@ -9,5 +9,6 @@ template="name=r1 node=xxx"}
V {}
S {}
E {}
T {tcleval([ get_ngspice_node [subst -nocommand \{@node\\\}] ] )} 6.875 -8.59375 0 0 0.25 0.25 {vcenter=true layer=15}
T {tcleval([regsub \{\\@(.*\\\\.)?\} [subst -nocommand \{@node\\\}] \{\} ] )} 6.875 -23.59375 0 0 0.25 0.25 {vcenter=true layer=15}
A 15 0 0 1.875 90 360 {fill=true}
T {tcleval([ ngspice::get_node [subst -nocommand \{@node\\\}] ] )} 4.375 -8.59375 0 0 0.2 0.2 {vcenter=true layer=15}
T {tcleval([regsub \{\\@(.*\\\\.)?\} [subst -nocommand \{@node\\\}] \{\} ] )} 4.375 -21.09375 0 0 0.2 0.2 {vcenter=true layer=15}

View File

@ -11,4 +11,4 @@ S {}
E {}
L 15 -0 -0 5 -5 {}
B 5 -0.46875 -0.46875 0.46875 0.46875 {name=p dir=xxx}
T {tcleval( [ get_ngspice_node v([set path]@@p\\) ] )} 6.875 -13.59375 0 0 0.2 0.2 {vcenter=true layer=15}
T {tcleval( [ ngspice::get_node v([set path]@@p\\) ] )} 6.875 -13.59375 0 0 0.2 0.2 {vcenter=true layer=15}

View File

@ -20,10 +20,10 @@ N 370 -280 390 -280 {lab=PLUS}
N 610 -280 630 -280 {lab=MINUS}
N 570 -430 620 -430 {lab=VCC}
N 380 -430 430 -430 {lab=VCC}
N 470 -430 530 -430 {lab=#net2}
N 470 -430 470 -400 {lab=#net2}
N 430 -400 470 -400 {lab=#net2}
N 430 -400 430 -310 {lab=#net2}
N 470 -430 530 -430 {lab=G}
N 470 -430 470 -400 {lab=G}
N 430 -400 470 -400 {lab=G}
N 430 -400 430 -310 {lab=G}
N 570 -400 570 -310 {lab=DIFFOUT}
N 570 -500 570 -460 {lab=VCC}
N 430 -500 570 -500 {lab=VCC}
@ -124,7 +124,21 @@ C {ngspice_probe.sym} 30 -370 0 0 {name=r6}
C {ngspice_probe.sym} 30 -240 0 0 {name=r7}
C {ngspice_probe.sym} 30 -520 0 0 {name=r8}
C {ngspice_probe.sym} 500 -210 0 0 {name=r9}
C {ngspice_get_value.sym} 590 -440 0 0 {name=r10 node=i(@m6[id])}
C {ngspice_get_value.sym} 410 -440 0 1 {name=r11 node=i(@m6[id])}
C {ngspice_get_value.sym} 530 -180 0 0 {name=r12 node=i(@m1[id])}
C {ngspice_get_value.sym} 210 -180 0 1 {name=r13 node=i(@m3[id])}
C {ngspice_get_expr.sym} 590 -450 0 0 {name=r18
node="[ngspice::get_current \{m2[id]\}]"
descr = Id
}
C {lab_pin.sym} 430 -370 0 0 {name=p12 lab=G net_name=true}
C {ngspice_get_expr.sym} 550 -450 0 1 {name=r10
node="[format %.4g [expr [ngspice::get_voltage vcc] - [ngspice::get_voltage g]]]"
descr = Vsg
}
C {ngspice_get_expr.sym} 530 -170 0 0 {name=r14
node="[ngspice::get_current \{m1[id]\}]"
descr = Id
}
C {ngspice_get_expr.sym} 210 -170 0 1 {name=r12
node="[ngspice::get_current \{m3[id]\}]"
descr = Id
}

View File

@ -6,116 +6,94 @@ S {
* .probe v(ga,sa) v(gb,sb)
* .probe p(q*) p(r*) i(r*) p(xm1) p(xm2) i(d*)}
E {}
T {CURRENT
MEASURE} 1040 -660 0 0 0.2 0.2 {}
T {CURRENT
MEASURE} 1040 -560 0 0 0.2 0.2 {}
L 15 270 -460 340 -390 {}
L 15 270 -330 340 -390 {}
T {ANALOG AUDIO AMPLIFIER
N-Channel only power stage} 430 -275 0 0 0.5 0.5 {layer=8 font="Liberation Sans"}
N 1110 -1180 1110 -790 {lab=VPP}
N-Channel only power stage} 430 -270 0 0 0.5 0.5 {layer=8 font="Liberation Sans"}
N 180 -500 180 -470 {lab=E9}
N 260 -470 340 -470 {lab=E9}
N 340 -500 340 -470 {lab=E9}
N 1110 -700 1110 -670 {lab=SA}
N 840 -1020 840 -980 {lab=E4}
N 1110 -590 1110 -570 {lab=#net1}
N 1110 -510 1110 -470 {lab=#net2}
N 570 -950 800 -950 {lab=#net3}
N 350 -950 550 -950 {lab=#net3}
N 330 -950 335 -955 {lab=#net3}
N 335 -955 345 -955 {lab=#net3}
N 345 -955 350 -950 {lab=#net3}
N 550 -950 555 -955 {lab=#net3}
N 555 -955 565 -955 {lab=#net3}
N 565 -955 570 -950 {lab=#net3}
N 1110 -590 1110 -570 {lab=OUTI}
N 1110 -510 1110 -470 {lab=#net1}
N 180 -1020 180 -980 {lab=E1}
N 230 -950 330 -950 {lab=#net3}
N 390 -790 520 -790 {lab=C2}
N 230 -950 230 -900 {lab=#net3}
N 180 -900 230 -900 {lab=#net3}
N 230 -950 230 -900 {lab=#net2}
N 180 -900 230 -900 {lab=#net2}
N 390 -790 390 -740 {lab=C2}
N 340 -740 390 -740 {lab=C2}
N 180 -920 180 -900 {lab=#net3}
N 220 -950 230 -950 {lab=#net3}
N 180 -920 180 -900 {lab=#net2}
N 220 -950 230 -950 {lab=#net2}
N 340 -760 340 -740 {lab=C2}
N 380 -790 390 -790 {lab=C2}
N 180 -1120 180 -1080 {lab=VBOOST}
N 840 -1120 840 -1080 {lab=VBOOST}
N 350 -1120 550 -1120 {lab=VBOOST}
N 330 -1120 335 -1125 {lab=VBOOST}
N 335 -1125 345 -1125 {lab=VBOOST}
N 345 -1125 350 -1120 {lab=VBOOST}
N 550 -1120 555 -1125 {lab=VBOOST}
N 555 -1125 565 -1125 {lab=VBOOST}
N 565 -1125 570 -1120 {lab=VBOOST}
N 180 -1120 330 -1120 {lab=VBOOST}
N 340 -1180 340 -1080 {lab=VPP}
N 560 -1180 560 -1080 {lab=VPP}
N 180 -1120 690 -1120 {lab=VBOOST}
N 690 -1120 840 -1120 {lab=VBOOST}
N 340 -1180 560 -1180 {lab=VPP}
N 60 -1180 340 -1180 {lab=VPP}
N 1100 -1120 1105 -1125 {lab=VBOOST}
N 1105 -1125 1115 -1125 {lab=VBOOST}
N 1115 -1125 1120 -1120 {lab=VBOOST}
N 840 -1120 1100 -1120 {lab=VBOOST}
N 560 -1180 1110 -1180 {lab=VPP}
N 830 -440 1070 -440 {lab=GB}
N 1110 -1180 1400 -1180 {lab=VPP}
N 840 -1120 1240 -1120 {lab=VBOOST}
N 860 -440 1070 -440 {lab=GB}
N 560 -460 560 -440 {lab=C8}
N 1200 -1120 1330 -1120 {lab=VBOOST}
N 1200 -900 1200 -870 {lab=#net4}
N 1110 -1180 1330 -1180 {lab=VPP}
N 1240 -1120 1400 -1120 {lab=VBOOST}
N 1240 -900 1240 -870 {lab=#net3}
N 560 -580 560 -520 {lab=E8}
N 560 -760 560 -640 {lab=C6}
N 840 -780 840 -760 {lab=GA}
N 690 -810 690 -790 {lab=B1}
N 690 -810 800 -810 {lab=B1}
N 690 -1120 690 -880 {lab=VBOOST}
N 570 -1120 690 -1120 {lab=VBOOST}
N 690 -820 690 -810 {lab=B1}
N 260 -470 260 -460 {lab=E9}
N 180 -70 260 -70 {lab=VNN}
N 150 -70 260 -70 {lab=VSS}
N 50 -210 220 -210 {lab=B3}
N 260 -180 260 -130 {lab=E3}
N 180 -150 180 -70 {lab=VNN}
N 50 -150 50 -70 {lab=VNN}
N 50 -70 180 -70 {lab=VNN}
N 690 -600 1110 -600 {lab=#net1}
N 150 -150 150 -70 {lab=VSS}
N 50 -150 50 -70 {lab=VSS}
N 50 -70 150 -70 {lab=VSS}
N 690 -600 1110 -600 {lab=OUTI}
N 180 -470 260 -470 {lab=E9}
N 1110 -610 1110 -600 {lab=#net1}
N 960 -380 1110 -380 {lab=SB}
N 960 -700 1110 -700 {lab=SA}
N 1200 -1120 1200 -960 {lab=VBOOST}
N 1110 -610 1110 -600 {lab=OUTI}
N 860 -380 1110 -380 {lab=SB}
N 860 -700 1110 -700 {lab=SA}
N 1240 -1120 1240 -960 {lab=VBOOST}
N 1110 -410 1110 -380 {lab=SB}
N 1110 -730 1110 -700 {lab=SA}
N 1120 -1120 1200 -1120 {lab=VBOOST}
N 840 -760 1070 -760 {lab=GA}
N 860 -760 1070 -760 {lab=GA}
N 340 -740 340 -690 {lab=C2}
N 340 -630 340 -560 {lab=C9}
N 220 -630 340 -630 {lab=C9}
N 180 -600 180 -560 {lab=C5}
N 1110 -320 1110 -280 {lab=VNN}
N 1330 -590 1390 -590 {lab=OUT}
N 1110 -590 1200 -590 {lab=#net1}
N 1110 -600 1110 -590 {lab=#net1}
N 340 -860 340 -820 {lab=#net5}
N 560 -860 560 -820 {lab=#net6}
N 1110 -590 1240 -590 {lab=OUTI}
N 1110 -600 1110 -590 {lab=OUTI}
N 340 -860 340 -820 {lab=#net4}
N 560 -860 560 -820 {lab=#net5}
N 560 -1020 560 -920 {lab=E6}
N 340 -1020 340 -920 {lab=E2}
N 260 -280 260 -240 {lab=C3}
N 730 -440 770 -440 {lab=#net7}
N 730 -440 770 -440 {lab=#net6}
N 560 -440 670 -440 {lab=C8}
N 690 -650 690 -600 {lab=#net1}
N 690 -730 690 -710 {lab=#net8}
N 690 -650 690 -600 {lab=OUTI}
N 690 -730 690 -710 {lab=#net7}
N 180 -840 180 -660 {lab=C7}
N 840 -860 840 -840 {lab=E11}
N 1200 -810 1200 -590 {lab=#net1}
N 1240 -810 1240 -590 {lab=OUTI}
N 860 -760 860 -750 {lab=GA}
N 860 -710 860 -700 {lab=SA}
N 860 -700 960 -700 {lab=SA}
N 860 -440 860 -430 {lab=GB}
N 860 -390 860 -380 {lab=SB}
N 860 -380 960 -380 {lab=SB}
N 1200 -590 1270 -590 {lab=#net1}
N 1240 -590 1270 -590 {lab=OUTI}
N 830 -440 860 -440 {lab=GB}
N 840 -760 860 -760 {lab=GA}
N 340 -1180 340 -1080 { lab=VPP}
N 560 -1180 560 -1080 { lab=VPP}
N 60 -1180 340 -1180 {lab=VPP}
N 340 -1180 560 -1180 {lab=VPP}
N 1110 -1180 1110 -790 { lab=VPP}
N 560 -1180 1110 -1180 {lab=VPP}
N 230 -950 800 -950 { lab=#net2}
C {ipin.sym} 530 -160 0 0 {name=p0 lab=PLUS}
C {ipin.sym} 530 -120 0 0 {name=p2 lab=VPP}
C {ipin.sym} 530 -100 0 0 {name=p3 lab=VNN}
@ -147,8 +125,8 @@ C {lab_pin.sym} 340 -970 0 1 {name=p23 lab=E2}
C {lab_pin.sym} 560 -970 0 1 {name=p28 lab=E6}
C {lab_pin.sym} 840 -1000 0 0 {name=p29 lab=E4}
C {lab_pin.sym} 180 -1120 0 0 {name=p34 lab=VBOOST}
C {ammeter.sym} 1110 -540 0 0 {name=vd net_name=true current=0.2093}
C {ammeter.sym} 1110 -640 0 0 {name=vu net_name=true current=0.2336}
C {ammeter.sym} 1110 -540 0 0 {name=vd net_name=true current=0.1944}
C {ammeter.sym} 1110 -640 0 0 {name=vu net_name=true current=0.216}
C {lab_pin.sym} 60 -1180 0 0 {name=p27 lab=VPP}
C {pnp.sym} 200 -950 0 1 {name=Q1 model=q2n2907p area=1 net_name=true}
C {pnp.sym} 360 -790 0 1 {name=Q2 model=q2n2907p area=1 net_name=true}
@ -195,25 +173,25 @@ rload out 0 4
C {lab_wire.sym} 920 -760 0 0 {name=l1 lab=GA}
C {res.sym} 800 -440 1 1 {name=R11 m=1 value=1300 net_name=true}
C {pnp.sym} 540 -490 0 0 {name=Q8 model=q2n2907p area=1 net_name=true}
C {capa.sym} 1200 -930 0 0 {name=C12 m=1 value="40u" net_name=true}
C {diode.sym} 1200 -1150 0 0 {name=D0 model=d1n4148 area=1
C {capa.sym} 1240 -930 0 0 {name=C12 m=1 value="40u" net_name=true}
C {diode.sym} 1240 -1150 0 0 {name=D0 model=d1n4148 area=1
url="http://pdf.datasheetcatalog.com/datasheet/bytes/1N5406.pdf" net_name=true}
C {res.sym} 1200 -840 0 1 {name=R18 m=1 value=200 net_name=true}
C {zener.sym} 1330 -1150 0 0 {name=D1 model=d1n758 area=1
C {res.sym} 1240 -840 0 1 {name=R18 m=1 value=200 net_name=true}
C {zener.sym} 1400 -1150 0 0 {name=D1 model=d1n758 area=1
url="http://www.futurlec.com/Datasheet/Diodes/1N746-1N759.pdf" net_name=true}
C {res.sym} 690 -760 0 1 {name=R14 m=1 value=4k net_name=true}
C {pnp.sym} 820 -810 0 0 {name=Q11 model=q2n2907p area=1 net_name=true}
C {res.sym} 690 -850 0 1 {name=R15 m=1 value=4k net_name=true}
C {res.sym} 260 -430 0 1 {name=R5 m=1 value=600 net_name=true}
C {res.sym} 260 -370 0 1 {name=R6 m=1 value=700 net_name=true}
C {zener.sym} 180 -180 2 0 {name=D2 model=d1n755 area=1
C {res.sym} 260 -430 0 1 {name=R5 m=1 value=120 net_name=true}
C {res.sym} 260 -370 0 1 {name=R6 m=1 value=120 net_name=true}
C {zener.sym} 150 -180 2 0 {name=D2 model=d1n755 area=1
url="http://www.futurlec.com/Datasheet/Diodes/1N746-1N759.pdf"
net_name=true}
C {npn.sym} 240 -210 0 0 {name=Q3 model=q2n2222 area=1 net_name=true}
C {res.sym} 180 -240 0 1 {name=R1 m=1 value=10k net_name=true}
C {lab_pin.sym} 180 -270 0 0 {name=p7 lab=VSS}
C {res.sym} 150 -240 0 1 {name=R1 m=1 value=10k net_name=true}
C {lab_pin.sym} 150 -270 0 0 {name=p7 lab=VPP}
C {res.sym} 260 -100 0 1 {name=R10 m=1 value=170 net_name=true}
C {lab_pin.sym} 50 -70 0 0 {name=p11 lab=VNN}
C {lab_pin.sym} 50 -70 0 0 {name=p11 lab=VSS}
C {capa.sym} 50 -180 0 0 {name=C3 m=1 value=100n net_name=true}
C {res.sym} 560 -610 0 1 {name=R12 m=1 value=1300 net_name=true}
C {lab_pin.sym} 690 -800 0 0 {name=p12 lab=B1}
@ -231,30 +209,18 @@ C {lab_pin.sym} 180 -690 0 0 {name=p8 lab=C7}
C {lab_pin.sym} 340 -710 0 1 {name=p31 lab=C2}
C {title.sym} 160 -30 0 0 {name=l2 author="Stefan Schippers"}
C {lab_pin.sym} 860 -700 0 0 {name=p32 lab=SA}
C {ammeter.sym} 1110 -350 0 0 {name=v0 net_name=true current=0.2288}
C {ammeter.sym} 1110 -350 0 0 {name=v0 net_name=true current=0.2138}
C {lab_pin.sym} 860 -380 0 0 {name=p35 lab=SB}
C {ammeter.sym} 560 -890 0 0 {name=v1 net_name=true current=0.01956}
C {ammeter.sym} 340 -890 0 0 {name=v2 net_name=true current=0.01947}
C {ammeter.sym} 260 -310 0 0 {name=v3 net_name=true current=0.03924}
C {ammeter.sym} 700 -440 3 0 {name=v4 net_name=true current=0.01942}
C {ammeter.sym} 690 -680 0 0 {name=v5 net_name=true current=0.006271}
C {ammeter.sym} 180 -870 0 1 {name=v6 net_name=true current=0.01955}
C {ammeter.sym} 840 -890 0 0 {name=v7 net_name=true current=0.0195}
C {spice_probe.sym} 940 -440 0 0 {name=p36 analysis=tran voltage=-46.31}
C {spice_probe_vdiff.sym} 860 -410 0 0 {name=p37 analysis=tran voltage=3.689}
C {spice_probe_vdiff.sym} 860 -730 0 0 {name=p38 analysis=tran voltage=3.691}
C {spice_probe.sym} 940 -760 0 0 {name=p39 analysis=tran voltage=3.814}
C {spice_probe.sym} 1220 -590 0 0 {name=p40 analysis=tran voltage=0.1231}
C {spice_probe.sym} 380 -530 0 0 {name=p41 analysis=tran voltage=21.3}
C {spice_probe.sym} 140 -530 0 1 {name=p42 analysis=tran voltage=21.3}
C {spice_probe.sym} 250 -470 0 1 {name=p43 analysis=tran voltage=20.61}
C {spice_probe.sym} 440 -790 0 0 {name=p44 analysis=tran voltage=48.22}
C {spice_probe.sym} 280 -950 0 0 {name=p45 analysis=tran voltage=48.22}
C {spice_probe.sym} 730 -810 0 0 {name=p46 analysis=tran voltage=25.21}
C {ammeter.sym} 1300 -590 3 0 {name=v8 net_name=true current=0.03055}
C {spice_probe.sym} 280 -630 0 1 {name=p50 analysis=tran voltage=42.36}
C {spice_probe.sym} 340 -820 0 1 {name=p51 analysis=tran voltage=49.03}
C {spice_probe.sym} 120 -210 0 1 {name=p52 analysis=tran voltage=-42.58}
C {ammeter.sym} 560 -890 0 0 {name=v1 net_name=true current=0.01954}
C {ammeter.sym} 340 -890 0 0 {name=v2 net_name=true current=0.01944}
C {ammeter.sym} 260 -310 0 0 {name=v3 net_name=true current=0.03919}
C {ammeter.sym} 700 -440 3 0 {name=v4 net_name=true current=0.01939}
C {ammeter.sym} 690 -680 0 0 {name=v5 net_name=true current=0.006273}
C {ammeter.sym} 180 -870 0 1 {name=v6 net_name=true current=0.01952}
C {ammeter.sym} 840 -890 0 0 {name=v7 net_name=true current=0.01947}
C {spice_probe_vdiff.sym} 860 -410 0 0 {name=p37 analysis=tran voltage=3.684}
C {spice_probe_vdiff.sym} 860 -730 0 0 {name=p38 analysis=tran voltage=3.685}
C {ammeter.sym} 1300 -590 3 0 {name=v8 net_name=true current=0.02782}
C {opin.sym} 600 -130 0 0 {name=p5 lab=OUT}
C {ipin.sym} 530 -180 0 0 {name=p1 lab=MINUS}
C {ipin.sym} 530 -140 0 0 {name=p4 lab=VSS}
@ -285,10 +251,146 @@ tclcommand="
"
}
C {ngspice_probe.sym} 750 -1120 0 0 {name=p54}
C {spice_probe.sym} 690 -1180 0 0 {name=p47 analysis=tran voltage=50}
C {spice_probe.sym} 1110 -280 0 0 {name=p49 analysis=tran voltage=-50}
C {ngspice_probe.sym} 180 -760 0 0 {name=p53}
C {ngspice_probe.sym} 560 -710 0 0 {name=p55}
C {ngspice_get_value.sym} 965 -710 0 0 {name=r48 node=i(@r.$\{path\}r0[i])}
C {ngspice_get_value.sym} 815 -955 0 1 {name=r1 node=i(@q.$\{path\}q4[ib])}
C {ngspice_get_value.sym} 845 -985 0 0 {name=r2 node=i(@q.$\{path\}q4[ic])}
C {ngspice_get_value.sym} 1130 -780 0 0 {name=r4 node=i(@r.$\{path\}xm1.rd[i])}
C {ngspice_get_expr.sym} 800 -1000 0 1 {name=r8
node="[format %.4g [expr [ngspice::get_voltage e4] - [ngspice::get_voltage c7]]]"
descr = veb
}
C {ngspice_get_expr.sym} 860 -980 0 0 {name=r9
node="[format %.4g [expr [ngspice::get_current \{q4[ic]\}] / [ngspice::get_current \{q4[ib]\}] ] ]"
descr = beta
}
C {ngspice_probe.sym} 560 -830 0 0 {name=p41}
C {ngspice_probe.sym} 560 -530 0 1 {name=p42}
C {ngspice_probe.sym} 590 -440 2 1 {name=p47}
C {ngspice_get_expr.sym} 860 -920 0 0 {name=r15
node="[format %.4g [expr ([ngspice::get_voltage e4] - [ngspice::get_voltage e11]) * [ngspice::get_current \{q4[ic]\}]]] W"
descr = power
}
C {ngspice_probe.sym} 260 -260 0 0 {name=p48}
C {ngspice_probe.sym} 90 -70 0 0 {name=p49}
C {ngspice_probe.sym} 100 -210 0 1 {name=p52}
C {ngspice_probe.sym} 1190 -590 0 1 {name=p39}
C {ngspice_probe.sym} 890 -700 2 1 {name=p43}
C {ngspice_probe.sym} 460 -790 2 1 {name=p44}
C {ngspice_probe.sym} 730 -810 2 1 {name=p46}
C {ngspice_probe.sym} 440 -950 0 0 {name=p50}
C {ngspice_probe.sym} 200 -470 0 0 {name=p45}
C {ngspice_probe.sym} 340 -600 0 0 {name=p51}
C {ngspice_get_expr.sym} 350 -860 0 0 {name=r17
node="[ngspice::get_current v2]"
descr = current
}
C {ngspice_get_expr.sym} 350 -1040 0 0 {name=r18
node="[ngspice::get_current \{r2[i]\}]"
descr = current
}
C {ngspice_get_expr.sym} 860 -1040 0 0 {name=r19
node="[ngspice::get_current \{r9[i]\}]"
descr = current
}
C {ngspice_get_expr.sym} 820 -890 0 1 {name=r2
node="[ngspice::get_current \{q4[ic]\}]"
descr = current
}
C {ngspice_get_expr.sym} 800 -970 0 1 {name=r1
node="[ngspice::get_current \{q4[ib]\}]"
descr = Ib
}
C {ngspice_get_expr.sym} 570 -460 0 0 {name=r11
node="[format %.4g [expr ([ngspice::get_voltage e8] - [ngspice::get_voltage c8]) * [ngspice::get_current \{q8[ic]\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 190 -860 0 0 {name=r12
node="[ngspice::get_current v6]"
descr = current
}
C {ngspice_get_expr.sym} 240 -210 0 1 {name=r6
node="[format %.4g [expr [ngspice::get_current \{q3[ic]\}] / [ngspice::get_current \{q3[ib]\}] ] ]"
descr = beta
}
C {ngspice_get_expr.sym} 860 -780 0 0 {name=r16
node="[format %.4g [expr ([ngspice::get_voltage e11] - [ngspice::get_voltage ga]) * [ngspice::get_current \{q11[ic]\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 980 -720 0 0 {name=r20
node="[ngspice::get_current \{r0[i]\}]"
descr = current
}
C {ngspice_get_expr.sym} 280 -200 2 1 {name=r3
node="[format %.4g [expr ([ngspice::get_voltage c3] - [ngspice::get_voltage e3]) * [ngspice::get_current \{q3[ic]\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 240 -190 2 0 {name=r21
node="[format %.4g [expr [ngspice::get_voltage b3] - [ngspice::get_voltage e3]]]"
descr = vbe
}
C {ngspice_get_expr.sym} 340 -390 0 0 {name=r7
node="[format %.4g [expr ([ngspice::get_voltage e9] - [ngspice::get_voltage c3]) * [ngspice::get_current \{r5[i]\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 570 -760 0 0 {name=r10
node="[format %.4g [expr ([ngspice::get_voltage e6] - [ngspice::get_voltage c6]) * [ngspice::get_current \{q6[ic]\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 210 -650 0 0 {name=r14
node="[format %.4g [expr ([ngspice::get_voltage c7] - [ngspice::get_voltage c5]) * [ngspice::get_current \{q7[ic]\}]]]"
descr = power
}
C {ngspice_probe.sym} 180 -560 0 0 {name=p36}
C {ngspice_get_expr.sym} 200 -500 0 0 {name=r13
node="[format %.4g [expr ([ngspice::get_voltage c5] - [ngspice::get_voltage e9]) * [ngspice::get_current \{q5[ic]\}]]]"
descr = power
}
C {ngspice_get_expr.sym} 320 -500 0 1 {name=r22
node="[format %.4g [expr ([ngspice::get_voltage c9] - [ngspice::get_voltage e9]) * [ngspice::get_current \{q9[ic]\}]]]"
descr = power
}
C {ngspice_get_expr.sym} 330 -760 0 1 {name=r23
node="[format %.4g [expr [ngspice::get_current \{q2[ic]\}] / [ngspice::get_current \{q2[ib]\}] ] ]"
descr = beta
}
C {ngspice_get_expr.sym} 1090 -640 0 1 {name=r24
node="[ngspice::get_current vu]"
descr = current
}
C {ngspice_get_expr.sym} 1090 -530 0 1 {name=r25
node="[ngspice::get_current vd]"
descr = current
}
C {ngspice_get_expr.sym} 1210 -1150 0 1 {name=r5
node="[ngspice::get_current \{d0[id]\}]"
descr = current
}
C {ngspice_get_expr.sym} 1370 -1150 0 1 {name=r26
node="[ngspice::get_current \{d1[id]\}]"
descr = current
}
C {ngspice_get_value.sym} 1130 -460 0 0 {name=r27 node=i(@r.$\{path\}xm2.rd[i])}
C {ngspice_get_expr.sym} 160 -230 0 0 {name=r28
node="[format %.4g [expr ([ngspice::get_node v(vpp)] - [ngspice::get_voltage b3]) * [ngspice::get_current \{r1[i]\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 1130 -740 2 1 {name=r29
node="[format %.4g [expr ([ngspice::get_node v(vpp)] - [ngspice::get_voltage outi]) * [ngspice::get_current \{vu\}]]] W"
descr = power
}
C {lab_wire.sym} 910 -600 0 1 {name=l40 lab=OUTI}
C {ngspice_get_expr.sym} 980 -400 0 0 {name=r30
node="[ngspice::get_current \{r7[i]\}]"
descr = current
}
C {ngspice_get_expr.sym} 700 -440 2 0 {name=r31
node="[ngspice::get_current \{v4\}]"
descr = current
}
C {ngspice_get_expr.sym} 1130 -420 2 1 {name=r32
node="[format %.4g [expr ([ngspice::get_voltage outi] - [ngspice::get_node v(vnn)]) * [ngspice::get_current \{vd\}]]] W"
descr = power
}
C {ngspice_get_expr.sym} 150 -160 2 0 {name=r33
node="[format %.4g [expr -[ngspice::get_voltage b3] * [ngspice::get_current \{d2[id]\}]]] W"
descr = power
}

View File

@ -33,18 +33,16 @@ N 580 -1200 580 -1190 {lab=VSS}
N 580 -1190 620 -1190 {lab=VSS}
N 550 -1240 580 -1240 {lab=IN}
N 620 -1250 710 -1250 {lab=REFP}
N 280 -1180 280 -1170 {lab=#net3}
N 280 -1250 280 -1240 {lab=#net4}
N 270 -1100 270 -1090 {lab=#net5}
N 270 -1170 270 -1160 {lab=#net3}
N 270 -1100 270 -1090 {lab=#net3}
N 270 -1170 270 -1160 {lab=#net4}
N 160 -1090 190 -1090 {lab=#net2}
N 370 -1090 380 -1090 {lab=VNN}
N 160 -1250 190 -1250 {lab=#net1}
N 370 -1250 380 -1250 {lab=VPP}
N 270 -1170 280 -1170 {lab=#net3}
N 250 -1250 280 -1250 {lab=#net4}
N 250 -1090 270 -1090 {lab=#net5}
N 160 -1170 270 -1170 {lab=#net3}
N 270 -1170 280 -1170 {lab=#net4}
N 250 -1250 280 -1250 {lab=#net5}
N 250 -1090 270 -1090 {lab=#net3}
N 160 -1170 270 -1170 {lab=#net4}
N 550 -950 710 -950 {lab=OUTM}
N 400 -890 550 -890 {lab=FBN}
N 550 -770 550 -750 {lab=IN}
@ -56,8 +54,7 @@ N 550 -490 710 -490 {lab=OUTP}
N 400 -430 550 -430 {lab=FB}
N 350 -430 350 -240 {lab=FB}
N 710 -490 710 -240 {lab=OUTP}
N 240 -370 240 -350 {lab=VPP}
N 240 -290 240 -220 {lab=INX}
N 240 -400 240 -380 {lab=VPP}
N 260 -220 260 -190 {lab=INX}
N 260 -130 260 -110 {lab=VSS}
N 510 -1120 580 -1120 {lab=VSS}
@ -69,8 +66,7 @@ N 650 -700 710 -700 {lab=OUTM}
N 650 -240 710 -240 {lab=OUTP}
N 240 -220 260 -220 {lab=INX}
N 260 -680 350 -680 {lab=VSSX}
N 240 -830 240 -810 {lab=VPP}
N 240 -750 240 -680 {lab=VSSX}
N 240 -860 240 -840 {lab=VPP}
N 260 -680 260 -650 {lab=VSSX}
N 260 -590 260 -570 {lab=VSS}
N 240 -680 260 -680 {lab=VSSX}
@ -78,18 +74,28 @@ N 180 -680 240 -680 {lab=VSSX}
N 880 -1250 900 -1250 {lab=IN_INT}
N 880 -1250 880 -1220 {lab=IN_INT}
N 400 -1000 400 -980 {lab=VPP}
N 400 -920 400 -890 {lab=FBN}
N 400 -540 400 -520 {lab=VPP}
N 400 -460 400 -430 {lab=FB}
N 860 -700 860 -520 {lab=OUTM}
N 860 -460 860 -240 {lab=OUTP}
N 350 -890 400 -890 {lab=FBN}
N 350 -430 400 -430 {lab=FB}
N 580 -1110 620 -1110 {lab=VSS}
N 580 -1120 580 -1110 {lab=VSS}
N 280 -1250 310 -1250 {lab=#net4}
N 270 -1090 310 -1090 {lab=#net5}
N 280 -1170 310 -1170 {lab=#net3}
N 280 -1250 310 -1250 {lab=#net5}
N 270 -1090 310 -1090 {lab=#net3}
N 280 -1170 310 -1170 {lab=#net4}
N 280 -1180 280 -1170 { lab=#net4}
N 280 -1250 280 -1240 { lab=#net5}
N 240 -730 240 -680 { lab=VSSX}
N 240 -270 240 -220 { lab=INX}
N 400 -920 400 -910 { lab=FBN}
N 400 -910 400 -890 { lab=FBN}
N 400 -460 400 -450 { lab=FB}
N 400 -450 400 -430 { lab=FB}
N 240 -780 240 -760 { lab=VSSX}
N 240 -760 240 -730 { lab=VSSX}
N 240 -320 240 -300 { lab=INX}
N 240 -300 240 -270 { lab=INX}
C {code.sym} 1020 -210 0 0 {name=STIMULI
only_toplevel=true
tclcommand="xschem edit_vi_prop"
@ -100,10 +106,10 @@ value=".option PARHIER=LOCAL RUNLVL=6 post MODMONTE=1 warn maxwarns=400
vvss vss 0 dc 0
.temp 30
.param frequ=20k
.param gain=42
.param frequ=5k
.param gain=45
.op
.tran 6e-7 0.009 uic
.tran 6e-7 0.06 uic
** models are generally not free: you must download
@ -140,8 +146,8 @@ C {lab_pin.sym} 860 -700 0 1 {name=p9 lab=OUTM}
C {mos_power_ampli.sym} 500 -200 0 0 {name=x0}
C {lab_pin.sym} 350 -180 0 0 {name=p12 lab=VPP}
C {lab_pin.sym} 350 -160 0 0 {name=p13 lab=VNN}
C {res.sym} 240 -320 0 1 {name=R6 m=1 value=100k}
C {lab_pin.sym} 240 -370 0 0 {name=p7 lab=VPP}
C {res.sym} 240 -350 0 1 {name=R6 m=1 value=100k}
C {lab_pin.sym} 240 -400 0 0 {name=p7 lab=VPP}
C {res.sym} 260 -160 0 1 {name=R7 m=1 value=100k}
C {lab_pin.sym} 260 -110 0 0 {name=p15 lab=VSS}
C {lab_pin.sym} 510 -1120 0 0 {name=p20 lab=VSS}
@ -159,11 +165,11 @@ C {lab_pin.sym} 350 -660 0 0 {name=p1 lab=VSS}
C {res.sym} 550 -460 0 1 {name=R2 m=1 value='100k'}
C {res.sym} 550 -400 0 1 {name=R3 m=1 value="'100k/(gain-2)'"}
C {vsource.sym} 880 -1190 0 0 {name=V3
xvalue="pulse -.1 .1 1m .1u .1u 10.1u 20u"
value="sin 0 1 frequ 1m"
xvalue="dc 0 pulse -.1 .1 1m .1u .1u 10.1u 20u"
value="dc 0 sin 0 1 frequ 1m"
}
C {res.sym} 240 -780 0 1 {name=R4 m=1 value=100k}
C {lab_pin.sym} 240 -830 0 0 {name=p18 lab=VPP}
C {res.sym} 240 -810 0 1 {name=R4 m=1 value=100k}
C {lab_pin.sym} 240 -860 0 0 {name=p18 lab=VPP}
C {res.sym} 260 -620 0 1 {name=R5 m=1 value=100k}
C {lab_pin.sym} 260 -570 0 0 {name=p10 lab=VSS}
C {res.sym} 400 -950 0 1 {name=R8 m=1 value=100k}
@ -176,17 +182,15 @@ C {res.sym} 930 -1250 1 1 {name=R10 m=1 value=2}
C {lab_pin.sym} 400 -1000 0 0 {name=p24 lab=VPP}
C {res.sym} 400 -490 0 1 {name=R13 m=1 value=100k}
C {lab_pin.sym} 400 -540 0 0 {name=p16 lab=VPP}
C {vsource.sym} 880 -1130 0 0 {name=V4 value=0 xvalue="pwl 0 .1 1m .1 1.01m 0"
C {vsource.sym} 880 -1130 0 0 {name=Vin value=0 xvalue="pwl 0 .1 1m .1 1.01m 0"
}
C {lab_pin.sym} 350 -270 0 0 {name=p19 lab=FB}
C {lab_pin.sym} 350 -730 0 0 {name=p25 lab=FBN}
C {title.sym} 160 -30 0 0 {name=l2 author="Stefan Schippers"}
C {lab_pin.sym} 880 -1250 0 0 {name=p27 lab=IN_INT}
C {ammeter.sym} 340 -1250 3 0 {name=vcurrvpp net_name=true current=0.5636}
C {spice_probe.sym} 790 -700 0 0 {name=p40 analysis=tran voltage=-0.1372}
C {spice_probe.sym} 770 -240 0 0 {name=p29 analysis=tran voltage=-0.1372}
C {ammeter.sym} 340 -1090 3 0 {name=vcurrvnn net_name=true current=-0.5715}
C {ammeter.sym} 340 -1170 3 0 {name=vcurrvss net_name=true current=0.007914}
C {ammeter.sym} 340 -1250 3 0 {name=vcurrvpp net_name=true current=0.54}
C {ammeter.sym} 340 -1090 3 0 {name=vcurrvnn net_name=true current=-0.4526}
C {ammeter.sym} 340 -1170 3 0 {name=vcurrvss net_name=true current=-0.08742}
C {launcher.sym} 780 -120 0 0 {name=h2
descr="Ctrl-Click
Clear all probes"
@ -213,6 +217,26 @@ tclcommand="
xschem redraw
"
}
C {spice_probe.sym} 250 -220 0 0 {name=p30 analysis=tran voltage=21.07}
C {spice_probe.sym} 250 -680 0 0 {name=p33 analysis=tran voltage=21.07}
C {ngspice_probe.sym} 350 -810 0 1 {name=p55}
C {ngspice_probe.sym} 240 -1170 0 1 {name=p34}
C {capa.sym} 280 -1210 0 0 {name=C2 m=1 value="100u"}
C {ngspice_probe.sym} 160 -1250 0 1 {name=p35}
C {ngspice_probe.sym} 160 -1090 0 1 {name=p36}
C {ngspice_probe.sym} 380 -1170 0 0 {name=p37}
C {ngspice_probe.sym} 810 -700 0 1 {name=p29}
C {ngspice_probe.sym} 810 -240 0 1 {name=p38}
C {ngspice_probe.sym} 300 -680 0 1 {name=p33}
C {ngspice_probe.sym} 300 -220 0 1 {name=p30}
C {ngspice_probe.sym} 350 -320 0 1 {name=p39}
C {ngspice_get_expr.sym} 565 -455 0 0 {name=r18
node="[ngspice::get_current \{r2[i]\}]"
descr = current
}
C {ngspice_get_expr.sym} 575 -915 0 0 {name=r1
node="[ngspice::get_current \{r19[i]\}]"
descr = current
}
C {ngspice_get_expr.sym} 820 -510 2 0 {name=r29
node="[format %.4g [expr ([ngspice::get_voltage outm] - [ngspice::get_voltage outp]) * [ngspice::get_current \{r1[i]\}]]] W"
descr = power
}