From afc3f1b7247a7c1aed5651af3ccc551ebe8961d5 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 20 Apr 2025 09:48:40 +0200 Subject: [PATCH] move some X11 dependent code into draw(), circuit example updates --- src/callback.c | 155 ---------------------- src/draw.c | 143 ++++++++++++++++++++ src/main.c | 13 +- src/xschem.h | 3 + xschem_library/ngspice/boost.sch | 34 ++--- xschem_library/ngspice/buck_boost.sch | 114 ++++++++++++---- xschem_library/ngspice/buf_ngspice.sym | 8 +- xschem_library/ngspice/stimuli.boost | 2 +- xschem_library/ngspice/stimuli.buck_boost | 4 +- 9 files changed, 263 insertions(+), 213 deletions(-) diff --git a/src/callback.c b/src/callback.c index c4c3e3c3..06f011e2 100644 --- a/src/callback.c +++ b/src/callback.c @@ -2260,132 +2260,6 @@ static void end_shape_point_edit(double c_snap) } } -#if defined(__unix__) && HAS_CAIRO==1 -static int grabscreen(const char *win_path, int event, int mx, int my, KeySym key, - int button, int aux, int state) -{ - static int grab_state = 0; - static int x1, y1, x2, y2; - int rmx, rmy, wmx, wmy; - unsigned int msq; - Window rw, cw; - XSetWindowAttributes winattr; - XGCValues gcv; - static GC gc = NULL; - static Window clientwin = 0; - static int first_motion = 1; - static int displayh = 0, displayw = 0; - static unsigned long white = 0; - - if(grab_state == 0 && event == ButtonPress && button == Button1) { - unsigned long gcvm = GCFunction | GCForeground; - - white = WhitePixel(display, screen_number); - displayh = DisplayHeight(display, screen_number); - displayw = DisplayWidth(display, screen_number); - - XQueryPointer(display, xctx->window, &rw, &cw , &rmx, &rmy, &wmx, &wmy, &msq); - gcv.function = GXxor; - gcv.foreground = white; - gc = XCreateGC(display, rw, gcvm, &gcv); - - winattr.override_redirect = True; - clientwin = XCreateWindow(display, rw, 0, 0, displayw, displayh, 0, screendepth, - InputOutput, visual, CWOverrideRedirect, &winattr); - XMapRaised(display,clientwin); - - x1 = rmx; - y1 = rmy; - dbg(1, "grabscreen(): got point1: %d %d\n", x1, y1); - grab_state = 1; - } - - if(grab_state == 1 && event == MotionNotify) { - static int xx1, xx2, yy1, yy2; - xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2; - INT_RECTORDER(xx1, yy1, xx2, yy2); - dbg(1, "Motion: %d %d %d %d\n", xx1, yy1, xx2, yy2); - if(!first_motion) { - XDrawRectangle(display, clientwin, gc, xx1 - 1, yy1 - 1, xx2 - xx1 + 2, yy2 - yy1 + 2); - } - first_motion = 0; - XQueryPointer(display, xctx->window, &rw, &cw , &rmx, &rmy, &wmx, &wmy, &msq); - x2 = xx2 = rmx; - y2 = yy2 = rmy; - xx1 = x1; yy1 = y1; - INT_RECTORDER(xx1, yy1, xx2, yy2); - XDrawRectangle(display, clientwin, gc, xx1 - 1, yy1 - 1, xx2 - xx1 + 2, yy2 - yy1 + 2); - } - - if(grab_state == 1 && event == ButtonRelease) { - int grab_w = 0, grab_h = 0; - cairo_surface_t *sfc = NULL, *subsfc = NULL; - png_to_byte_closure_t closure; - char *encoded_data = NULL; - size_t olength; - char *prop = NULL; - - - grab_state = 0; - first_motion = 1; - xctx->ui_state &= ~GRABSCREEN; - XQueryPointer(display, xctx->window, &rw, &cw , &rmx, &rmy, &wmx, &wmy, &msq); - x2 = rmx; - y2 = rmy; - INT_RECTORDER(x1, y1, x2, y2); - tclvareval("grab release ", xctx->top_path, ".drw", NULL); - if(x2 - x1 > 10 && y2 -y1 > 10) { - xctx->push_undo(); - grab_w = (x2 - x1 + 1); - grab_h = (y2 - y1 + 1); - dbg(1, "grabscreen(): grab area: %d %d - %d %d\n", x1, y1, x2, y2); - dbg(1, "grabscreen(): root w=%d, h=%d\n", displayw, displayh); - sfc = cairo_xlib_surface_create(display, rw, visual, displayw, displayh); - if(!sfc || cairo_surface_status(sfc) != CAIRO_STATUS_SUCCESS) { - dbg(0, "grabscreen(): failure creating sfc\n"); - XFreeGC(display, gc); - XDestroyWindow(display, clientwin); - return 0; - } - dbg(1, "sfc: w=%d, h=%d\n", - cairo_xlib_surface_get_width(sfc), - cairo_xlib_surface_get_height(sfc)); - subsfc = cairo_surface_create_for_rectangle(sfc, x1, y1, grab_w, grab_h); - if(!subsfc || cairo_surface_status(subsfc) != CAIRO_STATUS_SUCCESS) { - dbg(0, "grabscreen(): failure creating subsfc\n"); - cairo_surface_destroy(sfc); - XFreeGC(display, gc); - XDestroyWindow(display, clientwin); - return 0; - } - closure.buffer = NULL; - closure.size = 0; - closure.pos = 0; - cairo_surface_write_to_png_stream(subsfc, png_writer, &closure); - cairo_surface_destroy(subsfc); - cairo_surface_destroy(sfc); - closure.size = closure.pos; - dbg(1, "closure.size = %ld\n", closure.size); - encoded_data = base64_encode((unsigned char *)closure.buffer, closure.size, &olength, 0); - dbg(1, "olength = %ld\n", olength); - my_free(_ALLOC_ID_, &closure.buffer); - my_mstrcat(_ALLOC_ID_, &prop, "flags=image,unscaled\nalpha=0.8\nimage_data=", encoded_data, NULL); - my_free(_ALLOC_ID_, &encoded_data); - storeobject(-1, xctx->mousex_snap, xctx->mousey_snap, xctx->mousex_snap + grab_w, xctx->mousey_snap + grab_h, - xRECT, GRIDLAYER, SELECTED, prop); - my_free(_ALLOC_ID_, &prop); - xctx->need_reb_sel_arr=1; - rebuild_selected_array(); - move_objects(START,0,0,0); - xctx->ui_state |= START_SYMPIN; - } - XFreeGC(display, gc); - XDestroyWindow(display, clientwin); - } - return 1; -} -#endif - void unselect_attached_floaters(void) { int c, i, found = 0; @@ -4103,35 +3977,6 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m case '|': if(0 && (state & ControlMask)) { /* testmode */ - static int x = 0; - - if(x == 0) { - int i; - XFillRectangle(display, xctx->window, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1, - xctx->areaw, xctx->areah); - XFlush(display); - sleep_ms(400); - for(i = xctx->xrect[0].x; i < xctx->xrect[0].width; i++) { - XDrawLine(display, xctx->window, xctx->gctiled, - i, xctx->xrect[0].y, i, xctx->xrect[0].height); - XFlush(display); - sleep_ms(4); - } - } else if(x == 1) { - int i; - XFillRectangle(display, xctx->window, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1, - xctx->areaw, xctx->areah); - XFlush(display); - sleep_ms(400); - for(i = xctx->xrect[0].x; i < xctx->xrect[0].width; i++) { - XDrawLine(display, xctx->window, xctx->gctiled, - i, xctx->xrect[0].y, i+1, xctx->xrect[0].height); - XFlush(display); - sleep_ms(4); - } - } - x++; - x %= 2; } break; diff --git a/src/draw.c b/src/draw.c index e4ce43b8..ec96a271 100644 --- a/src/draw.c +++ b/src/draw.c @@ -61,6 +61,23 @@ static void my_cairo_fill(cairo_surface_t *src_surface, int x, int y, unsigned i } #endif +int xserver_ok(void) +{ + int has_x = 1; + if(!getenv("DISPLAY") || !getenv("DISPLAY")[0]) has_x = 0; + else { + display = XOpenDisplay(NULL); + if(!display) { + has_x=0; + fprintf(errfp, "\n X server connection failed, although DISPLAY shell variable is set.\n" + " A possible reason is that the X server is not running or DISPLAY shell variable\n" + " is incorrectly set.\n" + " Starting Xschem in text only mode.\n\n"); + } else XCloseDisplay(display); + } + return has_x; +} + int textclip(int x1,int y1,int x2,int y2, double xa,double ya,double xb,double yb) /* check if some of (xa,ya-xb,yb) is inside (x1,y1-x2,y2) */ @@ -157,6 +174,132 @@ void print_image() xctx->do_copy_area=save; } +#if defined(__unix__) && HAS_CAIRO==1 +int grabscreen(const char *win_path, int event, int mx, int my, KeySym key, + int button, int aux, int state) +{ + static int grab_state = 0; + static int x1, y1, x2, y2; + int rmx, rmy, wmx, wmy; + unsigned int msq; + Window rw, cw; + XSetWindowAttributes winattr; + XGCValues gcv; + static GC gc = NULL; + static Window clientwin = 0; + static int first_motion = 1; + static int displayh = 0, displayw = 0; + static unsigned long white = 0; + + if(grab_state == 0 && event == ButtonPress && button == Button1) { + unsigned long gcvm = GCFunction | GCForeground; + + white = WhitePixel(display, screen_number); + displayh = DisplayHeight(display, screen_number); + displayw = DisplayWidth(display, screen_number); + + XQueryPointer(display, xctx->window, &rw, &cw , &rmx, &rmy, &wmx, &wmy, &msq); + gcv.function = GXxor; + gcv.foreground = white; + gc = XCreateGC(display, rw, gcvm, &gcv); + + winattr.override_redirect = True; + clientwin = XCreateWindow(display, rw, 0, 0, displayw, displayh, 0, screendepth, + InputOutput, visual, CWOverrideRedirect, &winattr); + XMapRaised(display,clientwin); + + x1 = rmx; + y1 = rmy; + dbg(1, "grabscreen(): got point1: %d %d\n", x1, y1); + grab_state = 1; + } + + if(grab_state == 1 && event == MotionNotify) { + static int xx1, xx2, yy1, yy2; + xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2; + INT_RECTORDER(xx1, yy1, xx2, yy2); + dbg(1, "Motion: %d %d %d %d\n", xx1, yy1, xx2, yy2); + if(!first_motion) { + XDrawRectangle(display, clientwin, gc, xx1 - 1, yy1 - 1, xx2 - xx1 + 2, yy2 - yy1 + 2); + } + first_motion = 0; + XQueryPointer(display, xctx->window, &rw, &cw , &rmx, &rmy, &wmx, &wmy, &msq); + x2 = xx2 = rmx; + y2 = yy2 = rmy; + xx1 = x1; yy1 = y1; + INT_RECTORDER(xx1, yy1, xx2, yy2); + XDrawRectangle(display, clientwin, gc, xx1 - 1, yy1 - 1, xx2 - xx1 + 2, yy2 - yy1 + 2); + } + + if(grab_state == 1 && event == ButtonRelease) { + int grab_w = 0, grab_h = 0; + cairo_surface_t *sfc = NULL, *subsfc = NULL; + png_to_byte_closure_t closure; + char *encoded_data = NULL; + size_t olength; + char *prop = NULL; + + + grab_state = 0; + first_motion = 1; + xctx->ui_state &= ~GRABSCREEN; + XQueryPointer(display, xctx->window, &rw, &cw , &rmx, &rmy, &wmx, &wmy, &msq); + x2 = rmx; + y2 = rmy; + INT_RECTORDER(x1, y1, x2, y2); + tclvareval("grab release ", xctx->top_path, ".drw", NULL); + if(x2 - x1 > 10 && y2 -y1 > 10) { + xctx->push_undo(); + grab_w = (x2 - x1 + 1); + grab_h = (y2 - y1 + 1); + dbg(1, "grabscreen(): grab area: %d %d - %d %d\n", x1, y1, x2, y2); + dbg(1, "grabscreen(): root w=%d, h=%d\n", displayw, displayh); + sfc = cairo_xlib_surface_create(display, rw, visual, displayw, displayh); + if(!sfc || cairo_surface_status(sfc) != CAIRO_STATUS_SUCCESS) { + dbg(0, "grabscreen(): failure creating sfc\n"); + XFreeGC(display, gc); + XDestroyWindow(display, clientwin); + return 0; + } + dbg(1, "sfc: w=%d, h=%d\n", + cairo_xlib_surface_get_width(sfc), + cairo_xlib_surface_get_height(sfc)); + subsfc = cairo_surface_create_for_rectangle(sfc, x1, y1, grab_w, grab_h); + if(!subsfc || cairo_surface_status(subsfc) != CAIRO_STATUS_SUCCESS) { + dbg(0, "grabscreen(): failure creating subsfc\n"); + cairo_surface_destroy(sfc); + XFreeGC(display, gc); + XDestroyWindow(display, clientwin); + return 0; + } + closure.buffer = NULL; + closure.size = 0; + closure.pos = 0; + cairo_surface_write_to_png_stream(subsfc, png_writer, &closure); + cairo_surface_destroy(subsfc); + cairo_surface_destroy(sfc); + closure.size = closure.pos; + dbg(1, "closure.size = %ld\n", closure.size); + encoded_data = base64_encode((unsigned char *)closure.buffer, closure.size, &olength, 0); + dbg(1, "olength = %ld\n", olength); + my_free(_ALLOC_ID_, &closure.buffer); + my_mstrcat(_ALLOC_ID_, &prop, "flags=image,unscaled\nalpha=0.8\nimage_data=", encoded_data, NULL); + my_free(_ALLOC_ID_, &encoded_data); + storeobject(-1, xctx->mousex_snap, xctx->mousey_snap, xctx->mousex_snap + grab_w, xctx->mousey_snap + grab_h, + xRECT, GRIDLAYER, SELECTED, prop); + my_free(_ALLOC_ID_, &prop); + xctx->need_reb_sel_arr=1; + rebuild_selected_array(); + move_objects(START,0,0,0); + xctx->ui_state |= START_SYMPIN; + } + XFreeGC(display, gc); + XDestroyWindow(display, clientwin); + } + return 1; +} +#endif + #if HAS_CAIRO==1 static void set_cairo_color(int layer) { diff --git a/src/main.c b/src/main.c index f3a5d07d..ecd84629 100644 --- a/src/main.c +++ b/src/main.c @@ -78,7 +78,6 @@ int main(int argc, char **argv) int stdin_is_a_fifo = 0; struct stat statbuf; #endif - Display *display; signal(SIGINT, sig_handler); signal(SIGSEGV, sig_handler); signal(SIGILL, sig_handler); @@ -92,17 +91,7 @@ int main(int argc, char **argv) errfp=stderr; /* 20181013 check for empty or non existing DISPLAY *before* calling Tk_Main or Tcl_Main */ #ifdef __unix__ - if(!getenv("DISPLAY") || !getenv("DISPLAY")[0]) has_x=0; - else { - display = XOpenDisplay(NULL); - if(!display) { - has_x=0; - fprintf(errfp, "\n X server connection failed, although DISPLAY shell variable is set.\n" - " A possible reason is that the X server is not running or DISPLAY shell variable\n" - " is incorrectly set.\n" - " Starting Xschem in text only mode.\n\n"); - } else XCloseDisplay(display); - } + has_x = xserver_ok(); #endif cli_argc = argc; cli_opt_argc = process_options(argc, argv); diff --git a/src/xschem.h b/src/xschem.h index 3128dc1d..7c052f3d 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1335,6 +1335,9 @@ extern void svg_draw(void); extern void svg_embedded_graph(FILE *fd, int i, double rx1, double ry1, double rx2, double ry2); extern void set_viewport_size(int w, int h, double lw); extern void print_image(); +extern int grabscreen(const char *win_path, int event, int mx, int my, KeySym key, + int button, int aux, int state); +extern int xserver_ok(void); extern const char *get_trailing_path(const char *str, int no_of_dir, int skip_ext); extern const char *get_cell(const char *str, int no_of_dir); extern const char *get_cell_w_ext(const char *str, int no_of_dir); diff --git a/xschem_library/ngspice/boost.sch b/xschem_library/ngspice/boost.sch index 71316328..68d99e31 100644 --- a/xschem_library/ngspice/boost.sch +++ b/xschem_library/ngspice/boost.sch @@ -5,15 +5,15 @@ V {} S {} E {} B 2 880 -290 1430 -110 {flags=graph -y1=2.5e-05 +y1=0.00013 y2=45 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.0044053357 -x2=0.0045174308 +x1=0.0042932407 +x2=0.0044053357 divx=5 subdivx=1 xlabmag=1.0 @@ -38,8 +38,8 @@ ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.0044053357 -x2=0.0045174308 +x1=0.0042932407 +x2=0.0044053357 divx=5 subdivx=1 xlabmag=1.5 @@ -55,14 +55,14 @@ g1" linewidth_mult=1.2} B 2 880 -500 1430 -400 {flags=graph y1=1.3 -y2=8 +y2=7.5 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.0044053357 -x2=0.0045174308 +x1=0.0042932407 +x2=0.0044053357 divx=5 subdivx=1 xlabmag=1.5 @@ -78,14 +78,14 @@ i(vbatt)" linewidth_mult=1.2} B 2 880 -590 1430 -500 {flags=graph y1=0 -y2=84 +y2=78 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.0044053357 -x2=0.0045174308 +x1=0.0042932407 +x2=0.0044053357 divx=5 subdivx=1 xlabmag=1.5 @@ -101,14 +101,14 @@ i(vm1) supply * 24u ravg()" linewidth_mult=1.2} B 2 880 -700 1430 -590 {flags=graph y1=-0.014 -y2=2.9 +y2=2.6 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.0044053357 -x2=0.0045174308 +x1=0.0042932407 +x2=0.0044053357 divx=5 subdivx=1 xlabmag=1.5 @@ -156,7 +156,7 @@ place=end value=" .ic v(diode)=12 v(batt)=42 .param VCC=12 -.include stimuli.cir +.include stimuli_boost.cir .option method=gear gmin=1e-12 + itl1=1000 itl2=1000 itl4=1000 itl5=0 .control @@ -173,9 +173,9 @@ tclcommand="set_sim_defaults; set sim(spice,0,fg) 1; xschem netlist; xschem simu C {res.sym} 780 -150 0 0 {name=RLOAD value=30 footprint=1206 device=resistor m=1} C {lab_pin.sym} 800 -270 2 0 {name=l6 lab=BATT} C {lab_pin.sym} 780 -100 0 0 {name=l2 lab=0} -C {capa.sym} 680 -150 0 0 {name=C1 m=1 value="100u ic=42" footprint=1206 device="ceramic capacitor"} +C {capa.sym} 680 -150 0 0 {name=C1 m=1 value="30u ic=42" footprint=1206 device="ceramic capacitor"} C {lab_pin.sym} 680 -100 0 0 {name=l7 lab=0} -C {lab_wire.sym} 510 -270 0 1 {name=l10 lab=DIODE} +C {lab_wire.sym} 530 -270 0 1 {name=l10 lab=DIODE} C {lab_pin.sym} 80 -270 0 0 {name=l11 lab=SUPPLY} C {ammeter.sym} 780 -210 0 1 {name=vbatt} C {launcher.sym} 1160 -90 0 0 {name=h5 diff --git a/xschem_library/ngspice/buck_boost.sch b/xschem_library/ngspice/buck_boost.sch index 873f8916..25f3c0e7 100644 --- a/xschem_library/ngspice/buck_boost.sch +++ b/xschem_library/ngspice/buck_boost.sch @@ -5,15 +5,15 @@ V {} S {} E {} B 2 880 -290 1430 -110 {flags=graph -y1=-45 +y1=-42 y2=12 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.003147633 -x2=0.0032007081 +x1=0.0035110393 +x2=0.0037319804 divx=5 subdivx=1 xlabmag=1.0 @@ -31,15 +31,15 @@ logy=0 hilight_wave=-1 linewidth_mult=1.2} B 2 880 -400 1430 -290 {flags=graph -y1=-0.0009 +y1=-0.00023 y2=12 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.003147633 -x2=0.0032007081 +x1=0.0035110393 +x2=0.0037319804 divx=5 subdivx=1 xlabmag=1.5 @@ -55,14 +55,14 @@ g1" linewidth_mult=1.2} B 2 880 -500 1430 -400 {flags=graph y1=-1.5 -y2=11 +y2=36 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.003147633 -x2=0.0032007081 +x1=0.0035110393 +x2=0.0037319804 divx=5 subdivx=1 xlabmag=1.5 @@ -72,20 +72,21 @@ unitx=1 logx=0 logy=0 hilight_wave=-1 -color="4 7" +color="4 7 17" node="i(vm1) -i(vbatt)" +i(vbatt) +i(vind)" linewidth_mult=1.2} B 2 880 -590 1430 -500 {flags=graph y1=0 -y2=77 +y2=61 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.003147633 -x2=0.0032007081 +x1=0.0035110393 +x2=0.0037319804 divx=5 subdivx=1 xlabmag=1.5 @@ -101,14 +102,14 @@ i(vm1) supply * 24u ravg()" linewidth_mult=1.2} B 2 880 -700 1430 -590 {flags=graph y1=0 -y2=10 +y2=2.8 ypos1=0 ypos2=2 divy=5 subdivy=1 unity=1 -x1=0.003147633 -x2=0.0032007081 +x1=0.0035110393 +x2=0.0037319804 divx=5 subdivx=1 xlabmag=1.5 @@ -137,7 +138,7 @@ N 780 -330 780 -240 {lab=BATT} N 680 -330 780 -330 {lab=BATT} N 400 -330 500 -330 {lab=DIODE} N 110 -430 150 -430 {lab=G1} -N -10 -430 30 -430 {lab=PWM1} +N -50 -430 30 -430 {lab=PWM1} N 80 -170 80 -100 {lab=0} N 80 -330 80 -230 {lab=SUPPLY} N 300 -250 300 -240 {lab=#net1} @@ -157,7 +158,7 @@ place=end value=" .ic v(diode)=12 v(batt)=42 .param VCC=12 -.include stimuli.cir +.include stimuli_buck_boost.cir .option method=gear gmin=1e-10 + itl1=1000 itl2=100 itl4=1000 itl5=0 .control @@ -175,7 +176,7 @@ tclcommand="set_sim_defaults; set sim(spice,0,fg) 1; xschem netlist; xschem simu C {res.sym} 780 -150 0 0 {name=RLOAD value=30 footprint=1206 device=resistor m=1} C {lab_pin.sym} 800 -330 2 0 {name=l6 lab=BATT} C {lab_pin.sym} 780 -100 0 0 {name=l2 lab=0} -C {capa.sym} 680 -150 0 0 {name=C1 m=1 value="100u ic=42" footprint=1206 device="ceramic capacitor"} +C {capa.sym} 680 -150 0 0 {name=C1 m=1 value="20u ic=42" footprint=1206 device="ceramic capacitor"} C {lab_pin.sym} 680 -100 0 0 {name=l7 lab=0} C {lab_wire.sym} 420 -330 0 1 {name=l10 lab=DIODE} C {lab_pin.sym} 80 -330 0 0 {name=l11 lab=SUPPLY} @@ -184,7 +185,7 @@ C {launcher.sym} 1160 -90 0 0 {name=h5 descr="load waves" tclcommand="xschem raw_read $netlist_dir/buck_boost.raw tran" } -C {ipin.sym} -10 -430 0 0 {name=p3 lab=PWM1} +C {ipin.sym} -50 -430 0 0 {name=p3 lab=PWM1} C {ammeter.sym} 370 -330 1 0 {name=vdiode} C {diode.sym} 530 -330 1 0 {name=XD2 model=STPST15H100SB area=1 format="@name @pinlist @model" @@ -215,11 +216,11 @@ attach=l8} C {res.sym} 300 -150 0 0 {name=Rind1 value=0.05 footprint=1206 device=resistor m=1 hide_texts=true attach=Rind1} -C {lab_wire.sym} 120 -430 0 1 {name=l4 lab=G1} +C {lab_wire.sym} 150 -430 0 1 {name=l4 lab=G1} C {buf_ngspice.sym} 70 -430 0 0 {name=x1 RUP=10 RDOWN=10} C {vsource.sym} 80 -200 0 0 {name=VSUPPLY value=12 savecurrent=false} C {lab_pin.sym} 300 -100 0 0 {name=l12 lab=0} -C {pmos3.sym} 150 -350 3 1 {name=XM1 model=irfr5410 m=1 +C {pmos3.sym} 150 -350 3 1 {name=XM1 model=irf5305 m=1 device_model=" .SUBCKT irfr5410 1 2 3 ************************************** @@ -277,6 +278,73 @@ D4 6 0 MD3 * RS=0 BV=infinite IBV=1mA .MODEL MD3 D IS=1e-10 N=1 .ENDS irfr5410 + + + + + +.SUBCKT irf5305 1 2 3 +************************************** +* Model Generated by MODPEX * +*Copyright(c) Symmetry Design Systems* +* All Rights Reserved * +* UNPUBLISHED LICENSED SOFTWARE * +* Contains Proprietary Information * +* Which is The Property of * +* SYMMETRY OR ITS LICENSORS * +*Commercial Use or Resale Restricted * +* by Symmetry License Agreement * +************************************** +* Model generated on Apr 23, 96 +* Model format: SPICE3 +* Symmetry POWER MOS Model (Version 1.0) +* External Node Designations +* Node 1 -> Drain +* Node 2 -> Gate +* Node 3 -> Source +M1 9 7 8 8 MM L=100u W=100u +* Default values used in MM: +* The voltage-dependent capacitances are +* not included. Other default values are: +* RS=0 RD=0 LD=0 CBD=0 CBS=0 CGBO=0 +.MODEL MM PMOS LEVEL=1 IS=1e-32 ++VTO=-3.45761 LAMBDA=0 KP=10.066 ++CGSO=1.03141e-05 CGDO=1e-11 +RS 8 3 0.0262305 +D1 1 3 MD +.MODEL MD D IS=8.90854e-09 RS=0.00921723 N=1.5 BV=55 ++IBV=0.00025 EG=1.2 XTI=3.13635 TT=1e-07 ++CJO=1.30546e-09 VJ=0.663932 M=0.419045 FC=0.5 +RDS 3 1 2.2e+06 +RD 9 1 0.0001 +RG 2 7 11.0979 +D2 5 4 MD1 +* Default values used in MD1: +* RS=0 EG=1.11 XTI=3.0 TT=0 +* BV=infinite IBV=1mA +.MODEL MD1 D IS=1e-32 N=50 ++CJO=1.63729e-09 VJ=0.791199 M=0.552278 FC=1e-08 +D3 5 0 MD2 +* Default values used in MD2: +* EG=1.11 XTI=3.0 TT=0 CJO=0 +* BV=infinite IBV=1mA +.MODEL MD2 D IS=1e-10 N=0.400245 RS=3e-06 +RL 5 10 1 +FI2 7 9 VFI2 -1 +VFI2 4 0 0 +EV16 10 0 9 7 1 +CAP 11 10 1.89722e-09 +FI1 7 9 VFI1 -1 +VFI1 11 6 0 +RCAP 6 10 1 +D4 6 0 MD3 +* Default values used in MD3: +* EG=1.11 XTI=3.0 TT=0 CJO=0 +* RS=0 BV=infinite IBV=1mA +.MODEL MD3 D IS=1e-10 N=0.400245 +.ENDS + + "} C {ammeter.sym} 250 -330 3 1 {name=vm1} C {ammeter.sym} 300 -280 0 1 {name=vind} diff --git a/xschem_library/ngspice/buf_ngspice.sym b/xschem_library/ngspice/buf_ngspice.sym index 2fb4ad37..77dcd24d 100644 --- a/xschem_library/ngspice/buf_ngspice.sym +++ b/xschem_library/ngspice/buf_ngspice.sym @@ -1,4 +1,4 @@ -v {xschem version=3.4.5 file_version=1.2 +v {xschem version=3.4.7RC file_version=1.2 * * This file is part of XSCHEM, * a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit @@ -40,5 +40,7 @@ T {Y} 7.5 -6.5 0 1 0.2 0.2 {} T {A} -17.5 -6.5 0 0 0.2 0.2 {} T {RUP=@RUP RDOWN=@RDOWN} -25 -52 0 0 0.2 0.2 {} -T {@#1:net_name} -22.5 6.25 0 1 0.15 0.15 {layer=15} -T {@#0:net_name} 17.5 6.25 0 0 0.15 0.15 {layer=15} +T {@#1:net_name} -22.5 6.25 0 1 0.15 0.15 {layer=15 +hide=instance} +T {@#0:net_name} 17.5 6.25 0 0 0.15 0.15 {layer=15 +hide=instance} diff --git a/xschem_library/ngspice/stimuli.boost b/xschem_library/ngspice/stimuli.boost index 897b2190..827f3526 100644 --- a/xschem_library/ngspice/stimuli.boost +++ b/xschem_library/ngspice/stimuli.boost @@ -6,7 +6,7 @@ slope 0.1 format hspice param pw 8.7 param period 12 -beginfile stimuli.cir +beginfile stimuli_boost.cir set SUPPLY 12 set PWM1 0 s 1 diff --git a/xschem_library/ngspice/stimuli.buck_boost b/xschem_library/ngspice/stimuli.buck_boost index e89de7cb..9d50bece 100644 --- a/xschem_library/ngspice/stimuli.buck_boost +++ b/xschem_library/ngspice/stimuli.buck_boost @@ -4,9 +4,9 @@ voltage 12.0 ground_node 0 slope 0.1 format hspice -param pw 2.3 +param pw 2.7 param period 12 -beginfile stimuli.cir +beginfile stimuli_buck_boost.cir set PWM1 0 s 1 clock PWM1 pw period