diff --git a/src/callback.c b/src/callback.c index 00dc1cde..2105cba6 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1025,7 +1025,7 @@ int callback(int event, int mx, int my, KeySym key, if(key=='*' && state==ShiftMask ) /* postscript print */ { if(xctx->semaphore >= 2) break; - ps_draw(); + ps_draw(7); break; } if(key=='*' && state==(ControlMask|ShiftMask) ) /* xpm print */ diff --git a/src/draw.c b/src/draw.c index 9b880fc5..5c3096b6 100644 --- a/src/draw.c +++ b/src/draw.c @@ -87,7 +87,7 @@ void print_image() } else tcleval( "convert_to_png plot.xpm plot.png"); #else char *psfile=NULL; - create_ps(&psfile); + create_ps(&psfile, 7); if(plotfile[0]) { my_snprintf(cmd, S(cmd), "convert_to_png {%s} {%s}", psfile, plotfile); tcleval(cmd); diff --git a/src/psprint.c b/src/psprint.c index bf3b099b..83cea831 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -648,10 +648,11 @@ static void fill_ps_colors() } -void create_ps(char **psfile) +void create_ps(char **psfile, int what) { double dx, dy, scale, scaley; int landscape=1; + static int numpages = 0; double margin=10; /* in postscript points, (1/72)". No need to add margin as xschem zoom full already has margins.*/ /* Legal: 612 792 */ @@ -662,9 +663,12 @@ void create_ps(char **psfile) int old_grid; const char *textfont; - if(!(fd = open_tmpfile("psplot_", psfile)) ) { - fprintf(errfp, "ps_draw(): can not create tmpfile %s\n", *psfile); - return; + if(what & 1) { /* prolog */ + numpages = 0; + if(!(fd = open_tmpfile("psplot_", psfile)) ) { + fprintf(errfp, "ps_draw(): can not create tmpfile %s\n", *psfile); + return; + } } ps_colors=my_calloc(311, cadlayers, sizeof(Ps_color)); if(ps_colors==NULL){ @@ -692,199 +696,216 @@ void create_ps(char **psfile) pagey = tmp; } - dbg(1, "ps_draw(): bbox: x1=%g y1=%g x2=%g y2=%g\n", boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2); - fprintf(fd, "%%!PS-Adobe-3.0\n"); - /* fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", landscape ? "a4land" : "a4", pagex, pagey); */ - fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", "a4", pagex, pagey); - fprintf(fd, "%%%%PageOrientation: %s\n", landscape ? "Landscape" : "Portrait"); - fprintf(fd, "%%%%Title: xschem plot\n"); - fprintf(fd, "%%%%Creator: xschem\n"); - fprintf(fd, "%%%%Pages: 1\n"); - fprintf(fd, "%%%%EndComments\n"); - fprintf(fd, "%%%%BeginProlog\n\n"); - - for(i = 0; i < sizeof(utf8_enc)/sizeof(char *); i++) { - fprintf(fd, utf8_enc[i]); - } - for(i = 0; i < sizeof(utf8)/sizeof(char *); i++) { - fprintf(fd, utf8[i]); - } - - fprintf(fd, "/Times /Times chararr recode\n"); - fprintf(fd, "/Times-Bold /Times-Bold chararr recode\n"); - fprintf(fd, "/Times-Oblique /Times-Oblique chararr recode\n"); - fprintf(fd, "/Times-BoldOblique /Times-BoldOblique chararr recode\n"); - fprintf(fd, "/Helvetica /Helvetica chararr recode\n"); - fprintf(fd, "/Helvetica-Bold /Helvetica-Bold chararr recode\n"); - fprintf(fd, "/Helvetica-Oblique /Helvetica-Oblique chararr recode\n"); - fprintf(fd, "/Helvetica-BoldOblique /Helvetica-BoldOblique chararr recode\n"); - fprintf(fd, "/Courier /Courier chararr recode\n"); - fprintf(fd, "/Courier-Bold /Courier-Bold chararr recode\n"); - fprintf(fd, "/Courier-Oblique /Courier-Oblique chararr recode\n"); - fprintf(fd, "/Courier-BoldOblique /Courier-BoldOblique chararr recode\n"); - - fprintf(fd,"/cm {28.346457 mul} bind def\n"); - fprintf(fd,"/LT {lineto} bind def\n"); - fprintf(fd,"/MT {moveto} bind def\n"); - fprintf(fd,"/RMT {rmoveto} bind def\n"); - fprintf(fd,"/L {moveto lineto stroke} bind def\n"); - fprintf(fd,"/RGB {setrgbcolor} bind def\n"); - fprintf(fd,"/FF {findfont} bind def\n"); - fprintf(fd,"/SF {setfont} bind def\n"); - fprintf(fd,"/SCF {scalefont} bind def\n"); - fprintf(fd,"/SW {stringwidth} bind def\n"); - fprintf(fd,"/GS {gsave} bind def\n"); - fprintf(fd,"/GR {grestore} bind def\n"); - fprintf(fd,"/NP {newpath} bind def\n"); - fprintf(fd,"/A {arcn} bind def\n"); - fprintf(fd,"/R {rectstroke} bind def\n"); - fprintf(fd,"/S {stroke} bind def\n"); - fprintf(fd,"/C {closepath} bind def\n"); - fprintf(fd,"/F {fill} bind def\n"); - fprintf(fd,"/RF {rectfill} bind def\n"); - fprintf(fd, "%%%%EndProlog\n"); - fprintf(fd, "%%%%BeginSetup\n"); - fprintf(fd, "<< /PageSize [%g %g] /Orientation 0 >> setpagedevice\n", pagex, pagey); - fprintf(fd, "%%%%Page: 1 1\n\n"); - fprintf(fd, "%%%%BeginPageSetup\n"); - fprintf(fd, "%%%%EndPageSetup\n"); - - scaley = scale = (pagey-2 * margin) / dy; - dbg(1, "scale=%g pagex=%g pagey=%g dx=%g dy=%g\n", scale, pagex, pagey, dx, dy); - if(dx * scale > (pagex - 2 * margin)) { - scale = (pagex - 2 * margin) / dx; - dbg(1, "scale=%g\n", scale); - } - fprintf(fd, "%g %g translate\n", - -scale * boundbox.x1 + margin, pagey - (scaley - scale) * dy - margin + scale * boundbox.y1); - fprintf(fd, "%g %g scale\n", scale, -scale); - fprintf(fd, "1 setlinejoin 1 setlinecap\n"); - set_lw(); - ps_drawgrid(); - - for(i=0;itexts;i++) - { - textlayer = xctx->text[i].layer; - if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; - - my_snprintf(ps_font_family, S(ps_font_name), "Helvetica"); - my_snprintf(ps_font_name, S(ps_font_name), "Helvetica"); - textfont = xctx->text[i].font; - if( (textfont && textfont[0])) { - my_snprintf(ps_font_family, S(ps_font_family), textfont); - my_snprintf(ps_font_name, S(ps_font_name), textfont); + if(what & 1) {/* prolog */ + dbg(1, "ps_draw(): bbox: x1=%g y1=%g x2=%g y2=%g\n", boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2); + fprintf(fd, "%%!PS-Adobe-3.0\n"); + /* fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", landscape ? "a4land" : "a4", pagex, pagey); */ + fprintf(fd, "%%%%DocumentMedia: %s %g %g 80 () ()\n", "a4", pagex, pagey); + fprintf(fd, "%%%%PageOrientation: %s\n", landscape ? "Landscape" : "Portrait"); + fprintf(fd, "%%%%Title: xschem plot\n"); + fprintf(fd, "%%%%Creator: xschem\n"); + fprintf(fd, "%%%%Pages: (atend)\n"); + fprintf(fd, "%%%%EndComments\n"); + fprintf(fd, "%%%%BeginProlog\n\n"); + + for(i = 0; i < sizeof(utf8_enc)/sizeof(char *); i++) { + fprintf(fd, utf8_enc[i]); } - if( xctx->text[i].flags & TEXT_BOLD) { - if( (xctx->text[i].flags & TEXT_ITALIC) || (xctx->text[i].flags & TEXT_OBLIQUE) ) { - my_snprintf(ps_font_family, S(ps_font_family), "%s-BoldOblique", ps_font_name); + for(i = 0; i < sizeof(utf8)/sizeof(char *); i++) { + fprintf(fd, utf8[i]); + } + + fprintf(fd, "/Times /Times chararr recode\n"); + fprintf(fd, "/Times-Bold /Times-Bold chararr recode\n"); + fprintf(fd, "/Times-Oblique /Times-Oblique chararr recode\n"); + fprintf(fd, "/Times-BoldOblique /Times-BoldOblique chararr recode\n"); + fprintf(fd, "/Helvetica /Helvetica chararr recode\n"); + fprintf(fd, "/Helvetica-Bold /Helvetica-Bold chararr recode\n"); + fprintf(fd, "/Helvetica-Oblique /Helvetica-Oblique chararr recode\n"); + fprintf(fd, "/Helvetica-BoldOblique /Helvetica-BoldOblique chararr recode\n"); + fprintf(fd, "/Courier /Courier chararr recode\n"); + fprintf(fd, "/Courier-Bold /Courier-Bold chararr recode\n"); + fprintf(fd, "/Courier-Oblique /Courier-Oblique chararr recode\n"); + fprintf(fd, "/Courier-BoldOblique /Courier-BoldOblique chararr recode\n"); + + fprintf(fd,"/cm {28.346457 mul} bind def\n"); + fprintf(fd,"/LT {lineto} bind def\n"); + fprintf(fd,"/MT {moveto} bind def\n"); + fprintf(fd,"/RMT {rmoveto} bind def\n"); + fprintf(fd,"/L {moveto lineto stroke} bind def\n"); + fprintf(fd,"/RGB {setrgbcolor} bind def\n"); + fprintf(fd,"/FF {findfont} bind def\n"); + fprintf(fd,"/SF {setfont} bind def\n"); + fprintf(fd,"/SCF {scalefont} bind def\n"); + fprintf(fd,"/SW {stringwidth} bind def\n"); + fprintf(fd,"/GS {gsave} bind def\n"); + fprintf(fd,"/GR {grestore} bind def\n"); + fprintf(fd,"/NP {newpath} bind def\n"); + fprintf(fd,"/A {arcn} bind def\n"); + fprintf(fd,"/R {rectstroke} bind def\n"); + fprintf(fd,"/S {stroke} bind def\n"); + fprintf(fd,"/C {closepath} bind def\n"); + fprintf(fd,"/F {fill} bind def\n"); + fprintf(fd,"/RF {rectfill} bind def\n"); + fprintf(fd, "%%%%EndProlog\n"); + } + + + if(what & 2) { /* page */ + numpages++; + fprintf(fd, "%%%%BeginSetup\n"); + fprintf(fd, "<< /PageSize [%g %g] /Orientation 0 >> setpagedevice\n", pagex, pagey); + fprintf(fd, "%%%%Page: %d %d\n\n", numpages, numpages); + fprintf(fd, "%%%%BeginPageSetup\n"); + fprintf(fd, "%%%%EndPageSetup\n"); + + scaley = scale = (pagey-2 * margin) / dy; + dbg(1, "scale=%g pagex=%g pagey=%g dx=%g dy=%g\n", scale, pagex, pagey, dx, dy); + if(dx * scale > (pagex - 2 * margin)) { + scale = (pagex - 2 * margin) / dx; + dbg(1, "scale=%g\n", scale); + } + fprintf(fd, "%g %g translate\n", + -scale * boundbox.x1 + margin, pagey - (scaley - scale) * dy - margin + scale * boundbox.y1); + fprintf(fd, "%g %g scale\n", scale, -scale); + fprintf(fd, "1 setlinejoin 1 setlinecap\n"); + + + set_lw(); + ps_drawgrid(); + + for(i=0;itexts;i++) + { + textlayer = xctx->text[i].layer; + if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; + + my_snprintf(ps_font_family, S(ps_font_name), "Helvetica"); + my_snprintf(ps_font_name, S(ps_font_name), "Helvetica"); + textfont = xctx->text[i].font; + if( (textfont && textfont[0])) { + my_snprintf(ps_font_family, S(ps_font_family), textfont); + my_snprintf(ps_font_name, S(ps_font_name), textfont); + } + if( xctx->text[i].flags & TEXT_BOLD) { + if( (xctx->text[i].flags & TEXT_ITALIC) || (xctx->text[i].flags & TEXT_OBLIQUE) ) { + my_snprintf(ps_font_family, S(ps_font_family), "%s-BoldOblique", ps_font_name); + } else { + my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name); + } + } + else if( xctx->text[i].flags & TEXT_ITALIC) + my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name); + else if( xctx->text[i].flags & TEXT_OBLIQUE) + my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name); + + if(text_ps) { + ps_draw_string(textlayer, xctx->text[i].txt_ptr, + xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, + xctx->text[i].x0,xctx->text[i].y0, + xctx->text[i].xscale, xctx->text[i].yscale); } else { - my_snprintf(ps_font_family, S(ps_font_family), "%s-Bold", ps_font_name); + old_ps_draw_string(textlayer, xctx->text[i].txt_ptr, + xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, + xctx->text[i].x0,xctx->text[i].y0, + xctx->text[i].xscale, xctx->text[i].yscale); } } - else if( xctx->text[i].flags & TEXT_ITALIC) - my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name); - else if( xctx->text[i].flags & TEXT_OBLIQUE) - my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name); - - if(text_ps) { - ps_draw_string(textlayer, xctx->text[i].txt_ptr, - xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, - xctx->text[i].x0,xctx->text[i].y0, - xctx->text[i].xscale, xctx->text[i].yscale); - } else { - old_ps_draw_string(textlayer, xctx->text[i].txt_ptr, - xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, - xctx->text[i].x0,xctx->text[i].y0, - xctx->text[i].xscale, xctx->text[i].yscale); - } - } - for(c=0;clines[c];i++) - ps_drawline(c, xctx->line[c][i].x1, xctx->line[c][i].y1, - xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash); - for(i=0;irects[c];i++) + for(c=0;crect[c][i].x1, xctx->rect[c][i].y1, - xctx->rect[c][i].x2, xctx->rect[c][i].y2, xctx->rect[c][i].dash); + set_ps_colors(c); + for(i=0;ilines[c];i++) + ps_drawline(c, xctx->line[c][i].x1, xctx->line[c][i].y1, + xctx->line[c][i].x2, xctx->line[c][i].y2, xctx->line[c][i].dash); + for(i=0;irects[c];i++) + { + ps_filledrect(c, xctx->rect[c][i].x1, xctx->rect[c][i].y1, + xctx->rect[c][i].x2, xctx->rect[c][i].y2, xctx->rect[c][i].dash); + } + for(i=0;iarcs[c];i++) + { + ps_drawarc(c, xctx->arc[c][i].fill, xctx->arc[c][i].x, xctx->arc[c][i].y, + xctx->arc[c][i].r, xctx->arc[c][i].a, xctx->arc[c][i].b, xctx->arc[c][i].dash); + } + for(i=0;ipolygons[c];i++) { + ps_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points, + xctx->poly[c][i].fill, xctx->poly[c][i].dash); + } + for(i=0;iinstances;i++) + ps_draw_symbol(i,c,0,0,0.0,0.0); } - for(i=0;iarcs[c];i++) + set_ps_colors(WIRELAYER); + for(i=0;iwires;i++) { - ps_drawarc(c, xctx->arc[c][i].fill, xctx->arc[c][i].x, xctx->arc[c][i].y, - xctx->arc[c][i].r, xctx->arc[c][i].a, xctx->arc[c][i].b, xctx->arc[c][i].dash); + ps_drawline(WIRELAYER, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0); } - for(i=0;ipolygons[c];i++) { - ps_drawpolygon(c, NOW, xctx->poly[c][i].x, xctx->poly[c][i].y, xctx->poly[c][i].points, - xctx->poly[c][i].fill, xctx->poly[c][i].dash); - } - for(i=0;iinstances;i++) - ps_draw_symbol(i,c,0,0,0.0,0.0); - } - set_ps_colors(WIRELAYER); - for(i=0;iwires;i++) - { - ps_drawline(WIRELAYER, xctx->wire[i].x1,xctx->wire[i].y1,xctx->wire[i].x2,xctx->wire[i].y2, 0); - } - - { - double x1, y1, x2, y2; - struct wireentry *wireptr; - int i; - struct iterator_ctx ctx; - update_conn_cues(0, 0); - /* draw connecting dots */ - x1 = X_TO_XSCHEM(xctx->areax1); - y1 = Y_TO_XSCHEM(xctx->areay1); - x2 = X_TO_XSCHEM(xctx->areax2); - y2 = Y_TO_XSCHEM(xctx->areay2); - for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) { - i = wireptr->n; - if( xctx->wire[i].end1 >1 ) { /* 20150331 draw_dots */ - ps_drawarc(WIRELAYER, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360, 0); - } - if( xctx->wire[i].end2 >1 ) { /* 20150331 draw_dots */ - ps_drawarc(WIRELAYER, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360, 0); + + { + double x1, y1, x2, y2; + struct wireentry *wireptr; + int i; + struct iterator_ctx ctx; + update_conn_cues(0, 0); + /* draw connecting dots */ + x1 = X_TO_XSCHEM(xctx->areax1); + y1 = Y_TO_XSCHEM(xctx->areay1); + x2 = X_TO_XSCHEM(xctx->areax2); + y2 = Y_TO_XSCHEM(xctx->areay2); + for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) { + i = wireptr->n; + if( xctx->wire[i].end1 >1 ) { /* 20150331 draw_dots */ + ps_drawarc(WIRELAYER, 1, xctx->wire[i].x1, xctx->wire[i].y1, cadhalfdotsize, 0, 360, 0); + } + if( xctx->wire[i].end2 >1 ) { /* 20150331 draw_dots */ + ps_drawarc(WIRELAYER, 1, xctx->wire[i].x2, xctx->wire[i].y2, cadhalfdotsize, 0, 360, 0); + } } } + + dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), plotfile); + fprintf(fd, "showpage\n\n"); + } + if(what & 4) { /* trailer */ + fprintf(fd, "%%%%trailer\n"); + fprintf(fd, "%%%%Pages: %d\n", numpages); + fprintf(fd, "%%%%EOF\n"); + fclose(fd); } - - dbg(1, "ps_draw(): INT_WIDTH(lw)=%d plotfile=%s\n",INT_WIDTH(xctx->lw), plotfile); - fprintf(fd, "showpage\n\n"); - fprintf(fd, "%%%%trailer\n"); - fprintf(fd, "%%%%EOF\n"); - fclose(fd); draw_grid=old_grid; my_free(879, &ps_colors); } -void ps_draw(void) +int ps_draw(int what) { char tmp[2*PATH_MAX+40]; static char lastdir[PATH_MAX] = ""; const char *r; - char *psfile; + static char *psfile; - if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir)); - if(!plotfile[0]) { - Tcl_VarEval(interp, "tk_getSaveFile -title {Select destination file} -initialfile ", - get_cell(xctx->sch[xctx->currsch], 0) , ".pdf -initialdir ", lastdir, NULL); - r = tclresult(); - if(r[0]) { - my_strncpy(plotfile, r, S(plotfile)); - Tcl_VarEval(interp, "file dirname ", plotfile, NULL); - my_strncpy(lastdir, tclresult(), S(lastdir)); + if(what & 1) { /* prolog */ + if(!lastdir[0]) my_strncpy(lastdir, pwd_dir, S(lastdir)); + if(!plotfile[0]) { + Tcl_VarEval(interp, "tk_getSaveFile -title {Select destination file} -initialfile ", + get_cell(xctx->sch[xctx->currsch], 0) , ".pdf -initialdir ", lastdir, NULL); + r = tclresult(); + if(r[0]) { + my_strncpy(plotfile, r, S(plotfile)); + Tcl_VarEval(interp, "file dirname ", plotfile, NULL); + my_strncpy(lastdir, tclresult(), S(lastdir)); + } + else return 0; } - else return; } - create_ps(&psfile); - if(plotfile[0]) { - my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} {%s}", psfile, plotfile); - } else { - my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} plot.pdf", psfile); + create_ps(&psfile, what); + if(what & 4) { /* trailer */ + if(plotfile[0]) { + my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} {%s}", psfile, plotfile); + } else { + my_snprintf(tmp, S(tmp), "convert_to_pdf {%s} plot.pdf", psfile); + } + my_strncpy(plotfile,"", S(plotfile)); + tcleval( tmp); + Tcl_SetResult(interp,"",TCL_STATIC); } - my_strncpy(plotfile,"", S(plotfile)); - tcleval( tmp); - Tcl_SetResult(interp,"",TCL_STATIC); + return 1; } diff --git a/src/scheduler.c b/src/scheduler.c index b0119570..f2753a35 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1061,6 +1061,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg #endif } + else if(!strcmp(argv[1],"hier_psprint")) + { + cmd_found = 1; + hier_psprint(); + Tcl_ResetResult(interp); + } else if(!strcmp(argv[1],"hilight")) { cmd_found = 1; @@ -1714,7 +1720,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } if(!strcmp(argv[2],"pdf") || !strcmp(argv[2],"ps")) { - ps_draw(); + ps_draw(7); } else if(!strcmp(argv[2],"png")) { int w = 0, h = 0; diff --git a/src/spice_netlist.c b/src/spice_netlist.c index b02556e6..96e3aeab 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -26,6 +26,78 @@ static struct hashentry *model_table[HASHSIZE]; static struct hashentry *model_entry; static struct hashentry *subckt_table[HASHSIZE]; + + + +void hier_psprint(void) /* netlister driver */ +{ + int i, save_ok; + char *subckt_name; + int spice_stop; + char filename[PATH_MAX]; + const char *str_tmp; + + if(!ps_draw(1)) return; /* prolog */ + if(xctx->modified) { + save_ok = save_schematic(xctx->sch[xctx->currsch]); + if(save_ok == -1) return; + } + + + free_hash(subckt_table); + zoom_full(0, 0, 1, 0.97); + ps_draw(2); /* page */ + dbg(0,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) ); + unselect_all(); + remove_symbols(); /* 20161205 ensure all unused symbols purged before descending hierarchy */ + load_schematic(1, xctx->sch[xctx->currsch], 0); + + my_strdup(1224, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]); + my_strcat(1227, &xctx->sch_path[xctx->currsch+1], "->netlisting"); + xctx->sch_path_hash[xctx->currsch+1] = 0; + xctx->currsch++; + subckt_name=NULL; + for(i=0;isymbols;i++) + { + if( strcmp(get_tok_value(xctx->sym[i].prop_ptr,"spice_ignore",0),"true")==0 ) continue; + if(!xctx->sym[i].type) continue; + if(strcmp(xctx->sym[i].type,"subcircuit")==0 && check_lib(abs_sym_path(xctx->sym[i].name, ""))) + { + /* xctx->sym can be SCH or SYM, use hash to avoid writing duplicate subckt */ + my_strdup(1228, &subckt_name, get_cell(xctx->sym[i].name, 0)); + if (str_hash_lookup(subckt_table, subckt_name, "", XLOOKUP)==NULL) + { + str_hash_lookup(subckt_table, subckt_name, "", XINSERT); + + if(!strcmp( get_tok_value(xctx->sym[i].prop_ptr,"spice_stop",0),"true") ) + spice_stop=1; + else + spice_stop=0; + if((str_tmp = get_tok_value(xctx->sym[i].prop_ptr, "schematic",0 ))[0]) { + my_strncpy(filename, abs_sym_path(str_tmp, ""), S(filename)); + } else { + my_strncpy(filename, add_ext(abs_sym_path(xctx->sym[i].name, ""), ".sch"), S(filename)); + } + spice_stop ? load_schematic(0,filename, 0) : load_schematic(1,filename, 0); + + zoom_full(0, 0, 1, 0.97); + ps_draw(2); /* page */ + dbg(0,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) ); + } + } + } + free_hash(subckt_table); + my_free(1229, &subckt_name); + my_strncpy(xctx->sch[xctx->currsch] , "", S(xctx->sch[xctx->currsch])); + xctx->currsch--; + unselect_all(); + load_schematic(1, xctx->sch[xctx->currsch], 0); + ps_draw(4); /* trailer */ +} + + + + void global_spice_netlist(int global) /* netlister driver */ { int first; diff --git a/src/xinit.c b/src/xinit.c index ee3f9383..232c63bd 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1656,7 +1656,7 @@ int Tcl_AppInit(Tcl_Interp *inter) xctx->areaw = xctx->areax2-xctx->areax1; xctx->areah = xctx->areay2-xctx->areay1; zoom_full(0, 0, 2, 0.97); - ps_draw(); + ps_draw(7); } else if(do_print == 2) { if(!has_x) { dbg(0, "xschem: can not do a png export if no X11 present / Xserver running (check if DISPLAY set).\n"); diff --git a/src/xschem.h b/src/xschem.h index 2a6b18ff..fe7775ee 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -861,8 +861,8 @@ extern int name_strcmp(char *s, char *d) ; extern int search(const char *tok, const char *val, int sub, int sel); extern int process_options(int argc, char **argv); extern void calc_drawing_bbox(xRect *boundbox, int selected); -extern void create_ps(char **psfile); -extern void ps_draw(void); +extern void create_ps(char **psfile, int what); +extern int ps_draw(int what); extern void svg_draw(void); extern void set_viewport_size(int w, int h, double lw); extern void print_image(); @@ -986,6 +986,7 @@ extern void store_poly(int pos, double *x, double *y, int points, extern void store_arc(int pos, double x, double y, double r, double a, double b, unsigned int rectcolor, unsigned short sel, char *prop_ptr); +extern void hier_psprint(void); extern void freenet_nocheck(int i); extern void spice_netlist(FILE *fd, int spice_stop); extern void tedax_netlist(FILE *fd, int spice_stop); diff --git a/src/xschem.tcl b/src/xschem.tcl index fcf781f9..6db98deb 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3838,6 +3838,7 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] -command "xschem saveas {} SYMBOL" -accelerator {Ctrl+Alt+S} # added svg, png 20171022 .menubar.file.menu add command -label "PDF/PS Export" -command "xschem print pdf" -accelerator {*} + .menubar.file.menu add command -label "Hierarchical PDF/PS Export" -command "xschem hier_psprint" .menubar.file.menu add command -label "PNG Export" -command "xschem print png" -accelerator {Ctrl+*} .menubar.file.menu add command -label "SVG Export" -command "xschem print svg" -accelerator {Alt+*} .menubar.file.menu add separator diff --git a/xschem_library/rom8k/lvnand3.sch b/xschem_library/rom8k/lvnand3.sch index f7b7dcb5..b22175dc 100644 --- a/xschem_library/rom8k/lvnand3.sch +++ b/xschem_library/rom8k/lvnand3.sch @@ -1,78 +1,80 @@ -v {xschem version=2.9.5_RC6 file_version=1.1} +v {xschem version=2.9.9 file_version=1.2 } G {} +K {} V {} S {} E {} -N 60 80 270 80 {lab=y} -N -70 -200 -10 -200 {lab=VCCPIN} -N -70 -170 -10 -170 {lab=VCCPIN} -N -70 -140 -70 80 {lab=y} -N 120 300 140 300 {lab=VSSBPIN} -N -130 -170 -110 -170 {lab=a} -N -20 -110 0 -110 {lab=b} -N -10 -200 -10 -170 {lab=VCCPIN} -N 120 170 120 190 {lab=#net1} -N 120 140 140 140 {lab=VSSBPIN} -N 120 80 120 110 {lab=y} -N 40 -140 100 -140 {lab=VCCPIN} -N 40 -110 100 -110 {lab=VCCPIN} -N 100 -140 100 -110 {lab=VCCPIN} -N 40 -80 40 80 {lab=y} -N -70 80 40 80 {lab=y} -N 40 80 60 80 {lab=y} -N -310 -170 -130 -170 {lab=a} -N -310 -110 -20 -110 {lab=b} -N 150 -80 210 -80 {lab=VCCPIN} -N 150 -50 210 -50 {lab=VCCPIN} -N 210 -80 210 -50 {lab=VCCPIN} -N -310 -50 110 -50 {lab=c} -N 150 -20 150 80 {lab=y} -N 120 220 140 220 {lab=VSSBPIN} -N 120 250 120 270 {lab=#net2} -N -180 300 80 300 {lab=a} -N -180 -170 -180 300 {lab=a} -N -160 -110 -160 220 {lab=b} -N -160 220 80 220 {lab=b} -N -140 140 80 140 {lab=c} -N -140 -50 -140 140 {lab=c} -C {lab_pin.sym} 120 330 0 0 {name=lg1 lab=VSSPIN} -C {lab_pin.sym} -70 -200 0 0 {name=lg2 lab=VCCPIN} -C {opin.sym} 270 80 0 0 {name=p1 lab=y verilog_type=wire} -C {ipin.sym} -310 -170 0 0 {name=p2 lab=a} -C {nlv4t.sym} 100 300 0 0 {name=m1 model=cmosn w=wn l=lln m=1 +N 560 -350 770 -350 {lab=y} +N 430 -630 490 -630 {lab=VCCPIN} +N 430 -600 490 -600 {lab=VCCPIN} +N 430 -570 430 -350 {lab=y} +N 620 -130 640 -130 {lab=VSSBPIN} +N 370 -600 390 -600 {lab=a} +N 480 -540 500 -540 {lab=b} +N 490 -630 490 -600 {lab=VCCPIN} +N 620 -260 620 -240 {lab=#net1} +N 620 -290 640 -290 {lab=VSSBPIN} +N 620 -350 620 -320 {lab=y} +N 540 -570 600 -570 {lab=VCCPIN} +N 540 -540 600 -540 {lab=VCCPIN} +N 600 -570 600 -540 {lab=VCCPIN} +N 540 -510 540 -350 {lab=y} +N 430 -350 540 -350 {lab=y} +N 540 -350 560 -350 {lab=y} +N 190 -600 370 -600 {lab=a} +N 190 -540 480 -540 {lab=b} +N 650 -510 710 -510 {lab=VCCPIN} +N 650 -480 710 -480 {lab=VCCPIN} +N 710 -510 710 -480 {lab=VCCPIN} +N 190 -480 610 -480 {lab=c} +N 650 -450 650 -350 {lab=y} +N 620 -210 640 -210 {lab=VSSBPIN} +N 620 -180 620 -160 {lab=#net2} +N 320 -130 580 -130 {lab=a} +N 320 -600 320 -130 {lab=a} +N 340 -540 340 -210 {lab=b} +N 340 -210 580 -210 {lab=b} +N 360 -290 580 -290 {lab=c} +N 360 -480 360 -290 {lab=c} +C {lab_pin.sym} 620 -100 0 0 {name=lg1 lab=VSSPIN} +C {lab_pin.sym} 430 -630 0 0 {name=lg2 lab=VCCPIN} +C {opin.sym} 770 -350 0 0 {name=p1 lab=y verilog_type=wire} +C {ipin.sym} 190 -600 0 0 {name=p2 lab=a} +C {nlv4t.sym} 600 -130 0 0 {name=m1 model=cmosn w=wn l=lln m=1 as="'0.270u*(wn)'" ad="'0.270u*(wn)'" ps="'2*0.270u+wn'" pd="'2*0.270u+wn'"} -C {plv4t.sym} -90 -170 0 0 {name=m2 model=cmosp w=wp l=lp m=1 +C {plv4t.sym} 410 -600 0 0 {name=m2 model=cmosp w=wp l=lp m=1 as="'0.270u*(wp)'" ad="'0.270u*(wp)'" ps="'2*0.270u+wp'" pd="'2*0.270u+wp'"} -C {plv4t.sym} 20 -110 0 0 {name=m3 model=cmosp w=wp l=lp m=1 +C {plv4t.sym} 520 -540 0 0 {name=m3 model=cmosp w=wp l=lp m=1 as="'0.270u*(wp)'" ad="'0.270u*(wp)'" ps="'2*0.270u+wp'" pd="'2*0.270u+wp'"} -C {nlv4t.sym} 100 140 0 0 {name=m5 model=cmosn w=wn l=lln m=1 +C {nlv4t.sym} 600 -290 0 0 {name=m5 model=cmosn w=wn l=lln m=1 as="'0.270u*(wn)'" ad="'0.270u*(wn)'" ps="'2*0.270u+wn'" pd="'2*0.270u+wn'"} -C {ipin.sym} -310 -110 0 0 {name=p3 lab=b} -C {lab_pin.sym} 40 -140 0 0 {name=l1 lab=VCCPIN} -C {ipin.sym} -310 -50 0 0 {name=p4 lab=c} -C {plv4t.sym} 130 -50 0 0 {name=m4 model=cmosp w=wp l=lp m=1 +C {ipin.sym} 190 -540 0 0 {name=p3 lab=b} +C {lab_pin.sym} 540 -570 0 0 {name=l1 lab=VCCPIN} +C {ipin.sym} 190 -480 0 0 {name=p4 lab=c} +C {plv4t.sym} 630 -480 0 0 {name=m4 model=cmosp w=wp l=lp m=1 as="'0.270u*(wp)'" ad="'0.270u*(wp)'" ps="'2*0.270u+wp'" pd="'2*0.270u+wp'"} -C {lab_pin.sym} 150 -80 0 0 {name=l0 lab=VCCPIN} -C {nlv4t.sym} 100 220 0 0 {name=m6 model=cmosn w=wn l=lln m=1 +C {lab_pin.sym} 650 -510 0 0 {name=l0 lab=VCCPIN} +C {nlv4t.sym} 600 -210 0 0 {name=m6 model=cmosn w=wn l=lln m=1 as="'0.270u*(wn)'" ad="'0.270u*(wn)'" ps="'2*0.270u+wn'" pd="'2*0.270u+wn'"} -C {lab_pin.sym} 140 300 0 1 {name=l2 lab=VSSPIN} -C {lab_pin.sym} 140 220 0 1 {name=l3 lab=VSSPIN} -C {lab_pin.sym} 140 140 0 1 {name=l4 lab=VSSPIN} +C {lab_pin.sym} 640 -130 0 1 {name=l2 lab=VSSPIN} +C {lab_pin.sym} 640 -210 0 1 {name=l3 lab=VSSPIN} +C {lab_pin.sym} 640 -290 0 1 {name=l4 lab=VSSPIN} +C {title.sym} 160 0 0 0 {name=l5 author="Stefan Schippers"} diff --git a/xschem_library/rom8k/lvnor2.sch b/xschem_library/rom8k/lvnor2.sch index 7a5cf490..4e5ed99a 100644 --- a/xschem_library/rom8k/lvnor2.sch +++ b/xschem_library/rom8k/lvnor2.sch @@ -1,43 +1,45 @@ -v {xschem version=2.9.5_RC6 file_version=1.1} +v {xschem version=2.9.9 file_version=1.2 } G {} +K {} V {assign #200 y =~(a|b);} S {} E {} -N 60 -30 100 -30 {lab=y} -N 40 -230 100 -230 {lab=VCCPIN} -N -130 30 -110 30 {lab=VSSBPIN} -N -20 -230 0 -230 {lab=a} -N 100 -260 100 -230 {lab=VCCPIN} -N -130 -30 -130 0 {lab=y} -N 60 30 80 30 {lab=VSSBPIN} -N 60 -30 60 0 {lab=y} -N 40 -110 100 -110 {lab=VCCPIN} -N 100 -140 100 -110 {lab=VCCPIN} -N 40 -80 40 -30 {lab=y} -N 40 -30 60 -30 {lab=y} -N -160 -260 100 -260 {lab=VCCPIN} -N -220 60 -130 60 {lab=VSSPIN} -N -130 -30 40 -30 {lab=y} -N -170 -110 -0 -110 {lab=b} -N -170 -110 -170 30 {lab=b} -N -20 30 20 30 {lab=a} -N -20 -230 -20 30 {lab=a} -N -200 -230 -20 -230 {lab=a} -N -200 -110 -170 -110 {lab=b} -N 40 -200 40 -140 {lab=#net1} -N 100 -230 100 -140 {lab=VCCPIN} -N -130 60 60 60 {lab=VSSPIN} -C {opin.sym} 100 -30 0 0 {name=p1 lab=y verilog_type=wire} -C {ipin.sym} -200 -230 0 0 {name=p2 lab=a} -C {plv4t.sym} 20 -230 0 0 {name=m2 model=cmosp w=wpa l=lpa m=1 +N 400 -190 440 -190 {lab=y} +N 380 -390 440 -390 {lab=VCCPIN} +N 210 -130 230 -130 {lab=VSSBPIN} +N 320 -390 340 -390 {lab=a} +N 440 -420 440 -390 {lab=VCCPIN} +N 210 -190 210 -160 {lab=y} +N 400 -130 420 -130 {lab=VSSBPIN} +N 400 -190 400 -160 {lab=y} +N 380 -270 440 -270 {lab=VCCPIN} +N 440 -300 440 -270 {lab=VCCPIN} +N 380 -240 380 -190 {lab=y} +N 380 -190 400 -190 {lab=y} +N 180 -420 440 -420 {lab=VCCPIN} +N 120 -100 210 -100 {lab=VSSPIN} +N 210 -190 380 -190 {lab=y} +N 170 -270 340 -270 {lab=b} +N 170 -270 170 -130 {lab=b} +N 320 -130 360 -130 {lab=a} +N 320 -390 320 -130 {lab=a} +N 140 -390 320 -390 {lab=a} +N 140 -270 170 -270 {lab=b} +N 380 -360 380 -300 {lab=#net1} +N 440 -390 440 -300 {lab=VCCPIN} +N 210 -100 400 -100 {lab=VSSPIN} +C {opin.sym} 440 -190 0 0 {name=p1 lab=y verilog_type=wire} +C {ipin.sym} 140 -390 0 0 {name=p2 lab=a} +C {plv4t.sym} 360 -390 0 0 {name=m2 model=cmosp w=wpa l=lpa m=1 } -C {plv4t.sym} 20 -110 0 0 {name=m1 model=cmosp w=wpb l=lpb m=1 +C {plv4t.sym} 360 -270 0 0 {name=m1 model=cmosp w=wpb l=lpb m=1 } -C {ipin.sym} -200 -110 0 0 {name=p3 lab=b} -C {lab_pin.sym} -160 -260 0 0 {name=l1 sig_type=std_logic lab=VCCPIN} -C {lab_pin.sym} -220 60 0 0 {name=l2 sig_type=std_logic lab=VSSPIN} -C {lab_pin.sym} 80 30 0 1 {name=l3 sig_type=std_logic lab=VSSPIN} -C {lab_pin.sym} -110 30 0 1 {name=l4 sig_type=std_logic lab=VSSPIN} -C {nlv4t.sym} 40 30 0 0 {name=m3 model=cmosn w=wna l=lna m=1} -C {nlv4t.sym} -150 30 0 0 {name=m4 model=cmosn w=wnb l=lnb m=1} -C {verilog_timescale.sym} 400 -37.5 0 0 {name=s1 timestep="1ps" precision="1ps" } +C {ipin.sym} 140 -270 0 0 {name=p3 lab=b} +C {lab_pin.sym} 180 -420 0 0 {name=l1 sig_type=std_logic lab=VCCPIN} +C {lab_pin.sym} 120 -100 0 0 {name=l2 sig_type=std_logic lab=VSSPIN} +C {lab_pin.sym} 420 -130 0 1 {name=l3 sig_type=std_logic lab=VSSPIN} +C {lab_pin.sym} 230 -130 0 1 {name=l4 sig_type=std_logic lab=VSSPIN} +C {nlv4t.sym} 380 -130 0 0 {name=m3 model=cmosn w=wna l=lna m=1} +C {nlv4t.sym} 190 -130 0 0 {name=m4 model=cmosn w=wnb l=lnb m=1} +C {verilog_timescale.sym} 740 -197.5 0 0 {name=s1 timestep="1ps" precision="1ps" } +C {title.sym} 160 0 0 0 {name=l5 author="Stefan Schippers"} diff --git a/xschem_library/rom8k/passhs.sch b/xschem_library/rom8k/passhs.sch index 5acf423a..bfdc4694 100644 --- a/xschem_library/rom8k/passhs.sch +++ b/xschem_library/rom8k/passhs.sch @@ -1,5 +1,6 @@ -v {xschem version=2.9.5_RC6 file_version=1.1} +v {xschem version=2.9.9 file_version=1.2 } G {} +K {} V {// these are the stimulus parameters // and are *NOT* the spec minimum/maximum values // spec minimum/maximum values for timing checks are @@ -1502,22 +1503,23 @@ end } S {} E {} -N 900 -540 900 -360 {lab=Z} -N 840 -540 840 -360 {lab=A} -N 870 -320 870 -300 {lab=E} -N 810 -300 870 -300 {lab=E} -N 810 -480 840 -480 {lab=A} -N 870 -600 870 -580 {lab=EN} -N 810 -600 870 -600 {lab=EN} -N 900 -480 930 -480 {lab=Z} -N 870 -540 870 -530 {lab=VDDPIN} -N 870 -370 870 -360 {lab=GNDPIN} -C {p.sym} 870 -560 3 1 {name=m60 model=cmosp w=WP l=2.4u m=1 +N 510 -350 510 -170 {lab=Z} +N 450 -350 450 -170 {lab=A} +N 480 -130 480 -110 {lab=E} +N 420 -110 480 -110 {lab=E} +N 420 -290 450 -290 {lab=A} +N 480 -410 480 -390 {lab=EN} +N 420 -410 480 -410 {lab=EN} +N 510 -290 540 -290 {lab=Z} +N 480 -350 480 -340 {lab=VDDPIN} +N 480 -180 480 -170 {lab=GNDPIN} +C {p.sym} 480 -370 3 1 {name=m60 model=cmosp w=WP l=2.4u m=1 } -C {n.sym} 870 -340 3 0 {name=m1 model=cmosn w=WN l=2.4u m=1} -C {iopin.sym} 930 -480 0 0 {name=p1 lab=Z} -C {iopin.sym} 810 -480 0 1 {name=p2 lab=A} -C {ipin.sym} 810 -600 0 0 {name=p3 lab=EN} -C {ipin.sym} 810 -300 0 0 {name=p4 lab=E} -C {lab_pin.sym} 870 -530 3 0 {name=l1 sig_type=std_logic lab=VCCPIN} -C {lab_pin.sym} 870 -370 3 1 {name=l2 sig_type=std_logic lab=VSSPIN} +C {n.sym} 480 -150 3 0 {name=m1 model=cmosn w=WN l=2.4u m=1} +C {iopin.sym} 540 -290 0 0 {name=p1 lab=Z} +C {iopin.sym} 420 -290 0 1 {name=p2 lab=A} +C {ipin.sym} 420 -410 0 0 {name=p3 lab=EN} +C {ipin.sym} 420 -110 0 0 {name=p4 lab=E} +C {lab_pin.sym} 480 -340 3 0 {name=l1 sig_type=std_logic lab=VCCPIN} +C {lab_pin.sym} 480 -180 3 1 {name=l2 sig_type=std_logic lab=VSSPIN} +C {title.sym} 160 0 0 0 {name=l3 author="Stefan Schippers"}