Merge branch 'StefanSchippers:master' into master

This commit is contained in:
Chayan Deb 2025-02-03 11:38:11 +05:30 committed by GitHub
commit 0eeef833fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 45 deletions

View File

@ -2010,7 +2010,6 @@ void get_additional_symbols(int what)
if(xctx->tok_size && sch[0]) { /* "schematic" token exists and a schematic is specified */ if(xctx->tok_size && sch[0]) { /* "schematic" token exists and a schematic is specified */
int j; int j;
char *sym = NULL; char *sym = NULL;
char *templ = NULL;
char *symname_attr = NULL; char *symname_attr = NULL;
int ignore_schematic = 0; int ignore_schematic = 0;
xSymbol *symptr = xctx->inst[i].ptr + xctx->sym; xSymbol *symptr = xctx->inst[i].ptr + xctx->sym;
@ -2030,15 +2029,13 @@ void get_additional_symbols(int what)
my_strdup2(_ALLOC_ID_, &sym, add_ext(rel_sym_path(sch), ".sym")); my_strdup2(_ALLOC_ID_, &sym, add_ext(rel_sym_path(sch), ".sym"));
} }
my_strdup2(_ALLOC_ID_, &templ, get_tok_value(symptr->prop_ptr, "template", 0));
my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(sym, 0), NULL); my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(sym, 0), NULL);
my_mstrcat(_ALLOC_ID_, &symname_attr, " symref=", get_sym_name(i, 9999, 1, 1), NULL); my_mstrcat(_ALLOC_ID_, &symname_attr, " symref=", get_sym_name(i, 9999, 1, 1), NULL);
my_strdup(_ALLOC_ID_, &spice_sym_def, my_strdup(_ALLOC_ID_, &spice_sym_def,
translate3(spice_sym_def, 1, xctx->inst[i].prop_ptr, translate3(spice_sym_def, 1, xctx->inst[i].prop_ptr,
templ, symptr->templ,
symname_attr)); symname_attr));
dbg(1, "get_additional_symbols(): spice_sym_def=%s\n", spice_sym_def); dbg(1, "get_additional_symbols(): spice_sym_def=%s\n", spice_sym_def);
my_free(_ALLOC_ID_, &templ);
my_free(_ALLOC_ID_, &symname_attr); my_free(_ALLOC_ID_, &symname_attr);
/* if instance symbol has default_schematic set to ignore copy the symbol anyway, since /* if instance symbol has default_schematic set to ignore copy the symbol anyway, since
* the base symbol will not be netlisted by *_block_netlist() */ * the base symbol will not be netlisted by *_block_netlist() */
@ -2395,8 +2392,7 @@ int descend_schematic(int instnumber, int fallback, int alert, int set_title)
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr, my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr,
xctx->inst[n].prop_ptr); xctx->inst[n].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ, my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ, xctx->sym[xctx->inst[n].ptr].templ);
get_tok_value(xctx->sym[xctx->inst[n].ptr].prop_ptr, "template", 0));
dbg(1,"descend_schematic(): inst_number=%d\n", inst_number); dbg(1,"descend_schematic(): inst_number=%d\n", inst_number);
my_strcat(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], find_nth(str, ",", "", 0, inst_number)); my_strcat(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], find_nth(str, ",", "", 0, inst_number));

View File

