From 882e20397de95a421236cb9ef07463094989e785 Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 14:12:05 +0100
Subject: [PATCH 1/9] get_additional_symbols(), get_sch_from_sym(): allow to
resolve schematic calls like: schematic=generator.tcl(@n\) --> let
get_tok_value() return backslashes and remove surrounding "..." quotes
---
src/actions.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index f726c945..031a3cef 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1969,7 +1969,7 @@ void get_additional_symbols(int what)
dbg(1, "schematic=%s\n", get_tok_value(xctx->inst[i].prop_ptr,"schematic",2));
/* resolve schematic=generator.tcl( @n ) where n=11 is defined in instance attrs */
my_strdup2(_ALLOC_ID_, &sch,
- translate3(get_tok_value(xctx->inst[i].prop_ptr,"schematic",2), 1,
+ translate3(get_tok_value(xctx->inst[i].prop_ptr,"schematic", 6), 1,
xctx->inst[i].prop_ptr, NULL, NULL));
dbg(1, "sch=%s\n", sch);
@@ -2093,7 +2093,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback)
if(inst >= 0) {
/* resolve schematic=generator.tcl( @n ) where n=11 is defined in instance attrs */
my_strdup2(_ALLOC_ID_, &str_tmp,
- translate3(get_tok_value(xctx->inst[inst].prop_ptr,"schematic",2), 1,
+ translate3(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), 1,
xctx->inst[inst].prop_ptr, NULL, NULL));
}
if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 2));
From 0a3fd95e065f34dea80c851efe049cf9205ef289 Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 14:58:10 +0100
Subject: [PATCH 2/9] code formatting
---
src/select.c | 3 +--
src/token.c | 8 ++++----
src/vhdl_netlist.c | 4 ++--
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/select.c b/src/select.c
index 324dac19..c6b521cb 100644
--- a/src/select.c
+++ b/src/select.c
@@ -964,8 +964,7 @@ void select_element(int i,unsigned short select_mode, int fast, int override_loc
if(xctx->inst[i].node && (xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr)
{
my_snprintf(str, S(str), "pin:%s -> %s",
- get_tok_value(
- (xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0) ,
+ get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0),
xctx->inst[i].node[j] ? xctx->inst[i].node[j] : "__UNCONNECTED_PIN__");
statusmsg(str,2);
}
diff --git a/src/token.c b/src/token.c
index d3aef7c6..1ae356fa 100644
--- a/src/token.c
+++ b/src/token.c
@@ -1557,13 +1557,13 @@ void print_vhdl_element(FILE *fd, int inst)
for(i=0;iinst[inst].node || !xctx->inst[inst].node[no_of_pins+i]) continue;
- my_strdup(_ALLOC_ID_, &generic_type,get_tok_value(
- (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"type",0));
+ my_strdup(_ALLOC_ID_, &generic_type,
+ get_tok_value( (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"type",0));
my_strdup(_ALLOC_ID_, &generic_value, xctx->inst[inst].node[no_of_pins+i] );
/*my_strdup(_ALLOC_ID_, &generic_value, get_tok_value( */
/* (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"value") ); */
- str_ptr = get_tok_value(
- (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"name",0);
+ str_ptr =
+ get_tok_value( (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"name",0);
if(generic_value) { /*03062002 dont print generics if unassigned */
if(tmp) fprintf(fd, " ,\n");
if(!tmp) fprintf(fd, "generic map (\n");
diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c
index ad54345d..1287c8e0 100644
--- a/src/vhdl_netlist.c
+++ b/src/vhdl_netlist.c
@@ -660,8 +660,8 @@ int vhdl_block_netlist(FILE *fd, int i)
for(k=0;ksym[j].rects[PINLAYER]; ++k)
{
if(strboolcmp(get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"vhdl_ignore",0), "true")) {
- my_strdup(_ALLOC_ID_, &sig_type,get_tok_value(
- xctx->sym[j].rect[PINLAYER][k].prop_ptr,"sig_type",0));
+ my_strdup(_ALLOC_ID_, &sig_type,
+ get_tok_value( xctx->sym[j].rect[PINLAYER][k].prop_ptr,"sig_type",0));
my_strdup(_ALLOC_ID_, &port_value,
get_tok_value(xctx->sym[j].rect[PINLAYER][k].prop_ptr,"value", 0) );
From 59e7872f67de48f3ca5225b5d841d5e5bddffaae Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 16:00:47 +0100
Subject: [PATCH 3/9] reduce some pointer indirections to array subscripts
(readability)
---
src/actions.c | 2 +-
src/editprop.c | 4 +--
src/hilight.c | 6 ++--
src/netlist.c | 12 ++++----
src/save.c | 10 ++++---
src/scheduler.c | 14 ++++-----
src/select.c | 2 +-
src/spice_netlist.c | 8 ++---
src/token.c | 69 ++++++++++++++++++++++---------------------
src/verilog_netlist.c | 8 ++---
10 files changed, 69 insertions(+), 66 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index 031a3cef..aaf181e5 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -2358,7 +2358,7 @@ int descend_schematic(int instnumber, int fallback, int alert, int set_title)
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr,
xctx->inst[n].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ,
- get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "template", 0));
+ get_tok_value(xctx->sym[xctx->inst[n].ptr].prop_ptr, "template", 0));
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));
diff --git a/src/editprop.c b/src/editprop.c
index 7c96173b..f40a65a4 100644
--- a/src/editprop.c
+++ b/src/editprop.c
@@ -1561,7 +1561,7 @@ static int update_symbol(const char *result, int x, int selected_inst)
dbg(1, "update_symbol(): for k loop: k=%d\n", k);
if(xctx->sel_array[k].type != ELEMENT) continue;
*ii=xctx->sel_array[k].n;
- old_prefix=(get_tok_value((xctx->sym + xctx->inst[*ii].ptr)->templ, "name",0))[0];
+ old_prefix=(get_tok_value(xctx->sym[xctx->inst[*ii].ptr].templ, "name",0))[0];
/* 20171220 calculate bbox before changes to correctly redraw areas */
/* must be recalculated as cairo text extents vary with zoom factor. */
symbol_bbox(*ii, &xctx->inst[*ii].x1, &xctx->inst[*ii].y1, &xctx->inst[*ii].x2, &xctx->inst[*ii].y2);
@@ -1604,7 +1604,7 @@ static int update_symbol(const char *result, int x, int selected_inst)
( !strcmp(symbol, xctx->inst[*ii].name) && strcmp(translated_sym, old_translated_sym) ) ) {
sym_number=match_symbol(translated_sym); /* check if exist */
if(sym_number>=0) {
- prefix=(get_tok_value((xctx->sym+sym_number)->templ, "name",0))[0]; /* get new symbol prefix */
+ prefix=(get_tok_value(xctx->sym[sym_number].templ, "name",0))[0]; /* get new symbol prefix */
}
}
diff --git a/src/hilight.c b/src/hilight.c
index f4d0f2b7..776526c3 100644
--- a/src/hilight.c
+++ b/src/hilight.c
@@ -591,7 +591,7 @@ void hilight_parent_pins(void)
if(!xctx->inst[i].node || !xctx->inst[i].node[j]) continue;
my_strdup(_ALLOC_ID_, &net_node, expandlabel(xctx->inst[i].node[j], &net_mult));
dbg(1, "hilight_parent_pins(): net_node=%s\n", net_node);
- pin_name = get_tok_value((xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0);
+ pin_name = get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][j].prop_ptr,"name",0);
dbg(1, "pin_name=%s\n", pin_name);
if(!pin_name[0]) continue;
my_strdup(_ALLOC_ID_, &pin_node, expandlabel(pin_name, &mult));
@@ -659,7 +659,7 @@ void hilight_child_pins(void)
if(!xctx->inst[i].node || !xctx->inst[i].node[j]) continue;
my_strdup(_ALLOC_ID_, &net_node, expandlabel(xctx->inst[i].node[j], &net_mult));
dbg(1, "hilight_child_pins(): net_node=%s\n", net_node);
- pin_name = get_tok_value((xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0);
+ pin_name = get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][j].prop_ptr,"name",0);
if(!pin_name[0]) continue;
my_strdup(_ALLOC_ID_, &pin_node, expandlabel(pin_name, &mult));
dbg(1, "hilight_child_pins(): pin_node=%s\n", pin_node);
@@ -771,7 +771,7 @@ int search(const char *tok, const char *val, int sub, int sel, int match_case)
} else if(!strcmp(tok,"cell::propstring")) {
has_token = (str = (xctx->inst[i].ptr+ xctx->sym)->prop_ptr) ? 1 : 0;
} else if(!strncmp(tok,"cell::", 6)) { /* cell::xxx looks for xxx in global symbol attributes */
- my_strdup(_ALLOC_ID_, &tmpname,get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr,tok+6,0));
+ my_strdup(_ALLOC_ID_, &tmpname,get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr,tok+6,0));
has_token = xctx->tok_size;
if(tmpname) {
str = tmpname;
diff --git a/src/netlist.c b/src/netlist.c
index a474f53a..87cf255d 100644
--- a/src/netlist.c
+++ b/src/netlist.c
@@ -839,12 +839,12 @@ static void name_generics()
bus_node_hash_lookup(inst[n].node[p],"", XINSERT, 1, sig_type,"", "","");
} else {
my_strdup(_ALLOC_ID_, &sig_type,
- get_tok_value((inst[i].ptr+ xctx->sym)->rect[GENERICLAYER][j-rects].prop_ptr, "sig_type", 0));
+ get_tok_value(xctx->sym[inst[i].ptr].rect[GENERICLAYER][j-rects].prop_ptr, "sig_type", 0));
/* insert generic label in hash table as a port so it will not */
/* be declared as a signal in the vhdl netlist. this is a workaround */
/* that should be fixed 25092001 */
bus_node_hash_lookup(inst[n].node[p],
- get_tok_value((inst[i].ptr+ xctx->sym)->rect[GENERICLAYER][j-rects].prop_ptr, "dir",0),
+ get_tok_value(xctx->sym[inst[i].ptr].rect[GENERICLAYER][j-rects].prop_ptr, "dir",0),
XINSERT, 1, sig_type,"", "","");
}
} /* end if(inst[iptr->n].node[iptr->pin] != NULL) */
@@ -1276,7 +1276,7 @@ static int name_nodes_of_pins_labels_and_propagate()
if(skip_instance(i, 0, netlist_lvs_ignore)) continue;
my_strdup(_ALLOC_ID_, &type,(inst[i].ptr+ xctx->sym)->type);
if(print_erc && (!inst[i].instname || !inst[i].instname[0]) &&
- !get_tok_value((inst[i].ptr+ xctx->sym)->templ, "name", 0)[0]
+ !get_tok_value(xctx->sym[inst[i].ptr].templ, "name", 0)[0]
) {
char str[2048];
if( type && /* list of devices that do not have a name= in template attribute */
@@ -1319,13 +1319,13 @@ static int name_nodes_of_pins_labels_and_propagate()
/* 20071204 only define a dir property if instance is not a label */
if(for_netlist)
my_strdup2(_ALLOC_ID_, &dir,
- get_tok_value( (inst[i].ptr+ xctx->sym)->rect[PINLAYER][0].prop_ptr, "dir",0));
+ get_tok_value(xctx->sym[inst[i].ptr].rect[PINLAYER][0].prop_ptr, "dir",0));
}
else {
/* handle global nodes (global=1 set as symbol property) 28032003 */
my_strdup(_ALLOC_ID_, &global_node,get_tok_value(inst[i].prop_ptr,"global",0));
if(!xctx->tok_size) {
- my_strdup(_ALLOC_ID_, &global_node,get_tok_value((inst[i].ptr+ xctx->sym)->prop_ptr,"global",0));
+ my_strdup(_ALLOC_ID_, &global_node,get_tok_value(xctx->sym[inst[i].ptr].prop_ptr,"global",0));
}
/*20071204 if instance is a label dont define a dir property for more precise erc checking */
}
@@ -1338,7 +1338,7 @@ static int name_nodes_of_pins_labels_and_propagate()
}
my_strdup(_ALLOC_ID_, &inst[i].node[0], inst[i].lab);
if(!(inst[i].node[0])) {
- my_strdup(_ALLOC_ID_, &inst[i].node[0], get_tok_value((inst[i].ptr+ xctx->sym)->templ, "lab",0));
+ my_strdup(_ALLOC_ID_, &inst[i].node[0], get_tok_value(xctx->sym[inst[i].ptr].templ, "lab",0));
dbg(1, "name_nodes_of_pins_labels_and_propagate(): no lab attr on instance, pick from symbol: %s\n",
inst[i].node[0]);
}
diff --git a/src/save.c b/src/save.c
index bf880b1d..bd211510 100644
--- a/src/save.c
+++ b/src/save.c
@@ -3222,10 +3222,12 @@ static int pin_compare(const void *a, const void *b)
int pinnumber_a, pinnumber_b;
const char *tmp;
int result;
+ xRect *aa = (xRect *)a;
+ xRect *bb = (xRect *)b;
- tmp = get_tok_value(((xRect *)a)->prop_ptr, "sim_pinnumber", 0);
+ tmp = get_tok_value(aa->prop_ptr, "sim_pinnumber", 0);
pinnumber_a = tmp[0] ? atoi(tmp) : -1;
- tmp = get_tok_value(((xRect *)b)->prop_ptr, "sim_pinnumber", 0);
+ tmp = get_tok_value(bb->prop_ptr, "sim_pinnumber", 0);
pinnumber_b = tmp[0] ?atoi(tmp) : -1;
result = pinnumber_a < pinnumber_b ? -1 : pinnumber_a == pinnumber_b ? 0 : 1;
if(result >= 0) order_changed = 1;
@@ -4967,7 +4969,7 @@ void create_sch_from_sym(void)
if(xctx->lastsel==1 && xctx->sel_array[0].type==ELEMENT)
{
my_strdup2(_ALLOC_ID_, &sch,
- get_tok_value((xctx->inst[xctx->sel_array[0].n].ptr+ xctx->sym)->prop_ptr, "schematic",0 ));
+ get_tok_value(xctx->sym[xctx->inst[xctx->sel_array[0].n].ptr].prop_ptr, "schematic", 0));
my_strncpy(schname, abs_sym_path(sch, ""), S(schname));
my_free(_ALLOC_ID_, &sch);
if(!schname[0]) {
@@ -5101,7 +5103,7 @@ void descend_symbol(void)
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr,
xctx->inst[n].prop_ptr);
my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ,
- get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "template", 0));
+ get_tok_value(xctx->sym[xctx->inst[n].ptr].prop_ptr, "template", 0));
if(!xctx->inst[n].embed)
/* use -1 to keep track we are descending into symbol from instance with no embed attr
diff --git a/src/scheduler.c b/src/scheduler.c
index def55e4f..bc08d8ba 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1817,7 +1817,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
tmp = xctx->inst[i].name;
Tcl_SetResult(interp, (char *) tmp, TCL_VOLATILE);
} else if(strstr(argv[4], "cell::") ) {
- tmp = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, argv[4]+6, with_quotes);
+ tmp = get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr, argv[4]+6, with_quotes);
dbg(1, "scheduler(): xschem getprop: looking up instance %d prop cell::|%s| : |%s|\n", i, argv[4]+6, tmp);
Tcl_SetResult(interp, (char *) tmp, TCL_VOLATILE);
} else {
@@ -1853,7 +1853,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
value = get_tok_value(xctx->inst[inst].prop_ptr,subtok,0);
}
if(!value[0]) {
- value = get_tok_value((xctx->inst[inst].ptr+ xctx->sym)->rect[PINLAYER][n].prop_ptr,argv[5],0);
+ value = get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][n].prop_ptr,argv[5],0);
}
if(value[0] != 0) {
char *ss;
@@ -2450,7 +2450,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
prepare_netlist_structs(0);
no_of_pins= (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER];
for(p=0;pinst[i].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr, "name",0), argv[3])) {
+ if(!strcmp(get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][p].prop_ptr, "name",0), argv[3])) {
str_ptr = net_name(i,p, &multip, 0, 1);
break;
}
@@ -2482,7 +2482,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
no_of_pins= (xctx->inst[inst].ptr+ xctx->sym)->rects[PINLAYER];
for(p=0;pinst[inst].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr, "name",0);
+ pin = get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][p].prop_ptr, "name",0);
if(!pin[0]) pin = "--ERROR--";
if(argc > 3 && strcmp(argv[3], pin)) continue;
if(first == 0) Tcl_AppendResult(interp, " ", NULL);
@@ -2596,7 +2596,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
no_of_pins= (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER];
for(p=0;pinst[i].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr, "name",0);
+ pin = get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][p].prop_ptr, "name",0);
if(!pin[0]) pin = "--ERROR--";
my_mstrcat(_ALLOC_ID_, &pins, "{", pin, "}", NULL);
if(p< no_of_pins-1) my_strcat(_ALLOC_ID_, &pins, " ");
@@ -3423,7 +3423,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(first == 0) Tcl_AppendResult(interp, " ", NULL);
if(argc > 3 && argv[3][0]) {
Tcl_AppendResult(interp, "{ {", my_itoa(p), "} {",
- get_tok_value((xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr, argv[3], 0),
+ get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][p].prop_ptr, argv[3], 0),
"} }", NULL);
} else {
Tcl_AppendResult(interp, "{ {", my_itoa(p), "} {",
@@ -4397,7 +4397,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
my_free(_ALLOC_ID_, &sym);
if(sym_number>=0)
{
- prefix=(get_tok_value( (xctx->sym+sym_number)->templ , "name",0))[0]; /* get new symbol prefix */
+ prefix=(get_tok_value(xctx->sym[sym_number].templ , "name",0))[0]; /* get new symbol prefix */
}
else prefix = 'x';
delete_inst_node(inst); /* 20180208 fix crashing bug: delete node info if changing symbol */
diff --git a/src/select.c b/src/select.c
index c6b521cb..485c9ee3 100644
--- a/src/select.c
+++ b/src/select.c
@@ -964,7 +964,7 @@ void select_element(int i,unsigned short select_mode, int fast, int override_loc
if(xctx->inst[i].node && (xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr)
{
my_snprintf(str, S(str), "pin:%s -> %s",
- get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0),
+ get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][j].prop_ptr,"name",0),
xctx->inst[i].node[j] ? xctx->inst[i].node[j] : "__UNCONNECTED_PIN__");
statusmsg(str,2);
}
diff --git a/src/spice_netlist.c b/src/spice_netlist.c
index fe1ebb1b..8fb84523 100644
--- a/src/spice_netlist.c
+++ b/src/spice_netlist.c
@@ -231,7 +231,7 @@ static int spice_netlist(FILE *fd, int spice_stop )
if(m[0]) str_hash_lookup(&model_table, model_name(m), m, XINSERT);
else {
my_strdup2(_ALLOC_ID_, &val,
- get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "device_model", 2));
+ get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr, "device_model", 2));
m = val;
if(strchr(val, '@')) m = translate(i, val);
else m = tcl_hook2(m);
@@ -316,7 +316,7 @@ int global_spice_netlist(int global) /* netlister driver */
{
if(skip_instance(i, 1, lvs_ignore)) continue;
type = (xctx->inst[i].ptr+ xctx->sym)->type;
- my_strdup(_ALLOC_ID_, &place,get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr,"place",0));
+ my_strdup(_ALLOC_ID_, &place,get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr,"place",0));
if( type && !strcmp(type,"netlist_commands") ) {
if(!place) {
my_strdup(_ALLOC_ID_, &place,get_tok_value(xctx->inst[i].prop_ptr,"place",0));
@@ -380,7 +380,7 @@ int global_spice_netlist(int global) /* netlister driver */
{
if(skip_instance(i, 1, lvs_ignore)) continue;
type = (xctx->inst[i].ptr+ xctx->sym)->type;
- my_strdup(_ALLOC_ID_, &place,get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr,"place",0));
+ my_strdup(_ALLOC_ID_, &place,get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr,"place",0));
if( type && !strcmp(type,"netlist_commands") ) {
if(!place) {
my_strdup(_ALLOC_ID_, &place,get_tok_value(xctx->inst[i].prop_ptr,"place",0));
@@ -535,7 +535,7 @@ int global_spice_netlist(int global) /* netlister driver */
{
if(skip_instance(i, 1, lvs_ignore)) continue;
type = (xctx->inst[i].ptr+ xctx->sym)->type;
- my_strdup(_ALLOC_ID_, &place,get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr,"place",0));
+ my_strdup(_ALLOC_ID_, &place,get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr,"place",0));
if( type && !strcmp(type,"netlist_commands") ) {
if(place && !strcmp(place, "end" )) {
if(first == 0) fprintf(fd,"**** begin user architecture code\n");
diff --git a/src/token.c b/src/token.c
index 1ae356fa..6a2bf6e2 100644
--- a/src/token.c
+++ b/src/token.c
@@ -424,6 +424,7 @@ static void get_pin_and_attr(const char *token, char **pin_num_or_name, char **p
/* bit 1: */
/* 1: do not perform tcl_hook2 substitution */
/* bit: 2 = 1: same as bit 0 = 1, but remove surrounding "..." quotes, keep everything in between */
+/* with_quotes values used in xschem: 0 1 2 4 6 */
const char *get_tok_value(const char *s,const char *tok, int with_quotes)
@@ -626,7 +627,7 @@ static char *get_pin_attr_from_inst(int inst, int pin, const char *attr)
dbg(1, "get_pin_attr_from_inst(): inst=%d pin=%d attr=%s\n", inst, pin, attr);
if(xctx->inst[inst].ptr < 0 ) return NULL;
pin_attr_value = NULL;
- str = get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][pin].prop_ptr,"name",0);
+ str = get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][pin].prop_ptr,"name",0);
if(str[0]) {
size_t tok_val_len;
tok_val_len = strlen(str);
@@ -934,13 +935,13 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr, fmt_attr, 2));
/* get netlist format rule from symbol */
if(!xctx->tok_size)
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, fmt_attr, 2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, fmt_attr, 2));
/* allow format string override in instance */
if(xctx->tok_size && strcmp(fmt_attr, "vhdl_format"))
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr, "vhdl_format", 2));
/* get netlist format rule from symbol */
if(!xctx->tok_size && strcmp(fmt_attr, "vhdl_format"))
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "vhdl_format", 2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "vhdl_format", 2));
if((name==NULL) || (format==NULL) ) {
my_free(_ALLOC_ID_, &template);
my_free(_ALLOC_ID_, &name);
@@ -1093,7 +1094,7 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
/* get pin_attr from instance pin attribute string */
if(!pin_attr_value) {
my_strdup(_ALLOC_ID_, &pin_attr_value,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][n].prop_ptr, pin_attr, 0));
}
}
/* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin */
@@ -1454,13 +1455,13 @@ void print_vhdl_element(FILE *fd, int inst)
fmt = get_tok_value(xctx->inst[inst].prop_ptr, fmt_attr, 2);
/* get netlist format rule from symbol */
if(!xctx->tok_size)
- fmt = get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, fmt_attr, 2);
+ fmt = get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, fmt_attr, 2);
/* allow format string override in instance */
if(!xctx->tok_size && strcmp(fmt_attr, "vhdl_format") )
fmt = get_tok_value(xctx->inst[inst].prop_ptr, "vhdl_format", 2);
/* get netlist format rule from symbol */
if(!xctx->tok_size && strcmp(fmt_attr, "vhdl_format"))
- fmt = get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "vhdl_format", 2);
+ fmt = get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "vhdl_format", 2);
if(fmt[0]) {
print_vhdl_primitive(fd, inst);
@@ -1491,7 +1492,7 @@ void print_vhdl_element(FILE *fd, int inst)
tmp=0;
/* 20080213 use generic_type property to decide if some properties are strings, see later */
- my_strdup(_ALLOC_ID_, &generic_type, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"generic_type", 0));
+ my_strdup(_ALLOC_ID_, &generic_type, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr,"generic_type", 0));
while(1)
{
@@ -1558,12 +1559,12 @@ void print_vhdl_element(FILE *fd, int inst)
{
if(!xctx->inst[inst].node || !xctx->inst[inst].node[no_of_pins+i]) continue;
my_strdup(_ALLOC_ID_, &generic_type,
- get_tok_value( (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"type",0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[GENERICLAYER][i].prop_ptr,"type",0));
my_strdup(_ALLOC_ID_, &generic_value, xctx->inst[inst].node[no_of_pins+i] );
/*my_strdup(_ALLOC_ID_, &generic_value, get_tok_value( */
/* (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"value") ); */
str_ptr =
- get_tok_value( (xctx->inst[inst].ptr + xctx->sym)->rect[GENERICLAYER][i].prop_ptr,"name",0);
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[GENERICLAYER][i].prop_ptr,"name",0);
if(generic_value) { /*03062002 dont print generics if unassigned */
if(tmp) fprintf(fd, " ,\n");
if(!tmp) fprintf(fd, "generic map (\n");
@@ -1589,7 +1590,7 @@ void print_vhdl_element(FILE *fd, int inst)
{
if(tmp) fprintf(fd, " ,\n");
fprintf(fd, " %s => %s",
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr,"name",0),
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][i].prop_ptr,"name",0),
str_ptr);
tmp=1;
}
@@ -2137,13 +2138,13 @@ int print_spice_element(FILE *fd, int inst)
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr, fmt_attr, 2));
/* get netlist format rule from symbol */
if(!xctx->tok_size)
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, fmt_attr, 2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, fmt_attr, 2));
/* allow format string override in instance */
if(!xctx->tok_size && strcmp(fmt_attr, "format") )
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr, "format", 2));
/* get netlist format rule from symbol */
if(!xctx->tok_size && strcmp(fmt_attr, "format"))
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "format", 2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "format", 2));
if ((name==NULL) || (format==NULL)) {
my_free(_ALLOC_ID_, &template);
my_free(_ALLOC_ID_, &format);
@@ -2359,7 +2360,7 @@ int print_spice_element(FILE *fd, int inst)
/* get pin_attr from instance pin attribute string */
if(!pin_attr_value) {
my_strdup(_ALLOC_ID_, &pin_attr_value,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][n].prop_ptr, pin_attr, 0));
}
}
/* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin */
@@ -2516,10 +2517,10 @@ void print_tedax_element(FILE *fd, int inst)
int no_of_pins=0;
int subcircuit = 0;
- my_strdup(_ALLOC_ID_, &extra, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"extra",0));
+ my_strdup(_ALLOC_ID_, &extra, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr,"extra",0));
my_strdup(_ALLOC_ID_, &extra_pinnumber, get_tok_value(xctx->inst[inst].prop_ptr,"extra_pinnumber",0));
if(!extra_pinnumber) my_strdup(_ALLOC_ID_, &extra_pinnumber,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"extra_pinnumber",0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr,"extra_pinnumber",0));
my_strdup(_ALLOC_ID_, &template,
(xctx->inst[inst].ptr + xctx->sym)->templ);
my_strdup(_ALLOC_ID_, &numslots, get_tok_value(xctx->inst[inst].prop_ptr,"numslots",0));
@@ -2533,7 +2534,7 @@ void print_tedax_element(FILE *fd, int inst)
/* allow format string override in instance */
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr,"tedax_format",2));
if(!format || !format[0])
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"tedax_format",2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr,"tedax_format",2));
no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
if( !format && !strcmp((xctx->inst[inst].ptr + xctx->sym)->type, "subcircuit") ) {
@@ -2553,7 +2554,7 @@ void print_tedax_element(FILE *fd, int inst)
for(i=0;iinst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr,"name",0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][i].prop_ptr,"name",0));
my_strdup2(_ALLOC_ID_, &pin, expandlabel(pinname, &pin_mult));
if(!int_hash_lookup(&table, pinname, 1, XINSERT_NOREPLACE)) {
dbg(1, "#net=%s pinname=%s pin=%s net_mult=%d pin_mult=%d\n", net, pinname, pin, net_mult, pin_mult);
@@ -2592,7 +2593,7 @@ void print_tedax_element(FILE *fd, int inst)
pinnumber = get_pin_attr_from_inst(inst, i, "pinnumber");
if(!pinnumber) {
my_strdup2(_ALLOC_ID_, &pinnumber,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr,"pinnumber",0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][i].prop_ptr,"pinnumber",0));
}
if(!xctx->tok_size) my_strdup(_ALLOC_ID_, &pinnumber, "--UNDEF--");
tmp = net_name(inst,i, &multip, 0, 1);
@@ -2600,7 +2601,7 @@ void print_tedax_element(FILE *fd, int inst)
fprintf(fd, "conn %s %s %s %s %d\n",
name,
tmp,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr,"name",0),
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][i].prop_ptr,"name",0),
pinnumber,
i+1);
}
@@ -2724,7 +2725,7 @@ void print_tedax_element(FILE *fd, int inst)
else if(token[0]=='@' && token[1]=='@') { /* recognize single pins 15112003 */
for(i=0;iinst[inst].ptr + xctx->sym)->rect[PINLAYER][i].prop_ptr,"name",0),
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][i].prop_ptr,"name",0),
token+2
)
) {
@@ -2760,7 +2761,7 @@ void print_tedax_element(FILE *fd, int inst)
/* get pin_attr from instance pin attribute string */
if(!pin_attr_value) {
my_strdup(_ALLOC_ID_, &pin_attr_value,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][n].prop_ptr, pin_attr, 0));
}
}
/* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin */
@@ -2866,13 +2867,13 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr, fmt_attr, 2));
/* get netlist format rule from symbol */
if(!xctx->tok_size)
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, fmt_attr, 2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, fmt_attr, 2));
/* allow format string override in instance */
if(!xctx->tok_size && strcmp(fmt_attr, "verilog_format") )
my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->inst[inst].prop_ptr, "verilog_format", 2));
/* get netlist format rule from symbol */
if(!xctx->tok_size && strcmp(fmt_attr, "verilog_format"))
- my_strdup(_ALLOC_ID_, &format, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "verilog_format", 2));
+ my_strdup(_ALLOC_ID_, &format, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "verilog_format", 2));
if((name==NULL) || (format==NULL) ) {
my_free(_ALLOC_ID_, &template);
my_free(_ALLOC_ID_, &name);
@@ -3021,7 +3022,7 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
/* get pin_attr from instance pin attribute string */
if(!pin_attr_value) {
my_strdup(_ALLOC_ID_, &pin_attr_value,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][n].prop_ptr, pin_attr, 0));
}
}
/* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin */
@@ -3150,13 +3151,13 @@ void print_verilog_element(FILE *fd, int inst)
fmt = get_tok_value(xctx->inst[inst].prop_ptr, fmt_attr, 2);
/* get netlist format rule from symbol */
if(!xctx->tok_size)
- fmt = get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, fmt_attr, 2);
+ fmt = get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, fmt_attr, 2);
/* allow format string override in instance */
if(!xctx->tok_size && strcmp(fmt_attr, "verilog_format") )
fmt = get_tok_value(xctx->inst[inst].prop_ptr, "verilog_format", 2);
/* get netlist format rule from symbol */
if(!xctx->tok_size && strcmp(fmt_attr, "verilog_format"))
- fmt = get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "verilog_format", 2);
+ fmt = get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "verilog_format", 2);
if(fmt[0]) {
print_verilog_primitive(fd, inst);
@@ -3170,11 +3171,11 @@ void print_verilog_element(FILE *fd, int inst)
return;
}
/* verilog_extra is the list of additional nodes passed as attributes */
- my_strdup(_ALLOC_ID_, &v_extra, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "verilog_extra", 0));
+ my_strdup(_ALLOC_ID_, &v_extra, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "verilog_extra", 0));
/* extra is the list of attributes NOT to consider as instance parameters */
- my_strdup(_ALLOC_ID_, &extra, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "extra", 0));
+ my_strdup(_ALLOC_ID_, &extra, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "extra", 0));
my_strdup(_ALLOC_ID_, &verilogprefix,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "verilogprefix", 0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr, "verilogprefix", 0));
if(verilogprefix) {
my_strdup(_ALLOC_ID_, &symname, verilogprefix);
my_strcat(_ALLOC_ID_, &symname, get_sym_name(inst, 0, 0, 0));
@@ -3186,7 +3187,7 @@ void print_verilog_element(FILE *fd, int inst)
no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
/* 20080915 use generic_type property to decide if some properties are strings, see later */
- my_strdup(_ALLOC_ID_, &generic_type, get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr,"generic_type",0));
+ my_strdup(_ALLOC_ID_, &generic_type, get_tok_value(xctx->sym[xctx->inst[inst].ptr].prop_ptr,"generic_type",0));
s=xctx->inst[inst].prop_ptr;
/* print instance subckt */
dbg(2, "print_verilog_element(): printing inst name & subcircuit name\n");
@@ -3386,13 +3387,13 @@ const char *net_name(int i, int j, int *multip, int hash_prefix_unnamed_net, int
my_snprintf(str_node, S(str_node), "%s", (xctx->inst[i].node[j])+1 );
}
expandlabel(
- get_tok_value( (xctx->inst[i].ptr + xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0), multip);
+ get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][j].prop_ptr,"name",0), multip);
return expandlabel(str_node, &tmp);
}
else
{
expandlabel(
- get_tok_value( (xctx->inst[i].ptr + xctx->sym)->rect[PINLAYER][j].prop_ptr,"name",0), multip);
+ get_tok_value(xctx->sym[xctx->inst[i].ptr].rect[PINLAYER][j].prop_ptr,"name",0), multip);
return expandlabel(xctx->inst[i].node[j], &tmp);
}
}
@@ -3541,7 +3542,7 @@ static char *get_pin_attr(const char *token, int inst, int engineering)
/* get pin_attr from instance pin attribute string */
if(!pin_attr_value) {
my_strdup(_ALLOC_ID_, &pin_attr_value,
- get_tok_value((xctx->inst[inst].ptr + xctx->sym)->rect[PINLAYER][n].prop_ptr, pin_attr, 0));
+ get_tok_value(xctx->sym[xctx->inst[inst].ptr].rect[PINLAYER][n].prop_ptr, pin_attr, 0));
}
}
/* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin
@@ -4305,7 +4306,7 @@ const char *translate(int inst, const char* s)
} else if(inst >= 0) {
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
if(!xctx->tok_size && xctx->inst[inst].ptr >= 0) {
- value=get_tok_value((xctx->inst[inst].ptr + xctx->sym)->templ, token+1, 0);
+ value=get_tok_value(xctx->sym[xctx->inst[inst].ptr].templ, token+1, 0);
}
if(!xctx->tok_size) { /* above lines did not find a value for token */
if(token[0] =='%') {
diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c
index 2a66227c..4911225f 100644
--- a/src/verilog_netlist.c
+++ b/src/verilog_netlist.c
@@ -135,9 +135,9 @@ int global_verilog_netlist(int global) /* netlister driver */
my_strdup(_ALLOC_ID_, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if( type && (strcmp(type,"timescale")==0 || strcmp(type,"verilog_preprocessor")==0) )
{
- str_tmp = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr , fmt_attr, 2);
+ str_tmp = get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr , fmt_attr, 2);
if(!xctx->tok_size && strcmp(fmt_attr, "verilog_format"))
- str_tmp = get_tok_value( (xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "verilog_format", 2);
+ str_tmp = get_tok_value(xctx->sym[xctx->inst[i].ptr].prop_ptr, "verilog_format", 2);
my_strdup(_ALLOC_ID_, &tmp_string, str_tmp);
fprintf(fd, "%s\n", str_tmp ? translate(i, tmp_string) : "");
@@ -479,9 +479,9 @@ int verilog_block_netlist(FILE *fd, int i)
my_strdup(_ALLOC_ID_, &type,(xctx->inst[j].ptr+ xctx->sym)->type);
if( type && ( strcmp(type,"timescale")==0 || strcmp(type,"verilog_preprocessor")==0) )
{
- str_tmp = get_tok_value( (xctx->inst[j].ptr+ xctx->sym)->prop_ptr, fmt_attr, 2);
+ str_tmp = get_tok_value(xctx->sym[xctx->inst[j].ptr].prop_ptr, fmt_attr, 2);
if(!xctx->tok_size && strcmp(fmt_attr, "verilog_format"))
- str_tmp = get_tok_value( (xctx->inst[j].ptr+ xctx->sym)->prop_ptr, "verilog_format", 2);
+ str_tmp = get_tok_value(xctx->sym[xctx->inst[j].ptr].prop_ptr, "verilog_format", 2);
my_strdup(_ALLOC_ID_, &tmp_string, str_tmp);
fprintf(fd, "%s\n", str_tmp ? translate(j, tmp_string) : "");
}
From aeb57781a8ab387218092f02001db9d651e38f05 Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 16:14:24 +0100
Subject: [PATCH 4/9] fix some c89 violations (warnings)
---
scconfig/hooks.c | 12 ++++++------
src/save.c | 9 +++++----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/scconfig/hooks.c b/scconfig/hooks.c
index 0abf7148..0a2e7d22 100644
--- a/scconfig/hooks.c
+++ b/scconfig/hooks.c
@@ -253,12 +253,12 @@ int hook_detect_target()
append("cc/cflags", " ");
append("cc/cflags", get("cc/argstd/Wall"));
}
- /*
- * if (require("cc/argstd/std_c89", 0, 0) == 0) {
- * append("cc/cflags", " ");
- * append("cc/cflags", get("cc/argstd/std_c89"));
- * }
- */
+
+ if (require("cc/argstd/std_c89", 0, 0) == 0) {
+ append("cc/cflags", " ");
+ append("cc/cflags", get("cc/argstd/std_c89"));
+ }
+
if (require("cc/argstd/pedantic", 0, 0) == 0) {
append("cc/cflags", " ");
append("cc/cflags", get("cc/argstd/pedantic"));
diff --git a/src/save.c b/src/save.c
index bd211510..4bff253d 100644
--- a/src/save.c
+++ b/src/save.c
@@ -1551,15 +1551,16 @@ int raw_get_pos(const char *node, double value, int dset, int from_start, int to
if(idx >= 0) {
double vx;
int start, end;
- int lastpoint = raw->npoints[dset] - 1;
+ int sign, lastpoint = raw->npoints[dset] - 1;
+ double vstart, vend;
start = from_start >= 0 ? from_start : 0;
end = to_end >= 0 ? to_end : lastpoint;
if(start > lastpoint) start = lastpoint;
if(end > lastpoint) end = lastpoint;
- double vstart = get_raw_value(dset, idx, start);
- double vend = get_raw_value(dset, idx, end);
- int sign = (vend > vstart) ? 1 : -1;
+ vstart = get_raw_value(dset, idx, start);
+ vend = get_raw_value(dset, idx, end);
+ sign = (vend > vstart) ? 1 : -1;
if( sign * value >= sign * vstart && sign * value <= sign * vend) {
while(1) {
x = (start + end ) / 2;
From 1d5ff211303497ad4de00683121ed226ebad5eea Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 16:51:20 +0100
Subject: [PATCH 5/9] get_sch_from_sym() fix detection of empty instance
`schematic` attribute
---
src/actions.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/actions.c b/src/actions.c
index aaf181e5..46d72e06 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -2092,7 +2092,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback)
dbg(1, "get_sch_from_sym(): symbol %s inst=%d web_url=%d\n", sym->name, inst, web_url);
if(inst >= 0) {
/* resolve schematic=generator.tcl( @n ) where n=11 is defined in instance attrs */
- my_strdup2(_ALLOC_ID_, &str_tmp,
+ my_strdup(_ALLOC_ID_, &str_tmp,
translate3(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), 1,
xctx->inst[inst].prop_ptr, NULL, NULL));
}
From a0da5c7b51e0a5f48d5b11778dc9d317b1f9ae63 Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 17:14:13 +0100
Subject: [PATCH 6/9] fix resolution of symbol references like:
symbolgen.tcl(buf), when descending into symbol correctly recognize generator
and descend into generated symbol
---
src/save.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/save.c b/src/save.c
index 4bff253d..f103e049 100644
--- a/src/save.c
+++ b/src/save.c
@@ -3446,7 +3446,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler
int generator = 0;
if(is_generator(fname)) generator = 1;
my_strncpy(name, fname, S(name));
- dbg(1, "load_schematic(): fname=%s\n", fname);
+ dbg(0, "load_schematic(): fname=%s\n", fname);
/* remote web object specified */
if(is_from_web(fname) && xschem_web_dirname[0]) {
/* download into ${XSCHEM_TMP_DIR}/xschem_web */
@@ -5152,7 +5152,11 @@ void descend_symbol(void)
}
if(!sympath || stat(sympath, &buf)) { /* not found */
dbg(1, "descend_symbol: not found: %s\n", sympath);
- my_strdup2(_ALLOC_ID_, &sympath, abs_sym_path(tcl_hook2(name), ""));
+ if(is_generator(name)) {
+ my_strdup2(_ALLOC_ID_, &sympath, tcl_hook2(name));
+ } else {
+ my_strdup2(_ALLOC_ID_, &sympath, abs_sym_path(tcl_hook2(name), ""));
+ }
}
dbg(1, "descend_symbol(): name=%s, sympath=%s, dirname=%s\n", name, sympath, xctx->current_dirname);
++xctx->currsch; /* increment level counter */
From be76009a3c8dee25d1048ecc24476ebb0458c607 Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 17:15:53 +0100
Subject: [PATCH 7/9] remove dbg msg
---
src/save.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/save.c b/src/save.c
index f103e049..0b0bd551 100644
--- a/src/save.c
+++ b/src/save.c
@@ -3446,7 +3446,7 @@ int load_schematic(int load_symbols, const char *fname, int reset_undo, int aler
int generator = 0;
if(is_generator(fname)) generator = 1;
my_strncpy(name, fname, S(name));
- dbg(0, "load_schematic(): fname=%s\n", fname);
+ dbg(1, "load_schematic(): fname=%s\n", fname);
/* remote web object specified */
if(is_from_web(fname) && xschem_web_dirname[0]) {
/* download into ${XSCHEM_TMP_DIR}/xschem_web */
From 69ddd2966c5b939378fd8b422e99ca388688ec17 Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Fri, 10 Jan 2025 17:40:16 +0100
Subject: [PATCH 8/9] get_sym_name(): use with_quotes=6 in extraction of
schematic attribute as done in get_additional_symbols() and
get_sch_from_sym()
---
src/actions.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index 46d72e06..bdc3ac16 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1787,7 +1787,7 @@ const char *get_sym_name(int inst, int ndir, int ext, int abs_path)
const char *sym, *sch;
/* instance based symbol selection */
- sch = tcl_hook2(str_replace(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 2), "@symname",
+ sch = tcl_hook2(str_replace(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), "@symname",
get_cell(xctx->inst[inst].name, 0), '\\', -1));
if(xctx->tok_size) { /* token exists */
@@ -1966,7 +1966,7 @@ void get_additional_symbols(int what)
my_strdup(_ALLOC_ID_, &verilog_sym_def, get_tok_value(xctx->inst[i].prop_ptr,"verilog_sym_def",4));
my_strdup(_ALLOC_ID_, &vhdl_sym_def, get_tok_value(xctx->inst[i].prop_ptr,"vhdl_sym_def",4));
- dbg(1, "schematic=%s\n", get_tok_value(xctx->inst[i].prop_ptr,"schematic",2));
+ dbg(1, "schematic=%s\n", get_tok_value(xctx->inst[i].prop_ptr,"schematic",6));
/* resolve schematic=generator.tcl( @n ) where n=11 is defined in instance attrs */
my_strdup2(_ALLOC_ID_, &sch,
translate3(get_tok_value(xctx->inst[i].prop_ptr,"schematic", 6), 1,
@@ -2096,7 +2096,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback)
translate3(get_tok_value(xctx->inst[inst].prop_ptr,"schematic", 6), 1,
xctx->inst[inst].prop_ptr, NULL, NULL));
}
- if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 2));
+ if(!str_tmp) my_strdup2(_ALLOC_ID_, &str_tmp, get_tok_value(sym->prop_ptr, "schematic", 6));
if(str_tmp[0]) { /* schematic attribute in symbol or instance was given */
/* @symname in schematic attribute will be replaced with symbol name */
my_strdup2(_ALLOC_ID_, &sch, tcl_hook2(str_replace(str_tmp, "@symname",
From 9d54269d25e4093c4a4ec2e9045d7d61f0c5c93f Mon Sep 17 00:00:00 2001
From: stefan schippers
Date: Sat, 11 Jan 2025 01:34:41 +0100
Subject: [PATCH 9/9] doc updates (@spice_get_node)
---
doc/xschem_man/symbol_property_syntax.html | 30 +++++++++++++++++++++-
src/token.c | 21 +++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/doc/xschem_man/symbol_property_syntax.html b/doc/xschem_man/symbol_property_syntax.html
index adb6f3cc..d0ca082c 100644
--- a/doc/xschem_man/symbol_property_syntax.html
+++ b/doc/xschem_man/symbol_property_syntax.html
@@ -568,7 +568,10 @@ verilog_format="xnor #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );"
This expands to the net that connect to symbol pin named pin. This substitution
takes place only when producing a netlist (Spice, Verilog, VHDL, tEDAx) so it is allowed to use this
value only in format,vhdl_format, tedax_format or verilog_format
- attributes (see Netlisting slide)
+ attributes (see Netlisting slide)
+ The @#pin attribute is expanded to ?m net where m is the pin multiplicity and
+ net is the name of the net attached to the symbol pin. This information is needed
+ by the xschem netlister.
@#n
This expands to the net that connect to symbol pin at position n in the XSCHEM internal storage. This substitution
@@ -577,6 +580,10 @@ verilog_format="xnor #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );"
attributes (see Netlisting slide)
This method of accessing a net that connects to a pin is much faster than previous one since XSCHEM does not need to
loop through symbol pin names looking for a match.
+ The @#n attribute is expanded to ?m net where m is the n-th pin multiplicity and
+ net is the name of the net attached to the symbol cwn-thpin pin. This information is needed
+ by the xschem netlister.
+
Example: @#2: return net name that connects to the third pin of the symbol (position 2).
@#n:pin_attribute
@@ -612,6 +619,27 @@ verilog_format="xnor #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );"
sequence number n, extracted from simulation raw file (operating point or
cursor b position)
+ @spice_get_node spice_node
+
+ spice_node Will be replaced with the Spice simulated value for that node.
+ Examples:
+ Id=@spice_get_node i(\@m.@path@spiceprefix@name\.msky130_fd_pr__@model\[id])
+ will translate to:
+ Id=6.6177u
+ and:
+ Id=@spice_get_node i(\@m.@path@spiceprefix@name\.msky130_fd_pr__@model\[id]) A
+ will translate to:
+ Id=6.6177uA
+ note the required separator spaces around the spice node. Spaces are used here as
+ separators since spice nodes don't allow spaces.
+ escapes are used for 2 reasons:
+ mark a @ as a literal character instead of a the start of a @var token to be substituted
+ mark the end of a @var, like for example @var\iable. In this case @var will
+ be substituted by xschem instead of @variable.
+ Caveats: only one @spice_get_node is allowed in a string for now.
+
+
+
@sch_last_modified
this indicates the last modification time of the .sch file of the symbol.
diff --git a/src/token.c b/src/token.c
index 6a2bf6e2..c4c54900 100644
--- a/src/token.c
+++ b/src/token.c
@@ -3646,6 +3646,27 @@ static char *get_pin_attr(const char *token, int inst, int engineering)
return value;
}
+/* This routine processes the entire string returned by translate, looks
+ * for "@spice_get_node " patterns and replaces with the
+ * Spice simulated value for that node.
+ * the format is "some_text@spice_get_node some_additional_text"
+ * Examples:
+ * Id=@spice_get_node i(\@m.@path@spiceprefix@name\.msky130_fd_pr__@model\[id])
+ * will translate to:
+ * Id=6.6177u
+ * Id=@spice_get_node i(\@m.@path@spiceprefix@name\.msky130_fd_pr__@model\[id]) A
+ * will translate to:
+ * Id=6.6177uA
+ * note the required separator spaces around the spice node. Spaces are used here as
+ * separators since spice nodes don't allow spaces.
+ * escapes are used for 2 reasons:
+ * mark a @ as a literal character instead of a the start of a @var token to be substituted
+ * mark the end of a @var, like for example @var\iable. In this case @var will
+ * be substituted by xschem instead of @variable
+ *
+ * caveats: only one @spice_get_node is allowed in a string for now.
+ */
+
const char *spice_get_node(const char *token)
{
const char *pos;