eliminated any differences between SYMBOL and SCHEMATIC files. There is no "current_type" variable any more. Symbols who used to have netlisting rules defined in schvhdlprop have now these attributes in schsymbolprop. Old symbol files with schvhdlprop will be saved with netlisting rules in schsymbolprop.
This commit is contained in:
parent
4a332ade11
commit
f3bedb39a4
|
|
@ -161,7 +161,7 @@ p{padding: 15px 30px 10px;}
|
|||
<li><kbd>devices/attributes.sym</kbd></li>
|
||||
<li><kbd>devices/port_attributes.sym</kbd></li>
|
||||
<li><kbd>devices/generic_pin.sym</kbd></li>
|
||||
<li><kbd>devices/generic.sym</kbd></li>
|
||||
<li><kbd>devices/lab_generic.sym</kbd></li>
|
||||
</ul><br>
|
||||
<!-- end of slide -->
|
||||
<div class="filler"></div>
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ p{padding: 15px 30px 10px;}
|
|||
have a property string attached. Any text can be present in a property string, however
|
||||
in most cases the property string is organized as a set of <kbd>key=value</kbd> pairs separated by white space.
|
||||
In addition to object properties the schematic or symbol view has global properties attached.
|
||||
There is one global property defined per netlisting mode (currently SPICE, VHDL, Verilog, tEDAx).
|
||||
There is one global property defined per netlisting mode (currently SPICE, VHDL, Verilog, tEDAx) and one additional global property
|
||||
for symbols (containing the netlisting rules usually).
|
||||
See the <a href="xschem_properties.html">XSCHEM properties</a> section of the manual for more info.
|
||||
</p>
|
||||
<h3>COORDINATE SYSTEM</h3>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ p{padding: 15px 30px 10px;}
|
|||
<h3>GENERAL RULES</h3>
|
||||
<p>
|
||||
For symbols a global property string (to show it press <kbd>'q'</kbd> when nothing
|
||||
is selected). defines at least 3 attributes:
|
||||
is selected and <kbd>Options->Symbol global attrs</kbd> is selected) defines at least 3 attributes:
|
||||
</p>
|
||||
<ul>
|
||||
<li><kbd>type</kbd> defines the the type of symbol. Normally the type attribute describes the symbol
|
||||
|
|
@ -110,9 +110,20 @@ type=nmos
|
|||
need to escape the '$' in property strings a different and less used character was chosen.<br>
|
||||
A literal <kbd>@</kbd> must be escaped to prevent it to be interpreted as the start of a token to be
|
||||
substituted (<kbd>\@</kbd>). If a non space character (different than <kbd>@</kbd>) ends a token it must be escaped.
|
||||
Attribute substitution takes place in symbol format attribute and in every text, as shown in below picture.
|
||||
Attribute substitution with values defined in instance attributes takes place in symbol
|
||||
format attribute and in every text, as shown in below picture.
|
||||
</p>
|
||||
<br>
|
||||
<p class="important">
|
||||
In recent xschem versions a <kbd>$</kbd> prefixed attribute (example: <kbd>$var</kbd>) can be used
|
||||
instead of a <lbd>@</kbd> prefix. The only difference is that if no matching attribute is defined
|
||||
in instance the <kbd>$var</kbd> resolves to <kbd>var</kbd> instead of an empty string.
|
||||
</p>
|
||||
<img src="attribute_substitution.png">
|
||||
<p>
|
||||
If no matching attribute is defined in instance (for example we have <kbd>@W</kbd> in symbol and no <kbd>W=...</kbd> in instance)
|
||||
the <kbd>@W</kbd> string is substituted with an empty string.
|
||||
</p>
|
||||
<h3>OTHER PREDEFINED SYMBOL ATTRIBUTES</h3>
|
||||
<ul>
|
||||
<li><kbd>vhdl_ignore</kbd></li>
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ p{padding: 15px 30px 10px;}
|
|||
schematic (.sch) or symbol window (.sym).
|
||||
<p class="important">
|
||||
There is actually one different global property
|
||||
string defined for any available netlisting modes, so if XSCHEM is set to produce SPICE
|
||||
netlists the SPICE global property string is displayed.
|
||||
string defined for any available netlisting modes plus one global property string for symbol definition (file format 1.2),
|
||||
so if XSCHEM is set to produce SPICE netlists the SPICE global property string is displayed.
|
||||
</p>
|
||||
<p>
|
||||
So, in addition to properties associated to graphical objects and
|
||||
|
|
@ -82,7 +82,7 @@ p{padding: 15px 30px 10px;}
|
|||
</p>
|
||||
<img src="global_property.png">
|
||||
<p>
|
||||
The <kbd>format</kbd> attribute defines the format of the SPICE netlist.
|
||||
In the above 'Symbol' global property string, the <kbd>format</kbd> attribute defines the format of the SPICE netlist.
|
||||
The SPICE netlist element line starts with the
|
||||
symbol name (in this case a resistor so 'rxxxxx'), the list of pins, the
|
||||
resistor value and a multiplicity factor (m).<br>
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ void deps_default_init(void)
|
|||
dep_add("libs/fs/makedev/*", find_fs_makedev);
|
||||
|
||||
dep_add("libs/io/pipe/*", find_io_pipe);
|
||||
dep_add("libs/io/_pipe/*", find_io__pipe);
|
||||
dep_add("libs/io/dup2/*", find_io_dup2);
|
||||
dep_add("libs/io/fileno/*", find_io_fileno);
|
||||
dep_add("libs/io/lseek/*", find_io_lseek);
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ int find_shell(const char *name, int logdepth, int fatal);
|
|||
|
||||
/* find_io.c */
|
||||
int find_io_pipe(const char *name, int logdepth, int fatal);
|
||||
int find_io__pipe(const char *name, int logdepth, int fatal);
|
||||
int find_io_dup2(const char *name, int logdepth, int fatal);
|
||||
int find_io_fileno(const char *name, int logdepth, int fatal);
|
||||
int find_io_lseek(const char *name, int logdepth, int fatal);
|
||||
|
|
|
|||
|
|
@ -48,11 +48,31 @@ int find_io_pipe(const char *name, int logdepth, int fatal)
|
|||
logprintf(logdepth, "find_io_pipe: trying to find pipe(2)...\n");
|
||||
logdepth++;
|
||||
|
||||
|
||||
if (try_icl(logdepth, "libs/io/pipe", test_c, NULL, NULL, NULL)) return 0;
|
||||
if (try_icl(logdepth, "libs/io/pipe", test_c, "#include <unistd.h>\n", NULL, NULL)) return 0;
|
||||
return try_fail(logdepth, "libs/io/pipe");
|
||||
}
|
||||
|
||||
int find_io__pipe(const char *name, int logdepth, int fatal)
|
||||
{
|
||||
const char *test_c =
|
||||
NL "int main() {"
|
||||
NL " int fd[2];"
|
||||
NL " if (_pipe(fd, 1024, _O_BINARY) == 0)"
|
||||
NL " puts(\"OK\");"
|
||||
NL " return 0;"
|
||||
NL "}"
|
||||
NL;
|
||||
|
||||
require("cc/cc", logdepth, fatal);
|
||||
|
||||
report("Checking for _pipe()... ");
|
||||
logprintf(logdepth, "find_io__pipe: trying to find _pipe()...\n");
|
||||
logdepth++;
|
||||
|
||||
if (try_icl(logdepth, "libs/io/_pipe", test_c, "#include <io.h>\n#include <fcntl.h>\n", NULL, NULL)) return 0;
|
||||
return try_fail(logdepth, "libs/io/_pipe");
|
||||
}
|
||||
|
||||
int find_io_dup2(const char *name, int logdepth, int fatal)
|
||||
{
|
||||
char *test_c =
|
||||
|
|
|
|||
|
|
@ -469,13 +469,13 @@ void saveas(const char *f, int type) /* changed name from ask_save_file to save
|
|||
char *p;
|
||||
if(!f && has_x) {
|
||||
my_strncpy(filename , abs_sym_path(schematic[currentsch], ""), S(filename));
|
||||
if(type == SCHEMATIC) {
|
||||
my_snprintf(name, S(name), "save_file_dialog {Save file} .sch.sym INITIALLOADDIR {%s}", filename);
|
||||
} else {
|
||||
if(type == SYMBOL) {
|
||||
if( (p = strrchr(filename, '.')) && !strcmp(p, ".sch") ) {
|
||||
my_strncpy(filename, add_ext(filename, ".sym"), S(filename));
|
||||
}
|
||||
my_snprintf(name, S(name), "save_file_dialog {Save file} .sym.sch INITIALLOADDIR {%s}", filename);
|
||||
} else {
|
||||
my_snprintf(name, S(name), "save_file_dialog {Save file} .sch.sym INITIALLOADDIR {%s}", filename);
|
||||
}
|
||||
|
||||
tcleval(name);
|
||||
|
|
@ -487,7 +487,6 @@ void saveas(const char *f, int type) /* changed name from ask_save_file to save
|
|||
else res[0]='\0';
|
||||
|
||||
if(!res[0]) return; /* 20071104 */
|
||||
current_type = type;
|
||||
dbg(1, "saveas(): res = %s\n", res);
|
||||
save_schematic(res);
|
||||
Tcl_VarEval(interp, "update_recent_file {", res,"}", NULL);
|
||||
|
|
@ -891,7 +890,6 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, int rot,
|
|||
static char name[PATH_MAX];
|
||||
char *type;
|
||||
int cond;
|
||||
if(current_type==SYMBOL) return 0; /* 20161210 dont allow components placed inside symbols */
|
||||
if(symbol_name==NULL) {
|
||||
tcleval("load_file_dialog {Choose symbol} .sym INITIALINSTDIR");
|
||||
my_strncpy(name, tclresult(), S(name));
|
||||
|
|
@ -1071,7 +1069,6 @@ void descend_schematic(void)
|
|||
int inst_mult, inst_number;
|
||||
int save_ok = 0;
|
||||
|
||||
if(!(current_type==SCHEMATIC)) return; /*20180928 */
|
||||
|
||||
rebuild_selected_array();
|
||||
if(lastselected !=1 || selectedgroup[0].type!=ELEMENT)
|
||||
|
|
@ -1186,7 +1183,6 @@ void descend_schematic(void)
|
|||
|
||||
void go_back(int confirm) /* 20171006 add confirm */
|
||||
{
|
||||
int prev_curr_type=0;
|
||||
int save_ok; /* 20171020 */
|
||||
int from_embedded_sym;
|
||||
int save_modified;
|
||||
|
|
@ -1195,7 +1191,6 @@ void go_back(int confirm) /* 20171006 add confirm */
|
|||
save_ok=0;
|
||||
if(currentsch>0)
|
||||
{
|
||||
prev_curr_type=current_type; /* 20190521 */
|
||||
/* if current sym/schematic is changed ask save before going up */
|
||||
if(modified)
|
||||
{
|
||||
|
|
@ -1227,9 +1222,7 @@ void go_back(int confirm) /* 20171006 add confirm */
|
|||
load_schematic(1, filename, 1);
|
||||
if(from_embedded_sym) modified=save_modified; /* to force ask save embedded sym in parent schematic */
|
||||
|
||||
if(prev_curr_type==SCHEMATIC) {
|
||||
hilight_parent_pins();
|
||||
}
|
||||
hilight_parent_pins();
|
||||
if(enable_drill) drill_hilight(); /* 20171212 */
|
||||
xorigin=zoom_array[currentsch].x;
|
||||
yorigin=zoom_array[currentsch].y;
|
||||
|
|
@ -1239,7 +1232,6 @@ void go_back(int confirm) /* 20171006 add confirm */
|
|||
change_linewidth(-1.);
|
||||
draw();
|
||||
|
||||
current_type=SCHEMATIC;
|
||||
dbg(1, "go_back(): current path: %s\n", sch_path[currentsch]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
{
|
||||
if(semaphore >= 2) break;
|
||||
if(!strcmp(schematic[currentsch],"") || strstr(schematic[currentsch], "untitled")) { /* check if unnamed schematic, use saveas in this case */
|
||||
saveas(NULL, current_type);
|
||||
saveas(NULL, SCHEMATIC);
|
||||
} else {
|
||||
save(1);
|
||||
}
|
||||
|
|
@ -725,7 +725,7 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
if(key=='S' && state == (ShiftMask | ControlMask)) /* save as schematic */
|
||||
{
|
||||
if(semaphore >= 2) break;
|
||||
saveas(NULL, current_type);
|
||||
saveas(NULL, SCHEMATIC);
|
||||
break;
|
||||
}
|
||||
if(key=='e' && state == 0) /* descend to schematic */
|
||||
|
|
@ -752,13 +752,11 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
if(key=='a' && state == 0) /* make symbol */
|
||||
{
|
||||
if(semaphore >= 2) break; /* 20180914 */
|
||||
if(current_type==SCHEMATIC) {
|
||||
tcleval("tk_messageBox -type okcancel -message {do you want to make symbol view ?}");
|
||||
if(strcmp(tclresult(),"ok")==0)
|
||||
{
|
||||
save_schematic(schematic[currentsch]);
|
||||
make_symbol();
|
||||
}
|
||||
tcleval("tk_messageBox -type okcancel -message {do you want to make symbol view ?}");
|
||||
if(strcmp(tclresult(),"ok")==0)
|
||||
{
|
||||
save_schematic(schematic[currentsch]);
|
||||
make_symbol();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
106
src/editprop.c
106
src/editprop.c
|
|
@ -769,47 +769,44 @@ void edit_text_property(int x)
|
|||
tclgetvar("props"),
|
||||
tclgetvar("retval") );
|
||||
if(text_changed) {
|
||||
if(current_type==SYMBOL) {
|
||||
c = lastrect[PINLAYER];
|
||||
for(l=0;l<c;l++) {
|
||||
if(!strcmp( (get_tok_value(rect[PINLAYER][l].prop_ptr, "name",0)),
|
||||
textelement[sel].txt_ptr) ) {
|
||||
#ifdef HAS_CAIRO
|
||||
customfont = set_text_custom_font(&textelement[sel]);
|
||||
#endif
|
||||
text_bbox(textelement[sel].txt_ptr, textelement[sel].xscale,
|
||||
textelement[sel].yscale, rot, flip, textelement[sel].hcenter, textelement[sel].vcenter,
|
||||
textelement[sel].x0, textelement[sel].y0,
|
||||
&xx1,&yy1,&xx2,&yy2);
|
||||
#ifdef HAS_CAIRO
|
||||
if(customfont) cairo_restore(ctx);
|
||||
#endif
|
||||
c = lastrect[PINLAYER];
|
||||
for(l=0;l<c;l++) {
|
||||
if(!strcmp( (get_tok_value(rect[PINLAYER][l].prop_ptr, "name",0)),
|
||||
textelement[sel].txt_ptr) ) {
|
||||
#ifdef HAS_CAIRO
|
||||
customfont = set_text_custom_font(&textelement[sel]);
|
||||
#endif
|
||||
text_bbox(textelement[sel].txt_ptr, textelement[sel].xscale,
|
||||
textelement[sel].yscale, rot, flip, textelement[sel].hcenter, textelement[sel].vcenter,
|
||||
textelement[sel].x0, textelement[sel].y0,
|
||||
&xx1,&yy1,&xx2,&yy2);
|
||||
#ifdef HAS_CAIRO
|
||||
if(customfont) cairo_restore(ctx);
|
||||
#endif
|
||||
|
||||
pcx = (rect[PINLAYER][l].x1+rect[PINLAYER][l].x2)/2.0;
|
||||
pcy = (rect[PINLAYER][l].y1+rect[PINLAYER][l].y2)/2.0;
|
||||
pcx = (rect[PINLAYER][l].x1+rect[PINLAYER][l].x2)/2.0;
|
||||
pcy = (rect[PINLAYER][l].y1+rect[PINLAYER][l].y2)/2.0;
|
||||
|
||||
if(
|
||||
/* 20171206 20171221 */
|
||||
(fabs( (yy1+yy2)/2 - pcy) < cadgrid/2 &&
|
||||
(fabs(xx1 - pcx) < cadgrid*3 || fabs(xx2 - pcx) < cadgrid*3) )
|
||||
||
|
||||
(fabs( (xx1+xx2)/2 - pcx) < cadgrid/2 &&
|
||||
(fabs(yy1 - pcy) < cadgrid*3 || fabs(yy2 - pcy) < cadgrid*3) )
|
||||
) {
|
||||
if(x==0) /* 20080804 */
|
||||
my_strdup(71, &rect[PINLAYER][l].prop_ptr,
|
||||
subst_token(rect[PINLAYER][l].prop_ptr, "name",
|
||||
(char *) tclgetvar("retval")) );
|
||||
else
|
||||
my_strdup(72, &rect[PINLAYER][l].prop_ptr,
|
||||
subst_token(rect[PINLAYER][l].prop_ptr, "name",
|
||||
(char *) tclgetvar("retval")) );
|
||||
}
|
||||
if(
|
||||
/* 20171206 20171221 */
|
||||
(fabs( (yy1+yy2)/2 - pcy) < cadgrid/2 &&
|
||||
(fabs(xx1 - pcx) < cadgrid*3 || fabs(xx2 - pcx) < cadgrid*3) )
|
||||
||
|
||||
(fabs( (xx1+xx2)/2 - pcx) < cadgrid/2 &&
|
||||
(fabs(yy1 - pcy) < cadgrid*3 || fabs(yy2 - pcy) < cadgrid*3) )
|
||||
) {
|
||||
if(x==0) /* 20080804 */
|
||||
my_strdup(71, &rect[PINLAYER][l].prop_ptr,
|
||||
subst_token(rect[PINLAYER][l].prop_ptr, "name",
|
||||
(char *) tclgetvar("retval")) );
|
||||
else
|
||||
my_strdup(72, &rect[PINLAYER][l].prop_ptr,
|
||||
subst_token(rect[PINLAYER][l].prop_ptr, "name",
|
||||
(char *) tclgetvar("retval")) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my_strdup(74, &textelement[sel].txt_ptr, (char *) tclgetvar("retval"));
|
||||
|
||||
}
|
||||
if(x==0) {
|
||||
if(preserve)
|
||||
|
|
@ -1153,37 +1150,36 @@ void edit_property(int x)
|
|||
char *old_prop = NULL;
|
||||
char *new_prop = NULL;
|
||||
|
||||
if(netlist_type==CAD_SYMBOL_ATTRS && current_type==SCHEMATIC) {
|
||||
if(netlist_type==CAD_SYMBOL_ATTRS) {
|
||||
if(schsymbolprop!=NULL) /*09112003 */
|
||||
tclsetvar("retval",schsymbolprop);
|
||||
else
|
||||
tclsetvar("retval","");
|
||||
}
|
||||
else if(netlist_type==CAD_VERILOG_NETLIST && current_type==SCHEMATIC) {
|
||||
else if(netlist_type==CAD_VHDL_NETLIST) {
|
||||
if(schvhdlprop!=NULL) /*09112003 */
|
||||
tclsetvar("retval",schvhdlprop);
|
||||
else
|
||||
tclsetvar("retval","");
|
||||
}
|
||||
else if(netlist_type==CAD_VERILOG_NETLIST) {
|
||||
if(schverilogprop!=NULL) /*09112003 */
|
||||
tclsetvar("retval",schverilogprop);
|
||||
else
|
||||
tclsetvar("retval","");
|
||||
}
|
||||
else if(netlist_type==CAD_SPICE_NETLIST && current_type==SCHEMATIC) { /* 20100217 */
|
||||
else if(netlist_type==CAD_SPICE_NETLIST) { /* 20100217 */
|
||||
if(schprop!=NULL)
|
||||
tclsetvar("retval",schprop);
|
||||
else
|
||||
tclsetvar("retval","");
|
||||
}
|
||||
else if(netlist_type==CAD_TEDAX_NETLIST && current_type==SCHEMATIC) { /* 20100217 */
|
||||
else if(netlist_type==CAD_TEDAX_NETLIST) { /* 20100217 */
|
||||
if(schtedaxprop!=NULL)
|
||||
tclsetvar("retval",schtedaxprop);
|
||||
else
|
||||
tclsetvar("retval","");
|
||||
}
|
||||
else { /* this is used for symbol global props also */
|
||||
if(schvhdlprop!=NULL)
|
||||
tclsetvar("retval",schvhdlprop);
|
||||
else
|
||||
tclsetvar("retval","");
|
||||
}
|
||||
|
||||
my_strdup(660, &old_prop, tclgetvar("retval"));
|
||||
|
||||
if(x==0) tcleval("text_line {Global schematic property:} 0");
|
||||
|
|
@ -1203,31 +1199,27 @@ void edit_property(int x)
|
|||
|
||||
if(strcmp(tclgetvar("rcode"),"") )
|
||||
{
|
||||
if(current_type==SYMBOL && /* 20120404 added case for symbol editing, use schvhdlprop regardless of netlisting mode */
|
||||
(!schvhdlprop || strcmp(schvhdlprop, tclgetvar("retval") ) ) ) { /* symbol edit */
|
||||
set_modify(1); push_undo(); /* 20150327 */
|
||||
my_strdup(93, &schvhdlprop, (char *) tclgetvar("retval"));
|
||||
} else if(netlist_type==CAD_VERILOG_NETLIST && current_type==SCHEMATIC && /* 20120228 check if schverilogprop NULL */
|
||||
if(netlist_type==CAD_VERILOG_NETLIST && /* 20120228 check if schverilogprop NULL */
|
||||
(!schverilogprop || strcmp(schverilogprop, tclgetvar("retval") ) ) ) { /* 20120209 */
|
||||
set_modify(1); push_undo(); /* 20150327 */
|
||||
my_strdup(94, &schverilogprop, (char *) tclgetvar("retval")); /*09112003 */
|
||||
|
||||
} else if(netlist_type==CAD_SPICE_NETLIST && current_type==SCHEMATIC && /* 20120228 check if schprop NULL */
|
||||
} else if(netlist_type==CAD_SPICE_NETLIST && /* 20120228 check if schprop NULL */
|
||||
(!schprop || strcmp(schprop, tclgetvar("retval") ) ) ) { /* 20120209 */
|
||||
set_modify(1); push_undo(); /* 20150327 */
|
||||
my_strdup(95, &schprop, (char *) tclgetvar("retval")); /*09112003 */
|
||||
|
||||
} else if(netlist_type==CAD_SYMBOL_ATTRS && current_type==SCHEMATIC && /* 20120228 check if schprop NULL */
|
||||
} else if(netlist_type==CAD_SYMBOL_ATTRS && /* 20120228 check if schprop NULL */
|
||||
(!schsymbolprop || strcmp(schsymbolprop, tclgetvar("retval") ) ) ) { /* 20120209 */
|
||||
set_modify(1); push_undo(); /* 20150327 */
|
||||
my_strdup(422, &schsymbolprop, (char *) tclgetvar("retval")); /*09112003 */
|
||||
|
||||
} else if(netlist_type==CAD_TEDAX_NETLIST && current_type==SCHEMATIC && /* 20120228 check if schprop NULL */
|
||||
} else if(netlist_type==CAD_TEDAX_NETLIST && /* 20120228 check if schprop NULL */
|
||||
(!schtedaxprop || strcmp(schtedaxprop, tclgetvar("retval") ) ) ) { /* 20120209 */
|
||||
set_modify(1); push_undo(); /* 20150327 */
|
||||
my_strdup(96, &schtedaxprop, (char *) tclgetvar("retval")); /*09112003 */
|
||||
|
||||
} else if(netlist_type==CAD_VHDL_NETLIST && current_type==SCHEMATIC && /* 20120228 check if schvhdlprop NULL */
|
||||
} else if(netlist_type==CAD_VHDL_NETLIST && /* 20120228 check if schvhdlprop NULL */
|
||||
(!schvhdlprop || strcmp(schvhdlprop, tclgetvar("retval") ) ) ) { /* netlist_type==CAD_VHDL_NETLIST */
|
||||
set_modify(1); push_undo(); /* 20150327 */
|
||||
my_strdup(97, &schvhdlprop, (char *) tclgetvar("retval"));
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ int draw_window=0; /* 20181009 */
|
|||
int draw_grid=1;
|
||||
double cadgrid = CADGRID;
|
||||
double cadhalfdotsize = CADHALFDOTSIZE;
|
||||
int current_type=SCHEMATIC;
|
||||
char current_name[PATH_MAX]; /* 20190519 */
|
||||
int change_lw=0; /* allow change linewidth */
|
||||
int incr_hilight=1;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function beginfile(f)
|
|||
print "**** symbol-izing: " sym " ****"
|
||||
template="" ; start=0
|
||||
while((getline symline <sym) >0) {
|
||||
if(symline ~ /^G \{/ ) start=1
|
||||
if(symline ~ /^[GK] \{/ ) start=1
|
||||
if(start) template=template symline "\n"
|
||||
if(symline ~ /\} *$/) start=0
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ function beginfile(f)
|
|||
ip=op=n_pin=0
|
||||
print "v {xschem version=2.9.7 file_version=1.1}" > sym
|
||||
if(template=="") {
|
||||
printf "%s", "G {type=subcircuit\nformat=\"@name @pinlist @symname\"\n" >sym
|
||||
printf "%s", "K {type=subcircuit\nformat=\"@name @pinlist @symname\"\n" >sym
|
||||
printf "%s\n", "template=\"name=x1\"" >sym
|
||||
printf "%s", "}\n" >sym
|
||||
}
|
||||
|
|
|
|||
84
src/save.c
84
src/save.c
|
|
@ -398,52 +398,45 @@ void save_line(FILE *fd)
|
|||
|
||||
void write_xschem_file(FILE *fd)
|
||||
{
|
||||
int ty=0;
|
||||
fprintf(fd, "v {xschem version=%s file_version=%s}\n", XSCHEM_VERSION, XSCHEM_FILE_VERSION);
|
||||
/* 20171025 for symbol only put G {} field and look for format or type props in the 3 global prop strings. */
|
||||
if(current_type == SYMBOL) {
|
||||
if(schsymbolprop && schsymbolprop[0]) {
|
||||
fprintf(fd, "G ");
|
||||
save_ascii_string(schsymbolprop,fd);
|
||||
fprintf(fd, "\nV {}\nS {}\nE {}\n");
|
||||
}
|
||||
else if(schvhdlprop && !strncmp(schvhdlprop,"type=", 5)) {
|
||||
|
||||
if(schvhdlprop && !schsymbolprop) {
|
||||
get_tok_value(schvhdlprop,"type",0);
|
||||
ty = get_tok_size;
|
||||
if(ty && !strcmp(schematic[currentsch] + strlen(schematic[currentsch]) - 4,".sym") ) {
|
||||
fprintf(fd, "G {}\nK ");
|
||||
save_ascii_string(schvhdlprop,fd);
|
||||
fputc('\n', fd);
|
||||
} else {
|
||||
fprintf(fd, "G ");
|
||||
save_ascii_string(schvhdlprop,fd);
|
||||
fprintf(fd, "\nV {}\nS {}\nE {}\n");
|
||||
}
|
||||
else if(schtedaxprop && !strncmp(schtedaxprop,"type=", 5)) {
|
||||
fprintf(fd, "G ");
|
||||
save_ascii_string(schtedaxprop,fd);
|
||||
fprintf(fd, "\nV {}\nS {}\nE {}\n");
|
||||
}
|
||||
else if(schprop && !strncmp(schprop,"type=", 5)) {
|
||||
fprintf(fd, "G ");
|
||||
save_ascii_string(schprop,fd);
|
||||
fprintf(fd, "\nV {}\nS {}\nE {}\n");
|
||||
} else if(schverilogprop && !strncmp(schverilogprop,"type=", 5)) {
|
||||
fprintf(fd, "G ");
|
||||
save_ascii_string(schverilogprop,fd);
|
||||
fprintf(fd, "\nV {}\nS {}\nE {}\n");
|
||||
fputc('\n', fd);
|
||||
fprintf(fd, "K ");
|
||||
save_ascii_string(schsymbolprop,fd);
|
||||
fputc('\n', fd);
|
||||
}
|
||||
} else {
|
||||
fprintf(fd, "G ");
|
||||
save_ascii_string(schvhdlprop,fd);
|
||||
fputc('\n', fd);
|
||||
if(schsymbolprop && schsymbolprop[0]) {
|
||||
fprintf(fd, "K ");
|
||||
save_ascii_string(schsymbolprop,fd);
|
||||
fputc('\n', fd);
|
||||
}
|
||||
fprintf(fd, "V ");
|
||||
save_ascii_string(schverilogprop,fd); /*09112003 */
|
||||
fputc('\n', fd);
|
||||
fprintf(fd, "S ");
|
||||
save_ascii_string(schprop,fd); /* 20100217 */
|
||||
fputc('\n', fd);
|
||||
fprintf(fd, "E ");
|
||||
save_ascii_string(schtedaxprop,fd); /* 20100217 */
|
||||
fprintf(fd, "K ");
|
||||
save_ascii_string(schsymbolprop,fd);
|
||||
fputc('\n', fd);
|
||||
}
|
||||
|
||||
fprintf(fd, "V ");
|
||||
save_ascii_string(schverilogprop,fd); /*09112003 */
|
||||
fputc('\n', fd);
|
||||
|
||||
fprintf(fd, "S ");
|
||||
save_ascii_string(schprop,fd); /* 20100217 */
|
||||
fputc('\n', fd);
|
||||
|
||||
fprintf(fd, "E ");
|
||||
save_ascii_string(schtedaxprop,fd); /* 20100217 */
|
||||
fputc('\n', fd);
|
||||
|
||||
save_line(fd);
|
||||
save_box(fd);
|
||||
save_arc(fd);
|
||||
|
|
@ -728,6 +721,7 @@ void read_xschem_file(FILE *fd) /* 20180912 */
|
|||
char tag[1];
|
||||
int inst_cnt;
|
||||
int version_found = 0;
|
||||
int ty=0;
|
||||
|
||||
dbg(2, "read_xschem_file(): start\n");
|
||||
inst_cnt = endfile = 0;
|
||||
|
|
@ -759,9 +753,6 @@ void read_xschem_file(FILE *fd) /* 20180912 */
|
|||
break;
|
||||
case 'G':
|
||||
load_ascii_string(&schvhdlprop,fd);
|
||||
if(schvhdlprop && !strncmp(schvhdlprop, "type=", 5)) current_type = SYMBOL;
|
||||
else current_type=SCHEMATIC;
|
||||
dbg(2, "read_xschem_file(): schematic property:%s\n",schvhdlprop?schvhdlprop:"<NULL>");
|
||||
break;
|
||||
case 'L':
|
||||
load_line(fd);
|
||||
|
|
@ -782,7 +773,6 @@ void read_xschem_file(FILE *fd) /* 20180912 */
|
|||
load_wire(fd);
|
||||
break;
|
||||
case 'C':
|
||||
current_type=SCHEMATIC;
|
||||
load_inst(inst_cnt++, fd);
|
||||
break;
|
||||
case '[':
|
||||
|
|
@ -838,6 +828,17 @@ void read_xschem_file(FILE *fd) /* 20180912 */
|
|||
break;
|
||||
}
|
||||
read_line(fd, 0); /* discard any remaining characters till (but not including) newline */
|
||||
|
||||
if(schvhdlprop) {
|
||||
get_tok_value(schvhdlprop, "type",0);
|
||||
ty = get_tok_size;
|
||||
if(!schsymbolprop && ty && !strcmp(schematic[currentsch] + strlen(schematic[currentsch]) - 4,".sym")) {
|
||||
char *tmp;
|
||||
tmp = schsymbolprop;
|
||||
schsymbolprop = schvhdlprop;
|
||||
schvhdlprop = tmp;
|
||||
}
|
||||
}
|
||||
if(check_version && !version_found) return;
|
||||
if(!file_version[0]) {
|
||||
my_snprintf(file_version, S(file_version), "1.0");
|
||||
|
|
@ -966,7 +967,6 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
|
|||
struct stat buf;
|
||||
int i;
|
||||
|
||||
current_type=SCHEMATIC; /* correct type is set later by read_xschem_file() */
|
||||
prepared_hilight_structs=0; /* 20171212 */
|
||||
prepared_netlist_structs=0; /* 20171212 */
|
||||
prepared_hash_instances=0; /* 20171224 */
|
||||
|
|
@ -999,7 +999,7 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
|
|||
fclose(fd); /* 20150326 moved before load symbols */
|
||||
set_modify(0);
|
||||
dbg(2, "load_schematic(): loaded file:wire=%d inst=%d\n",lastwire , lastinst);
|
||||
if(load_symbols && current_type == SCHEMATIC) link_symbols_to_instances();
|
||||
if(load_symbols) link_symbols_to_instances();
|
||||
}
|
||||
dbg(1, "load_schematic(): %s, returning\n", schematic[currentsch]);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -212,12 +212,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
else if(!strcmp(argv[1],"make_symbol"))
|
||||
{
|
||||
if(has_x) tcleval("tk_messageBox -type okcancel -message {do you want to make symbol view ?}");
|
||||
if(!has_x || strcmp(tclresult(),"ok")==0)
|
||||
if(current_type==SCHEMATIC)
|
||||
{
|
||||
save_schematic(schematic[currentsch]);
|
||||
make_symbol();
|
||||
}
|
||||
if(!has_x || strcmp(tclresult(),"ok")==0) {
|
||||
save_schematic(schematic[currentsch]);
|
||||
make_symbol();
|
||||
}
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
|
||||
|
|
@ -407,7 +405,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
}
|
||||
my_snprintf(schematic[currentsch], S(schematic[currentsch]), "%s/%s", pwd_dir, name);
|
||||
my_strncpy(current_name, name, S(current_name));
|
||||
current_type=SYMBOL;
|
||||
} else {
|
||||
for(i=0;;i++) {
|
||||
if(i == 0) my_snprintf(name, S(name), "%s.sch", "untitled");
|
||||
|
|
@ -416,7 +413,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
}
|
||||
my_snprintf(schematic[currentsch], S(schematic[currentsch]), "%s/%s", pwd_dir, name);
|
||||
my_strncpy(current_name, name, S(current_name));
|
||||
current_type=SCHEMATIC;
|
||||
}
|
||||
draw();
|
||||
set_modify(0); /* 20171025 */
|
||||
|
|
@ -895,19 +891,19 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
f = !strcmp(argv[2],"") ? NULL : argv[2];
|
||||
if(!strcmp(argv[3], "SCHEMATIC")) saveas(f, SCHEMATIC);
|
||||
else if(!strcmp(argv[3], "SYMBOL")) saveas(f, SYMBOL);
|
||||
else saveas(f, current_type);
|
||||
else saveas(f, SCHEMATIC);
|
||||
}
|
||||
else if(argc == 3) {
|
||||
const char *f;
|
||||
f = !strcmp(argv[2],"") ? NULL : argv[2];
|
||||
saveas(f, current_type);
|
||||
saveas(f, SCHEMATIC);
|
||||
}
|
||||
else saveas(NULL, current_type);
|
||||
else saveas(NULL, SCHEMATIC);
|
||||
} else if(!strcmp(argv[1],"save")) {
|
||||
dbg(1, "xschem(): saving: current schematic\n");
|
||||
|
||||
if(!strcmp(schematic[currentsch],"")) { /* 20170622 check if unnamed schematic, use saveas in this case... */
|
||||
saveas(NULL, current_type);
|
||||
saveas(NULL, SCHEMATIC);
|
||||
} else {
|
||||
save(0);
|
||||
}
|
||||
|
|
@ -915,7 +911,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
printf("top win:%lx\n", Tk_WindowId(Tk_Parent(Tk_MainWindow(interp))));
|
||||
} else if(!strcmp(argv[1],"globals")) {
|
||||
printf("*******global variables:*******\n");
|
||||
printf("current_type=%s\n", current_type == SCHEMATIC ? "SCHEMATIC" : "SYMBOL");
|
||||
printf("netlist_dir=%s\n", netlist_dir? netlist_dir: "<NULL>");
|
||||
printf("lw=%d\n", lw);
|
||||
printf("lastwire=%d\n", lastwire);
|
||||
|
|
@ -1567,13 +1562,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
}
|
||||
else if(!strcmp(argv[1],"get") && argc==3)
|
||||
{
|
||||
if(!strcmp(argv[2],"current_type")) { /* 20171025 */
|
||||
if( current_type == SYMBOL )
|
||||
Tcl_AppendResult(interp, "SYMBOL",NULL);
|
||||
else
|
||||
Tcl_AppendResult(interp, "SCHEMATIC",NULL);
|
||||
}
|
||||
else if(!strcmp(argv[2],"incr_hilight")) {
|
||||
if(!strcmp(argv[2],"incr_hilight")) {
|
||||
if( incr_hilight != 0 )
|
||||
Tcl_AppendResult(interp, "1",NULL);
|
||||
else
|
||||
|
|
@ -1877,13 +1866,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
double s = atof(argv[3]);
|
||||
if(s>-20. && s<20.) nocairo_vert_correct = s;
|
||||
}
|
||||
else if(!strcmp(argv[2],"current_type")) { /* 20171025 */
|
||||
if(!strcmp(argv[3],"SYMBOL")) {
|
||||
current_type=SYMBOL;
|
||||
} else {
|
||||
current_type=SCHEMATIC;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(argv[2],"persistent_command")) { /* 20171025 */
|
||||
if(!strcmp(argv[3],"1")) {
|
||||
persistent_command=1;
|
||||
|
|
|
|||
|
|
@ -41,12 +41,6 @@ void global_spice_netlist(int global) /* netlister driver */
|
|||
char cellname[PATH_MAX]; /* 20081211 overflow safe 20161122 */
|
||||
char *subckt_name;
|
||||
|
||||
if(current_type==SYMBOL) {
|
||||
tcleval("alert_ {This is a symbol, no netlisting can be done.\n"
|
||||
"If this is a schematic delete any 'type=...'\n"
|
||||
"from global properties, save and restart xschem}");
|
||||
return;
|
||||
}
|
||||
if(modified) {
|
||||
save_ok = save_schematic(schematic[currentsch]);
|
||||
if(save_ok == -1) return;
|
||||
|
|
|
|||
|
|
@ -31,12 +31,6 @@ void global_tedax_netlist(int global) /* netlister driver */
|
|||
char tcl_cmd_netlist[PATH_MAX + 100]; /* 20081211 overflow safe 20161122 */
|
||||
char cellname[PATH_MAX]; /* 20081211 overflow safe 20161122 */
|
||||
|
||||
if(current_type==SYMBOL) {
|
||||
tcleval("alert_ {This is a symbol, no netlisting can be done.\n"
|
||||
"If this is a schematic delete any 'type=...'\n"
|
||||
"from global properties, save and restart xschem}");
|
||||
return;
|
||||
}
|
||||
if(modified) {
|
||||
save_ok = save_schematic(schematic[currentsch]);
|
||||
if(save_ok == -1) return;
|
||||
|
|
|
|||
|
|
@ -39,12 +39,6 @@ void global_verilog_netlist(int global) /* netlister driver */
|
|||
struct stat buf;
|
||||
char *subckt_name;
|
||||
|
||||
if(current_type==SYMBOL) {
|
||||
tcleval("alert_ {This is a symbol, no netlisting can be done.\n"
|
||||
"If this is a schematic delete any 'type=...'\n"
|
||||
"from global properties, save and restart xschem}");
|
||||
return;
|
||||
}
|
||||
if(modified) {
|
||||
save_ok = save_schematic(schematic[currentsch]);
|
||||
if(save_ok == -1) return;
|
||||
|
|
|
|||
|
|
@ -43,12 +43,6 @@ void global_vhdl_netlist(int global) /* netlister driver */
|
|||
/* top sch properties used for library use declarations and type definitions */
|
||||
/* to be printed before any entity declarations */
|
||||
|
||||
if(current_type==SYMBOL) {
|
||||
tcleval("alert_ {This is a symbol, no netlisting can be done.\n"
|
||||
"If this is a schematic delete any 'type=...'\n"
|
||||
"from global properties, save and restart xschem}");
|
||||
return;
|
||||
}
|
||||
if(modified) {
|
||||
save_ok = save_schematic(schematic[currentsch]);
|
||||
if(save_ok == -1) return;
|
||||
|
|
|
|||
|
|
@ -536,7 +536,6 @@ extern int tcp_port;
|
|||
extern int debug_var;
|
||||
extern char **color_array;
|
||||
extern Colormap colormap;
|
||||
extern int current_type;
|
||||
extern char current_name[PATH_MAX];
|
||||
extern unsigned int color_index[];
|
||||
extern int lw; /* line width */
|
||||
|
|
|
|||
|
|
@ -840,8 +840,7 @@ proc save_file_dialog { msg ext global_initdir {initialfile {}} {overwrt 1} } {
|
|||
}
|
||||
|
||||
proc is_xschem_file {f} {
|
||||
set fd [open $f r]
|
||||
set a [catch "open \"$f\" r" fd]
|
||||
set a [catch {open "$f" r} fd]
|
||||
set ret 0
|
||||
set score 0
|
||||
set instances 0
|
||||
|
|
@ -849,7 +848,7 @@ proc is_xschem_file {f} {
|
|||
puts stderr "Can not open file $f"
|
||||
} else {
|
||||
while { [gets $fd line] >=0 } {
|
||||
if { [regexp {^[TGVSE] \{} $line] } { incr score }
|
||||
if { [regexp {^[TKGVSE] \{} $line] } { incr score }
|
||||
if { [regexp {^[BL] +[0-9]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } { incr score }
|
||||
if { [regexp {^N +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } { incr score }
|
||||
if { [regexp {^C +\{[^{}]+\} +[-0-9.eE]+ +[-0-9.eE]+ +[0-3]+ +[0-3]+ +\{} $line] } { incr instances; incr score }
|
||||
|
|
|
|||
Loading…
Reference in New Issue