@ -5140,7 +5140,7 @@ int descend_symbol(void)
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr, my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr,
xctx->inst[n].prop_ptr); xctx->inst[n].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ, my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ,
get_tok_value(xctx->sym[xctx->inst[n].ptr].prop_ptr, "template", 0)); xctx->sym[xctx->inst[n].ptr].templ);
if(!xctx->inst[n].embed) if(!xctx->inst[n].embed)
/* use -1 to keep track we are descending into symbol from instance with no embed attr /* use -1 to keep track we are descending into symbol from instance with no embed attr

View File

@ -641,14 +641,9 @@ int spice_block_netlist(FILE *fd, int i, int alert)
my_strdup(_ALLOC_ID_, &sym_def, get_tok_value(xctx->sym[i].prop_ptr,"spice_sym_def",0)); my_strdup(_ALLOC_ID_, &sym_def, get_tok_value(xctx->sym[i].prop_ptr,"spice_sym_def",0));
if(sym_def) { if(sym_def) {
char *symname_attr = NULL; char *symname_attr = NULL;
char *templ = NULL;
const char *translated_sym_def; const char *translated_sym_def;
my_strdup2(_ALLOC_ID_, &templ, get_tok_value(xctx->sym[i].prop_ptr, "template", 0));
my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(name, 0), NULL); my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(name, 0), NULL);
translated_sym_def = translate3(sym_def, 1, "", translated_sym_def = translate3(sym_def, 1, "", xctx->sym[i].templ, symname_attr);
templ,
symname_attr);
my_free(_ALLOC_ID_, &templ);
my_free(_ALLOC_ID_, &symname_attr); my_free(_ALLOC_ID_, &symname_attr);
fprintf(fd, "%s\n", translated_sym_def); fprintf(fd, "%s\n", translated_sym_def);
my_free(_ALLOC_ID_, &sym_def); my_free(_ALLOC_ID_, &sym_def);

View File

@ -1174,9 +1174,18 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
if(c=='\0') if(c=='\0')
{ {
if(result && strstr(result, "tcleval(")== result) { /* do one level of substitutions to resolve remaining @params and/or tcl expr/code */
if(result) {
dbg(1, "print_vhdl_primitive(): before translate() result=%s\n", result); dbg(1, "print_vhdl_primitive(): before translate() result=%s\n", result);
my_strdup(_ALLOC_ID_, &result, translate(inst, result)); if(!strcmp(xctx->sym[xctx->inst[inst].ptr].type, "netlist_commands")) {
/* since netlist_commands often have @ characters in spice node save / plot commands, do
* not pass through translate, unless a tcleval(...) is present */
if(strstr(result, "tcleval(")== result) {
my_strdup(_ALLOC_ID_, &result, translate(inst, result));
}
} else {
my_strdup(_ALLOC_ID_, &result, translate(inst, result));
}
dbg(1, "print_vhdl_primitive(): after translate() result=%s\n", result); dbg(1, "print_vhdl_primitive(): after translate() result=%s\n", result);
} }
if(result) fprintf(fd, "%s", result); if(result) fprintf(fd, "%s", result);
@ -1856,7 +1865,6 @@ static int has_included_subcircuit(int inst, int symbol, char **result)
if(xctx->tok_size) { if(xctx->tok_size) {
char *symname = NULL; char *symname = NULL;
char *templ = NULL;
char *symname_attr = NULL; char *symname_attr = NULL;
int no_of_pins = (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER]; int no_of_pins = (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
int i; int i;
@ -1865,7 +1873,6 @@ static int has_included_subcircuit(int inst, int symbol, char **result)
Str_hashentry *entry; Str_hashentry *entry;
Str_hashtable table = {NULL, 0}; Str_hashtable table = {NULL, 0};
my_strdup2(_ALLOC_ID_, &templ, get_tok_value(xctx->sym[symbol].prop_ptr, "template", 0));
my_strdup2(_ALLOC_ID_, &symname, get_tok_value(xctx->inst[inst].prop_ptr, "schematic", 0)); my_strdup2(_ALLOC_ID_, &symname, get_tok_value(xctx->inst[inst].prop_ptr, "schematic", 0));
if(!symname[0]) { if(!symname[0]) {
my_strdup2(_ALLOC_ID_, &symname, get_tok_value(xctx->sym[symbol].prop_ptr, "schematic", 0)); my_strdup2(_ALLOC_ID_, &symname, get_tok_value(xctx->sym[symbol].prop_ptr, "schematic", 0));
@ -1876,7 +1883,7 @@ static int has_included_subcircuit(int inst, int symbol, char **result)
my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(symname, 0), NULL); my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(symname, 0), NULL);
my_mstrcat(_ALLOC_ID_, &symname_attr, " symref=", get_sym_name(inst, 9999, 1, 1), NULL); my_mstrcat(_ALLOC_ID_, &symname_attr, " symref=", get_sym_name(inst, 9999, 1, 1), NULL);
translated_sym_def = translate3(spice_sym_def, 1, xctx->inst[inst].prop_ptr, translated_sym_def = translate3(spice_sym_def, 1, xctx->inst[inst].prop_ptr,
templ, xctx->sym[symbol].templ,
symname_attr); symname_attr);
dbg(1, "has_included_subcircuit(): translated_sym_def=%s\n", translated_sym_def); dbg(1, "has_included_subcircuit(): translated_sym_def=%s\n", translated_sym_def);
dbg(1, "has_included_subcircuit(): symname=%s\n", symname); dbg(1, "has_included_subcircuit(): symname=%s\n", symname);
@ -1915,7 +1922,6 @@ static int has_included_subcircuit(int inst, int symbol, char **result)
tclvareval("has_included_subcircuit {", get_cell(symname, 0), "} {", tclvareval("has_included_subcircuit {", get_cell(symname, 0), "} {",
translated_sym_def, "} ", my_itoa(exp_no_of_pins), NULL); translated_sym_def, "} ", my_itoa(exp_no_of_pins), NULL);
my_free(_ALLOC_ID_, &templ);
my_free(_ALLOC_ID_, &symname_attr); my_free(_ALLOC_ID_, &symname_attr);
if(tclresult()[0]) { /* a valid spice_sym_def netlist was found */ if(tclresult()[0]) { /* a valid spice_sym_def netlist was found */
char *subckt_pin, *pin_save; char *subckt_pin, *pin_save;
@ -2473,32 +2479,20 @@ int print_spice_element(FILE *fd, int inst)
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions /* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
* can be calculated */ * can be calculated */
/* do one level of substitutions to resolve @params and equations*/ /* do one level of substitutions to resolve remaining @params and/or tcl expr/code */
if(result && strstr(result, "tcleval(")== result) { if(result) {
dbg(1, "print_spice_element(): before translate() result=%s\n", result); dbg(1, "print_spice_element(): before translate() result=%s\n", result);
my_strdup(_ALLOC_ID_, &result, translate(inst, result)); if(!strcmp(xctx->sym[xctx->inst[inst].ptr].type, "netlist_commands")) {
/* since netlist_commands often have @ characters in spice node save / plot commands, do
* not pass through translate, unless a tcleval(...) is present */
if(strstr(result, "tcleval(")== result) {
my_strdup(_ALLOC_ID_, &result, translate(inst, result));
}
} else {
my_strdup(_ALLOC_ID_, &result, translate(inst, result));
}
dbg(1, "print_spice_element(): after translate() result=%s\n", result); dbg(1, "print_spice_element(): after translate() result=%s\n", result);
} }
/* can't remember what the f**k this is supposed to do.
why eval( and not tcleval( ?
disable until some regression pops out
*/
#if 0
* /* do a second round of substitutions, but without calling tcl */
* if(result && strstr(result, "eval(") == result) {
* char *c = strrchr(result, ')');
* if(c) while(1) { /* shift following characters back 1 char */
* *c = (char)c[1];
* c++;
* if(!*c) break;
* }
* my_strdup2(_ALLOC_ID_, &result, translate(inst, result+5));
* }
#endif
if(result) fprintf(fd, "%s", result); if(result) fprintf(fd, "%s", result);
my_free(_ALLOC_ID_, &template); my_free(_ALLOC_ID_, &template);
my_free(_ALLOC_ID_, &format); my_free(_ALLOC_ID_, &format);
@ -3107,10 +3101,18 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
} }
if(c=='\0') if(c=='\0')
{ {
/* do one level of substitutions to resolve @params and equations*/ /* do one level of substitutions to resolve remaining @params and/or tcl expr/code */
if(result && strstr(result, "tcleval(")== result) { if(result) {
dbg(1, "print_verilog_primitive(): before translate() result=%s\n", result); dbg(1, "print_verilog_primitive(): before translate() result=%s\n", result);
my_strdup(_ALLOC_ID_, &result, translate(inst, result)); if(!strcmp(xctx->sym[xctx->inst[inst].ptr].type, "netlist_commands")) {
/* since netlist_commands often have @ characters in spice node save / plot commands, do
* not pass through translate, unless a tcleval(...) is present */
if(strstr(result, "tcleval(")== result) {
my_strdup(_ALLOC_ID_, &result, translate(inst, result));
}
} else {
my_strdup(_ALLOC_ID_, &result, translate(inst, result));
}
dbg(1, "print_verilog_primitive(): after translate() result=%s\n", result); dbg(1, "print_verilog_primitive(): after translate() result=%s\n", result);
} }
if(result) fprintf(fd, "%s", result); if(result) fprintf(fd, "%s", result);