From 9fcde30a524324cc5d8381a663f7c6972a880080 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 14 May 2023 01:13:18 +0200 Subject: [PATCH] do not perform tcl substitution before displaying netlist_commands text into an editor. Correctly restore xctx->current_dirname after netlisting. get_generator_command(): quote command name (just in case its pathname contains spaces). floater example labels in solar_panel.sch. Various corrections and optimizations in new floater labels code. --- src/actions.c | 15 +- src/editprop.c | 2 +- src/in_memory_undo.c | 3 + src/move.c | 88 +++--- src/save.c | 3 + src/spice_netlist.c | 2 + src/tedax_netlist.c | 2 + src/token.c | 4 +- src/verilog_netlist.c | 2 + src/vhdl_netlist.c | 2 + xschem_library/examples/0_examples_top.sch | 2 +- xschem_library/ngspice/solar_panel.sch | 303 +++++++++++---------- 12 files changed, 233 insertions(+), 195 deletions(-) diff --git a/src/actions.c b/src/actions.c index 1651fca7..ff9748d2 100644 --- a/src/actions.c +++ b/src/actions.c @@ -92,7 +92,9 @@ int there_are_floaters(void) } /* mod=-1 used to force set title - * mod=-2 used to reset floaters cache */ + * mod=-2 used to reset floaters cache + * if floaters are present set_modify(1) (after a modify opration) must be done before draw() + * to invalidate cached floater string values before redrawing*/ void set_modify(int mod) { int i, floaters = 0; @@ -104,7 +106,7 @@ void set_modify(int mod) /* hash instance names if there are (many) floaters and many instances for faster lookup */ for(i = 0; i < xctx->texts; i++) if(xctx->text[i].flags & TEXT_FLOATER) { - floaters++; + floaters++; my_free(_ALLOC_ID_, &xctx->text[i].floater_ptr); /* clear floater cached value */ my_free(_ALLOC_ID_, &xctx->text[i].floater_instname); /* clear floater cached value */ } @@ -1855,15 +1857,8 @@ void calc_drawing_bbox(xRect *boundbox, int selected) updatebbox(count,boundbox,&rect); } if(has_x && selected != 2) { - int floaters = 0; - /* hash instance names if there are (many) floaters and many instances for faster lookup */ if(xctx->floater_inst_table.table == NULL) { - for(i = 0; i < xctx->texts; i++) { - if(xctx->text[i].flags & TEXT_FLOATER) { - floaters++; - } - } - if(floaters) { + if(there_are_floaters()) { floater_hash_all_names(); } } diff --git a/src/editprop.c b/src/editprop.c index 43f02e6b..d2700ac9 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -1477,7 +1477,7 @@ static int edit_symbol_property(int x) !strcmp( (xctx->inst[*ii].ptr+ xctx->sym)->type, "netlist_commands"); if(xctx->inst[*ii].prop_ptr!=NULL) { if(*netl_com && x==1) { - tclsetvar("retval",get_tok_value( xctx->inst[*ii].prop_ptr,"value",0)); + tclsetvar("retval",get_tok_value( xctx->inst[*ii].prop_ptr,"value",2)); } else { tclsetvar("retval",xctx->inst[*ii].prop_ptr); } diff --git a/src/in_memory_undo.c b/src/in_memory_undo.c index a8aa723f..1f625e90 100644 --- a/src/in_memory_undo.c +++ b/src/in_memory_undo.c @@ -552,4 +552,7 @@ void mem_pop_undo(int redo, int set_modify_status) xctx->prep_net_structs = 0; xctx->prep_hi_structs = 0; update_conn_cues(WIRELAYER, 0, 0); + if(there_are_floaters()) { + floater_hash_all_names(); + } } diff --git a/src/move.c b/src/move.c index dc819526..492bd5e0 100644 --- a/src/move.c +++ b/src/move.c @@ -946,9 +946,6 @@ void copy_objects(int what) } /* end for(k=0;klastsel; ++i) { n = xctx->sel_array[i].n; if(xctx->sel_array[i].type == ELEMENT) { @@ -1016,7 +1013,7 @@ void copy_objects(int what) xctx->ui_state &= ~STARTCOPY; xctx->x1 = xctx->y_1 = xctx->x2 = xctx->y_2 = xctx->deltax = xctx->deltay = 0; xctx->move_rot = xctx->move_flip = 0; - set_modify(1); + set_modify(1); /* must be done before draw() if floaters are present to force cached values update */ if(!floaters) bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); draw(); if(!floaters) bbox(END , 0.0 , 0.0 , 0.0 , 0.0); @@ -1088,8 +1085,9 @@ void move_objects(int what, int merge, double dx, double dy) if(what & END) /* move selected objects */ { int firsti, firstw; + int floaters = there_are_floaters(); - bbox(START, 0.0 , 0.0 , 0.0 , 0.0); + if(!floaters) bbox(START, 0.0 , 0.0 , 0.0 , 0.0); /* no undo push for MERGE ad PLACE, already done before */ if( !xctx->kissing && !(xctx->ui_state & (STARTMERGE | PLACE_SYMBOL | PLACE_TEXT)) ) { dbg(1, "move_objects(): push undo state\n"); @@ -1111,7 +1109,7 @@ void move_objects(int what, int merge, double dx, double dy) firsti = firstw = 1; draw_selection(xctx->gctiled,0); update_symbol_bboxes(0, 0); - find_inst_to_be_redrawn(0); /* build list before moving and recalculating prepare_netlist_structs() */ + if(!floaters) find_inst_to_be_redrawn(0); /* build list before moving and recalculating prepare_netlist_structs() */ for(k=0;klastsel; ++i) @@ -1129,13 +1127,13 @@ void move_objects(int what, int merge, double dx, double dy) ov = INT_BUS_WIDTH(xctx->lw)> cadhalfdotsize ? INT_BUS_WIDTH(xctx->lw) : CADHALFDOTSIZE; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } - bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); + if(!floaters) bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } else { double ov, y1, y2; ov = cadhalfdotsize; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } - bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); + if(!floaters) bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } if(xctx->rotatelocal) { @@ -1177,13 +1175,13 @@ void move_objects(int what, int merge, double dx, double dy) ov = INT_BUS_WIDTH(xctx->lw)> cadhalfdotsize ? INT_BUS_WIDTH(xctx->lw) : CADHALFDOTSIZE; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } - bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); + if(!floaters) bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } else { double ov, y1, y2; ov = cadhalfdotsize; if(wire[n].y1 < wire[n].y2) { y1 = wire[n].y1-ov; y2 = wire[n].y2+ov; } else { y1 = wire[n].y1+ov; y2 = wire[n].y2-ov; } - bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); + if(!floaters) bbox(ADD, wire[n].x1-ov, y1 , wire[n].x2+ov , y2 ); } } break; @@ -1196,14 +1194,14 @@ void move_objects(int what, int merge, double dx, double dy) if(xctx->line[c][n].y1 < xctx->line[c][n].y2) { y1 = xctx->line[c][n].y1-ov; y2 = xctx->line[c][n].y2+ov; } else { y1 = xctx->line[c][n].y1+ov; y2 = xctx->line[c][n].y2-ov; } - bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); + if(!floaters) bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); } else { double ov, y1, y2; ov = cadhalfdotsize; if(xctx->line[c][n].y1 < xctx->line[c][n].y2) { y1 = xctx->line[c][n].y1-ov; y2 = xctx->line[c][n].y2+ov; } else { y1 = xctx->line[c][n].y1+ov; y2 = xctx->line[c][n].y2-ov; } - bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); + if(!floaters) bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); } if(xctx->rotatelocal) { @@ -1247,14 +1245,14 @@ void move_objects(int what, int merge, double dx, double dy) if(xctx->line[c][n].y1 < xctx->line[c][n].y2) { y1 = xctx->line[c][n].y1-ov; y2 = xctx->line[c][n].y2+ov; } else { y1 = xctx->line[c][n].y1+ov; y2 = xctx->line[c][n].y2-ov; } - bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); + if(!floaters) bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); } else { double ov, y1, y2; ov = cadhalfdotsize; if(xctx->line[c][n].y1 < xctx->line[c][n].y2) { y1 = xctx->line[c][n].y1-ov; y2 = xctx->line[c][n].y2+ov; } else { y1 = xctx->line[c][n].y1+ov; y2 = xctx->line[c][n].y2-ov; } - bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); + if(!floaters) bbox(ADD, xctx->line[c][n].x1-ov, y1 , xctx->line[c][n].x2+ov , y2 ); } break; @@ -1287,7 +1285,7 @@ void move_objects(int what, int merge, double dx, double dy) } } - bbox(ADD, bx1, by1, bx2, by2); /* bbox before move */ + if(!floaters) bbox(ADD, bx1, by1, bx2, by2); /* bbox before move */ for(j=0; jpoints; ++j) { if(j==0 || p->x[j] < bx1) bx1 = p->x[j]; @@ -1295,21 +1293,23 @@ void move_objects(int what, int merge, double dx, double dy) if(j==0 || p->x[j] > bx2) bx2 = p->x[j]; if(j==0 || p->y[j] > by2) by2 = p->y[j]; } - bbox(ADD, bx1, by1, bx2, by2); /* bbox after move */ + if(!floaters) bbox(ADD, bx1, by1, bx2, by2); /* bbox after move */ } break; case ARC: if(c!=k) break; - if(xctx->arc[c][n].fill) /* bbox before move */ - arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, 0, 360, - &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); - else - arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, - xctx->arc[c][n].a, xctx->arc[c][n].b, - &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); - bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2); + if(!floaters) { + if(xctx->arc[c][n].fill) {/* bbox before move */ + arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, + 0, 360, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); + } else { + arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, + xctx->arc[c][n].a, xctx->arc[c][n].b, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); + } + bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2); + } if(xctx->rotatelocal) { /* rotate center wrt itself: do nothing */ @@ -1352,21 +1352,23 @@ void move_objects(int what, int merge, double dx, double dy) xctx->arc[c][n].b = angle; } - if(xctx->arc[c][n].fill) /* bbox after move */ - arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, 0, 360, - &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); - else - arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, - xctx->arc[c][n].a, xctx->arc[c][n].b, - &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); - bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2); + if(!floaters) { + if(xctx->arc[c][n].fill) {/* bbox after move */ + arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, + 0, 360, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); + } else { + arc_bbox(xctx->arc[c][n].x, xctx->arc[c][n].y, xctx->arc[c][n].r, + xctx->arc[c][n].a, xctx->arc[c][n].b, &tmp.x1, &tmp.y1, &tmp.x2, &tmp.y2); + } + bbox(ADD, tmp.x1, tmp.y1, tmp.x2, tmp.y2); + } break; case xRECT: if(c!=k) break; /* bbox before move */ - bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2); + if(!floaters) bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2); if(xctx->rotatelocal) { ROTATION(xctx->move_rot, xctx->move_flip, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rx1,xctx->ry1); @@ -1441,7 +1443,7 @@ void move_objects(int what, int merge, double dx, double dy) xctx->rect[c][n].y2 = xctx->ry2; /* bbox after move */ - bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2); + if(!floaters) bbox(ADD, xctx->rect[c][n].x1, xctx->rect[c][n].y1, xctx->rect[c][n].x2, xctx->rect[c][n].y2); break; case xTEXT: @@ -1458,7 +1460,7 @@ void move_objects(int what, int merge, double dx, double dy) cairo_restore(xctx->cairo_ctx); } #endif - bbox(ADD, xctx->rx1, xctx->ry1, xctx->rx2, xctx->ry2 ); + if(!floaters) bbox(ADD, xctx->rx1, xctx->ry1, xctx->rx2, xctx->ry2 ); if(xctx->rotatelocal) { ROTATION(xctx->move_rot, xctx->move_flip, xctx->text[n].x0, xctx->text[n].y0, xctx->text[n].x0, xctx->text[n].y0, xctx->rx1,xctx->ry1); @@ -1484,7 +1486,7 @@ void move_objects(int what, int merge, double dx, double dy) cairo_restore(xctx->cairo_ctx); } #endif - bbox(ADD, xctx->rx1, xctx->ry1, xctx->rx2, xctx->ry2 ); + if(!floaters) bbox(ADD, xctx->rx1, xctx->ry1, xctx->rx2, xctx->ry2 ); break; @@ -1511,6 +1513,10 @@ void move_objects(int what, int merge, double dx, double dy) xctx->inst[n].rot = (xctx->inst[n].rot + ( (xctx->move_flip && (xctx->inst[n].rot & 1) ) ? xctx->move_rot+2 : xctx->move_rot) ) & 0x3; xctx->inst[n].flip = xctx->move_flip ^ xctx->inst[n].flip; + /* this is needed since no find_inst_to_be_redrawn() is executed if floaters are present */ + if(floaters) symbol_bbox(n, + &xctx->inst[n].x1, &xctx->inst[n].y1, + &xctx->inst[n].x2, &xctx->inst[n].y2); } } if(!firsti || !firstw) { @@ -1518,8 +1524,8 @@ void move_objects(int what, int merge, double dx, double dy) xctx->prep_hi_structs=0; } /* build after copying and after recalculating prepare_netlist_structs() */ - find_inst_to_be_redrawn(1 + 2 + 4 + 32); /* 32: call prepare_netlist_structs(0) */ - find_inst_to_be_redrawn(16); /* clear data */ + if(!floaters) find_inst_to_be_redrawn(1 + 2 + 4 + 32); /* 32: call prepare_netlist_structs(0) */ + if(!floaters) find_inst_to_be_redrawn(16); /* clear data */ check_collapsing_objects(); if(tclgetboolvar("autotrim_wires")) trim_wires(); @@ -1532,11 +1538,11 @@ void move_objects(int what, int merge, double dx, double dy) xctx->ui_state &= ~STARTMERGE; xctx->move_rot=xctx->move_flip=0; xctx->x1=xctx->y_1=xctx->x2=xctx->y_2=xctx->deltax=xctx->deltay=0.; - bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); + set_modify(1); /* must be done before draw() if floaters are present to force cached values update */ + if(!floaters) bbox(SET , 0.0 , 0.0 , 0.0 , 0.0); draw(); - bbox(END , 0.0 , 0.0 , 0.0 , 0.0); + if(!floaters) bbox(END , 0.0 , 0.0 , 0.0 , 0.0); xctx->rotatelocal=0; - set_modify(1); } draw_selection(xctx->gc[SELLAYER], 0); } diff --git a/src/save.c b/src/save.c index 0c70f2ba..f4c3a786 100644 --- a/src/save.c +++ b/src/save.c @@ -2246,6 +2246,9 @@ static void read_xschem_file(FILE *fd) dbg(1, "read_xschem_file(): no file_version, assuming file_version=%s\n", xctx->file_version); } } + if(there_are_floaters()) { + floater_hash_all_names(); + } } void load_ascii_string(char **ptr, FILE *fd) diff --git a/src/spice_netlist.c b/src/spice_netlist.c index a7509c5e..55efe8f0 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -434,6 +434,8 @@ int global_spice_netlist(int global) /* netlister driver */ unselect_all(1); dbg(1, "global_spice_netlist(): invoking pop_undo(0, 0)\n"); xctx->pop_undo(4, 0); + tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL); + my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname)); my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name)); dbg(1, "spice_netlist(): invoke prepare_netlist_structs for %s\n", xctx->current_name); err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */ diff --git a/src/tedax_netlist.c b/src/tedax_netlist.c index 6896afb5..cc19af22 100644 --- a/src/tedax_netlist.c +++ b/src/tedax_netlist.c @@ -229,6 +229,8 @@ int global_tedax_netlist(int global) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + tclvareval("get_directory [list ", xctx->sch[xctx->currsch - 1], "]", NULL); + my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname)); my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name)); err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */ diff --git a/src/token.c b/src/token.c index 59ccc806..2bf7dd3b 100644 --- a/src/token.c +++ b/src/token.c @@ -242,7 +242,9 @@ char *get_generator_command(const char *str) goto end; } #ifdef __unix__ - my_strdup(_ALLOC_ID_, &gen_cmd, cmd_filename); + /* my_strdup(_ALLOC_ID_, &gen_cmd, cmd_filename); */ + /* add quotes to protect spaces in cmd path */ + my_mstrcat(_ALLOC_ID_, &gen_cmd, "\"", cmd_filename, "\"", NULL); *spc_idx = ' '; my_strcat(_ALLOC_ID_, &gen_cmd, spc_idx); #else diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c index 8a2f63f2..ba3949e6 100644 --- a/src/verilog_netlist.c +++ b/src/verilog_netlist.c @@ -372,6 +372,8 @@ int global_verilog_netlist(int global) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL); + my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname)); my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name)); err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */ /* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */ diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 95e60c04..f2bffaab 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -460,6 +460,8 @@ int global_vhdl_netlist(int global) /* netlister driver */ xctx->currsch--; unselect_all(1); xctx->pop_undo(4, 0); + tclvareval("get_directory [list ", xctx->sch[xctx->currsch], "]", NULL); + my_strncpy(xctx->current_dirname, tclresult(), S(xctx->current_dirname)); my_strncpy(xctx->current_name, rel_sym_path(xctx->sch[xctx->currsch]), S(xctx->current_name)); err |= prepare_netlist_structs(1); /* so 'lab=...' attributes for unnamed nets are set */ /* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */ diff --git a/xschem_library/examples/0_examples_top.sch b/xschem_library/examples/0_examples_top.sch index be0cd72b..48d0d6d1 100644 --- a/xschem_library/examples/0_examples_top.sch +++ b/xschem_library/examples/0_examples_top.sch @@ -1463,7 +1463,7 @@ C {rom8k.sym} 480 -730 0 0 {name=x17} C {test_doublepin.sym} 160 -170 0 0 {name=x19} C {classD_amp.sym} 480 -770 0 0 {name=x20} C {delta_sigma.sym} 480 -610 0 0 {name=x21} -C {solar_panel.sym} 480 -570 0 0 {name=x22} +C {solar_panel.sym} 480 -570 0 0 {name=xsolar} C {test_extracted_netlist.sym} 160 -130 0 0 {name=x23 tclcommand="xschem descend"} C {poweramp_lcc.sym} 480 -650 0 0 {name=x16 diff --git a/xschem_library/ngspice/solar_panel.sch b/xschem_library/ngspice/solar_panel.sch index 34967ed2..e282dc92 100644 --- a/xschem_library/ngspice/solar_panel.sch +++ b/xschem_library/ngspice/solar_panel.sch @@ -7,34 +7,34 @@ K {} V {} S {} E {} -L 2 125 -885 125 -655 {} -L 2 165 -885 165 -655 {} -L 2 205 -885 205 -655 {} -L 2 245 -885 245 -655 {} -L 2 285 -885 285 -655 {} -L 2 325 -885 325 -655 {} -L 2 365 -885 365 -655 {} -L 2 405 -885 405 -655 {} -L 2 85 -855 415 -855 {} -L 2 85 -815 415 -815 {} -L 2 85 -775 415 -775 {} -L 2 85 -735 415 -735 {} -L 2 85 -695 415 -695 {} -L 4 85 -895 85 -635 {} -L 4 75 -655 425 -655 {} -L 4 125 -655 125 -645 {} -L 4 165 -655 165 -645 {} -L 4 205 -655 205 -645 {} -L 4 245 -655 245 -645 {} -L 4 285 -655 285 -645 {} -L 4 325 -655 325 -645 {} -L 4 365 -655 365 -645 {} -L 4 405 -655 405 -645 {} -L 4 75 -695 85 -695 {} -L 4 75 -735 85 -735 {} -L 4 75 -775 85 -775 {} -L 4 75 -815 85 -815 {} -L 4 75 -855 85 -855 {} +L 2 105 -1005 105 -775 {} +L 2 145 -1005 145 -775 {} +L 2 185 -1005 185 -775 {} +L 2 225 -1005 225 -775 {} +L 2 265 -1005 265 -775 {} +L 2 305 -1005 305 -775 {} +L 2 345 -1005 345 -775 {} +L 2 385 -1005 385 -775 {} +L 2 65 -975 395 -975 {} +L 2 65 -935 395 -935 {} +L 2 65 -895 395 -895 {} +L 2 65 -855 395 -855 {} +L 2 65 -815 395 -815 {} +L 4 65 -1015 65 -755 {} +L 4 55 -775 405 -775 {} +L 4 105 -775 105 -765 {} +L 4 145 -775 145 -765 {} +L 4 185 -775 185 -765 {} +L 4 225 -775 225 -765 {} +L 4 265 -775 265 -765 {} +L 4 305 -775 305 -765 {} +L 4 345 -775 345 -765 {} +L 4 385 -775 385 -765 {} +L 4 55 -815 65 -815 {} +L 4 55 -855 65 -855 {} +L 4 55 -895 65 -895 {} +L 4 55 -935 65 -935 {} +L 4 55 -975 65 -975 {} L 4 610 -1100 630 -1140 {} L 4 630 -1140 650 -1100 {} L 4 650 -1100 670 -1140 {} @@ -54,11 +54,16 @@ L 4 1130 -1060 1130 -1020 {} L 4 1130 -1060 1150 -1060 {} L 4 1150 -1060 1150 -1020 {} L 4 1150 -1020 1160 -1020 {} -L 4 890 -690 890 -650 {} -L 4 880 -650 890 -650 {} -L 4 880 -650 890 -640 {} -L 4 890 -640 900 -650 {} -L 4 890 -650 900 -650 {} +L 4 880 -760 880 -720 {} +L 4 870 -720 880 -720 {} +L 4 870 -720 880 -710 {} +L 4 880 -710 890 -720 {} +L 4 880 -720 890 -720 {} +L 4 970 -380 970 -340 {} +L 4 960 -340 970 -340 {} +L 4 960 -340 970 -330 {} +L 4 970 -330 980 -340 {} +L 4 970 -340 980 -340 {} B 2 1260 -560 1680 -390 {flags=graph y1 = -0.42 y2 = 22 @@ -145,76 +150,85 @@ color=8 node="\\"CTRL1 Duty cycle; ctrl1 20u ravg()\\"" jpeg_quality=30 linewidth_mult=2.0} -B 18 85 -840 340 -655 {} -A 5 340 -840 5.590169943749475 243.434948822922 360 {fill=true} -P 7 6 415 -655 360 -811.25 355 -825 342.5 -840 330 -845 85 -855 {} +B 18 65 -960 320 -775 {} +A 5 320 -960 5.590169943749475 243.434948822922 360 {fill=true} +P 7 6 395 -775 340 -931.25 335 -945 322.5 -960 310 -965 65 -975 {} T {2x10 1W white LED} 1240 -200 0 0 0.4 0.4 {layer=8} T {2xseries 1W white LEDs} 1220 -140 0 0 0.4 0.4 {} -T {2.5} 115 -635 0 0 0.2 0.2 {} -T {5.0} 155 -635 0 0 0.2 0.2 {} -T {7.5} 195 -635 0 0 0.2 0.2 {} -T {10.0} 235 -635 0 0 0.2 0.2 {} -T {12.5} 275 -635 0 0 0.2 0.2 {} -T {15.0} 315 -635 0 0 0.2 0.2 {} -T {17.5} 355 -635 0 0 0.2 0.2 {} -T {20.0} 395 -635 0 0 0.2 0.2 {} -T {2.5} 55 -860 0 0 0.2 0.2 {} -T {2.0} 55 -820 0 0 0.2 0.2 {} -T {1.5} 55 -775 0 0 0.2 0.2 {} -T {1.0} 55 -740 0 0 0.2 0.2 {} -T {0.5} 55 -700 0 0 0.2 0.2 {} -T {25C, 1000W/m2} 210 -910 0 0 0.2 0.2 {} -T {V} 430 -645 0 0 0.4 0.4 {} -T {I} 60 -900 0 0 0.4 0.4 {} -T {SOLAR PANEL} 165 -935 0 0 0.4 0.4 {} -T {Maximum Power} 327.5 -860 0 0 0.2 0.2 {layer=8} +T {2.5} 95 -755 0 0 0.2 0.2 {} +T {5.0} 135 -755 0 0 0.2 0.2 {} +T {7.5} 175 -755 0 0 0.2 0.2 {} +T {10.0} 215 -755 0 0 0.2 0.2 {} +T {12.5} 255 -755 0 0 0.2 0.2 {} +T {15.0} 295 -755 0 0 0.2 0.2 {} +T {17.5} 335 -755 0 0 0.2 0.2 {} +T {20.0} 375 -755 0 0 0.2 0.2 {} +T {2.5} 35 -980 0 0 0.2 0.2 {} +T {2.0} 35 -940 0 0 0.2 0.2 {} +T {1.5} 35 -895 0 0 0.2 0.2 {} +T {1.0} 35 -860 0 0 0.2 0.2 {} +T {0.5} 35 -820 0 0 0.2 0.2 {} +T {25C, 1000W/m2} 190 -1030 0 0 0.2 0.2 {} +T {V} 410 -765 0 0 0.4 0.4 {} +T {I} 40 -1020 0 0 0.4 0.4 {} +T {SOLAR PANEL} 145 -1055 0 0 0.4 0.4 {} +T {Maximum Power} 307.5 -980 0 0 0.2 0.2 {layer=8} T {set between 0 and 1 to simulate sun radiation -level} 10 -390 0 0 0.2 0.2 {} -T {@name} 885 -628.75 0 0 0.2 0.2 {floater=L2 +level} 10 -440 0 0 0.2 0.2 {} +T {@name} 875 -698.75 0 0 0.3 0.3 {floater=L2 layer=7} -T {@value} 885 -613.75 0 0 0.2 0.2 {floater=L2 +T {@value} 875 -673.75 0 0 0.3 0.3 {floater=L2 layer=7} -T {m=@m} 885 -598.75 0 0 0.2 0.2 {floater=L2 +T {m=@m} 875 -648.75 0 0 0.3 0.3 {floater=L2 layer=7} -T {Floater text example} 860 -720 0 0 0.4 0.4 {} -N 1010 -160 1100 -160 {lab=0} -N 1100 -250 1100 -160 {lab=0} -N 640 -560 730 -560 {lab=#net1} -N 1010 -390 1040 -390 {lab=VO} -N 1010 -390 1010 -260 {lab=VO} -N 1010 -200 1010 -160 {lab=0} -N 530 -560 580 -560 {lab=PANEL} -N 1010 -560 1010 -390 {lab=VO} -N 820 -560 860 -560 {lab=SW} -N 820 -560 820 -440 {lab=SW} -N 790 -560 820 -560 {lab=SW} -N 820 -160 1010 -160 {lab=0} -N 630 -160 820 -160 {lab=0} -N 1000 -560 1010 -560 {lab=VO} -N 1100 -390 1140 -390 {lab=LED} -N 1100 -390 1100 -310 {lab=LED} -N 820 -380 820 -340 { lab=#net2} -N 920 -560 940 -560 { lab=#net3} -N 360 -480 360 -430 { +T {Floater text +example} 850 -820 0 0 0.4 0.4 {} +T {@name} 985 -308.75 0 1 0.3 0.3 {floater=C1 +layer=7} +T {@value} 985 -286.25 0 1 0.3 0.3 {floater=C1 +layer=7} +T {m=@m} 985 -263.75 0 1 0.3 0.3 {floater=C1 +layer=7} +T {Floater text +example} 870 -440 0 0 0.4 0.4 {} +N 1010 -210 1100 -210 {lab=0} +N 1100 -300 1100 -210 {lab=0} +N 640 -610 730 -610 {lab=#net1} +N 1010 -440 1040 -440 {lab=VO} +N 1010 -440 1010 -310 {lab=VO} +N 1010 -250 1010 -210 {lab=0} +N 530 -610 580 -610 {lab=PANEL} +N 1010 -610 1010 -440 {lab=VO} +N 820 -610 860 -610 {lab=SW} +N 820 -610 820 -490 {lab=SW} +N 790 -610 820 -610 {lab=SW} +N 820 -210 1010 -210 {lab=0} +N 800 -210 820 -210 {lab=0} +N 1000 -610 1010 -610 {lab=VO} +N 1100 -440 1140 -440 {lab=LED} +N 1100 -440 1100 -360 {lab=LED} +N 820 -430 820 -390 { lab=#net2} +N 920 -610 940 -610 { lab=#net3} +N 360 -530 360 -480 { lab=#net4} -N 360 -370 360 -320 {lab=0} -N 360 -480 400 -480 { +N 360 -420 360 -370 {lab=0} +N 360 -530 400 -530 { lab=#net4} -N 760 -670 760 -600 { +N 760 -720 760 -650 { lab=CTRL1} -N 460 -480 530 -480 { +N 460 -530 530 -530 { lab=#net5} -N 590 -480 650 -480 { +N 590 -530 650 -530 { lab=PANEL} -N 500 -340 500 -320 { +N 500 -390 500 -370 { lab=0} -N 500 -420 500 -400 { +N 500 -470 500 -450 { lab=#net6} -N 160 -400 320 -400 { +N 160 -450 320 -450 { lab=SUN} -N 160 -310 160 -290 { +N 160 -360 160 -340 { lab=0} N 610 -1010 610 -990 { lab=0} @@ -222,19 +236,19 @@ N 610 -1080 610 -1070 { lab=TRIANG} N 610 -1080 770 -1080 { lab=TRIANG} -N 720 -870 830 -870 { +N 720 -890 830 -890 { lab=LEVEL} -N 550 -840 550 -800 { +N 550 -860 550 -820 { lab=REF} -N 550 -840 600 -840 { +N 550 -860 600 -860 { lab=REF} -N 550 -900 600 -900 { +N 550 -920 600 -920 { lab=LED} N 1010 -1000 1060 -1000 { lab=CTRL1} -N 160 -400 160 -370 { +N 160 -450 160 -420 { lab=SUN} -N 830 -970 830 -870 { +N 830 -970 830 -890 { lab=LEVEL} N 830 -970 890 -970 { lab=LEVEL} @@ -242,39 +256,46 @@ N 770 -1080 770 -1030 { lab=TRIANG} N 770 -1030 890 -1030 { lab=TRIANG} -N 820 -280 820 -160 { +N 820 -330 820 -210 { lab=0} C {title.sym} 160 -40 0 0 {name=l1 author="Stefan Schippers" net_name=true} -C {code_shown.sym} 190 -250 0 0 {name=CONTROL value=".control -* save all -tran .05u 1m uic -write solar_panel.raw -exit +C {code_shown.sym} 170 -310 0 0 {name=CONTROL +value="tcleval( +.control + * example of tcl evaluation of code blocks: + * current path: $path + * schematic: [xschem get current_name] + tran .05u 1m uic + write solar_panel.raw + exit .endc -" net_name=true} -C {code.sym} 20 -190 0 0 {name=MODELS value=".MODEL DIODE D(IS=1.139e-08 RS=0.99 CJO=9.3e-12 VJ=1.6 M=0.411 BV=30 EG=0.7 ) +)" + +net_name=true} +C {code.sym} 20 -240 0 0 {name=MODELS value=".MODEL DIODE D(IS=1.139e-08 RS=0.99 CJO=9.3e-12 VJ=1.6 M=0.411 BV=30 EG=0.7 ) .MODEL swmod SW(VT=0.5 VH=0.01 RON=0.01 ROFF=10000000) " net_name=true} -C {lab_pin.sym} 650 -480 0 1 {name=l4 lab=PANEL } -C {lab_pin.sym} 630 -160 0 0 {name=l6 lab=0 } -C {ammeter.sym} 1070 -390 3 0 {name=Vled net_name=true} -C {ind.sym} 890 -560 3 1 {name=L2 +C {lab_pin.sym} 650 -530 0 1 {name=l4 lab=PANEL } +C {lab_pin.sym} 800 -210 0 0 {name=l6 lab=0 } +C {ammeter.sym} 1070 -440 3 0 {name=Vled net_name=true} +C {ind.sym} 890 -610 3 1 {name=L2 m=1 value=40u footprint=1206 device=inductor net_name=true hide_texts=true} -C {lab_pin.sym} 1140 -390 0 1 {name=l7 lab=LED } -C {lab_pin.sym} 820 -500 0 1 {name=l9 lab=SW } -C {capa.sym} 1010 -230 0 0 {name=C1 +C {lab_pin.sym} 1140 -440 0 1 {name=l7 lab=LED } +C {lab_pin.sym} 820 -550 0 1 {name=l9 lab=SW } +C {capa.sym} 1010 -280 0 0 {name=C1 m=1 value=500n footprint=1206 -device="ceramic capacitor" net_name=true} -C {lab_pin.sym} 1010 -350 0 1 {name=l10 lab=VO } -C {lab_pin.sym} 530 -560 0 0 {name=l3 lab=PANEL } -C {ammeter.sym} 970 -560 3 0 {name=Vind net_name=true} -C {isource_table.sym} 1100 -280 0 0 {name=G2[9..0] CTRL="V(LED)" TABLE=" +device="ceramic capacitor" net_name=true +hide_texts=true} +C {lab_pin.sym} 1010 -400 0 1 {name=l10 lab=VO } +C {lab_pin.sym} 530 -610 0 0 {name=l3 lab=PANEL } +C {ammeter.sym} 970 -610 3 0 {name=Vind net_name=true} +C {isource_table.sym} 1100 -330 0 0 {name=G2[9..0] CTRL="V(LED)" TABLE=" + (0, 0) + (4.8, 5m) + (5.2, 15m) @@ -290,34 +311,34 @@ C {isource_table.sym} 1100 -280 0 0 {name=G2[9..0] CTRL="V(LED)" TABLE=" + (7.4, 470m) + (8.0, 750m)" net_name=true} -C {ammeter.sym} 610 -560 3 0 {name=Vsw net_name=true} -C {ammeter.sym} 820 -310 2 0 {name=Vdiode net_name=true} -C {spice_probe.sym} 1120 -390 0 0 {name=p1 analysis=tran} -C {spice_probe.sym} 650 -480 0 0 {name=p2 analysis=tran} -C {spice_probe.sym} 820 -460 0 1 {name=p3 analysis=tran} +C {ammeter.sym} 610 -610 3 0 {name=Vsw net_name=true} +C {ammeter.sym} 820 -360 2 0 {name=Vdiode net_name=true} +C {spice_probe.sym} 1120 -440 0 0 {name=p1 analysis=tran} +C {spice_probe.sym} 650 -530 0 0 {name=p2 analysis=tran} +C {spice_probe.sym} 820 -510 0 1 {name=p3 analysis=tran} C {launcher.sym} 1080 -1140 0 0 {name=h3 descr="Reload Waves" tclcommand=" xschem raw_read $netlist_dir/[file tail [file rootname [xschem get current_name]]].raw tran " } -C {pv_ngspice.sym} 360 -400 0 0 {name=X1 m=1 power=100 n=36} -C {lab_pin.sym} 360 -320 0 0 {name=l12 lab=0 } -C {capa.sym} 500 -450 0 0 {name=C11 +C {pv_ngspice.sym} 360 -450 0 0 {name=X1 m=1 power=100 n=36} +C {lab_pin.sym} 360 -370 0 0 {name=l12 lab=0 } +C {capa.sym} 500 -500 0 0 {name=C11 m=1 value=10u footprint=1206 device="ceramic capacitor" net_name=true} -C {lab_pin.sym} 500 -320 0 0 {name=l90 lab=0 } -C {ammeter.sym} 430 -480 3 1 {name=Vpanel net_name=true} -C {diode_ngspice.sym} 820 -410 2 0 {name=X2 m=1 Roff=1e9 Ron=0.1} -C {switch_ngspice.sym} 760 -560 1 0 {name=S1 model=swmod} -C {lab_pin.sym} 740 -600 0 0 {name=l5 lab=0 } -C {ammeter.sym} 560 -480 3 1 {name=Vpanel1 net_name=true} -C {ammeter.sym} 500 -370 0 0 {name=Vcap net_name=true} -C {vsource.sym} 160 -340 0 0 {name=Vfade value="pwl 0 1 1m 0"} -C {lab_pin.sym} 160 -290 0 0 {name=l8 lab=0 } -C {ngspice_get_expr.sym} 1120 -320 0 0 {name=r29 +C {lab_pin.sym} 500 -370 0 0 {name=l90 lab=0 } +C {ammeter.sym} 430 -530 3 1 {name=Vpanel net_name=true} +C {diode_ngspice.sym} 820 -460 2 0 {name=X2 m=1 Roff=1e9 Ron=0.1} +C {switch_ngspice.sym} 760 -610 1 0 {name=S1 model=swmod} +C {lab_pin.sym} 740 -650 0 0 {name=l5 lab=0 } +C {ammeter.sym} 560 -530 3 1 {name=Vpanel1 net_name=true} +C {ammeter.sym} 500 -420 0 0 {name=Vcap net_name=true} +C {vsource.sym} 160 -390 0 0 {name=Vfade value="pwl 0 1 1m 0"} +C {lab_pin.sym} 160 -340 0 0 {name=l8 lab=0 } +C {ngspice_get_expr.sym} 1120 -370 0 0 {name=r29 node="[format %.4g [expr \{[ngspice::get_voltage led] * [ngspice::get_current vled]\}]] W" descr = power } @@ -325,17 +346,17 @@ C {vsource.sym} 610 -1040 0 0 {name=Vtriang value="pulse 0 1 0 2u 2u 1f 4u"} C {lab_pin.sym} 610 -990 0 0 {name=l11 lab=0 } C {lab_pin.sym} 770 -1080 0 1 {name=l14 lab=TRIANG } -C {vsource.sym} 550 -770 0 0 {name=Vref value=7} -C {lab_pin.sym} 550 -740 0 0 {name=l17 lab=0 } -C {lab_pin.sym} 760 -670 0 0 {name=l13 lab=CTRL1 } -C {comp_ngspice.sym} 660 -870 0 0 {name=x3 OFFSET=0.5 AMPLITUDE=1 ROUT=7k COUT=1n} -C {lab_pin.sym} 550 -840 0 0 {name=l16 +C {vsource.sym} 550 -790 0 0 {name=Vref value=7} +C {lab_pin.sym} 550 -760 0 0 {name=l17 lab=0 } +C {lab_pin.sym} 760 -720 0 0 {name=l13 lab=CTRL1 } +C {comp_ngspice.sym} 660 -890 0 0 {name=x3 OFFSET=0.5 AMPLITUDE=1 ROUT=7k COUT=1n} +C {lab_pin.sym} 550 -860 0 0 {name=l16 lab=REF} -C {lab_pin.sym} 550 -900 0 0 {name=l15 lab=LED} -C {lab_pin.sym} 830 -870 0 1 {name=l18 lab=LEVEL} +C {lab_pin.sym} 550 -920 0 0 {name=l15 lab=LED} +C {lab_pin.sym} 830 -890 0 1 {name=l18 lab=LEVEL} C {comp_ngspice.sym} 950 -1000 0 0 {name=x4 OFFSET=0.5 AMPLITUDE=1 ROUT=1 COUT=1p} C {lab_pin.sym} 1060 -1000 0 1 {name=l19 lab=CTRL1 } -C {lab_pin.sym} 160 -400 0 0 {name=l20 lab=SUN } +C {lab_pin.sym} 160 -450 0 0 {name=l20 lab=SUN } C {spice_probe.sym} 850 -1030 0 1 {name=p4 analysis=tran} -C {spice_probe.sym} 810 -870 0 1 {name=p5 analysis=tran} -C {spice_probe.sym} 760 -620 0 0 {name=p6 analysis=tran} +C {spice_probe.sym} 810 -890 0 1 {name=p5 analysis=tran} +C {spice_probe.sym} 760 -670 0 0 {name=p6 analysis=tran}