reduce some pointer indirections to array subscripts (readability)

This commit is contained in:
stefan schippers 2025-01-10 16:00:47 +01:00
parent 0a3fd95e06
commit 59e7872f67
10 changed files with 69 additions and 66 deletions

View File

@ -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));

View File

@ -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 */
}
}

View File

@ -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;

View File

@ -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]);
}

View File

@ -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

View File

@ -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;p<no_of_pins;p++) {
if(!strcmp(get_tok_value((xctx->inst[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;p<no_of_pins;p++) {
const char *pin;
pin = get_tok_value((xctx->inst[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;p<no_of_pins;p++) {
const char *pin;
pin = get_tok_value((xctx->inst[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 */

View File

@ -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);
}

View File

@ -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");

View File

@ -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;i<no_of_pins; ++i) {
my_strdup2(_ALLOC_ID_, &net, net_name(inst,i, &net_mult, 0, 1));
my_strdup2(_ALLOC_ID_, &pinname,
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));
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;i<no_of_pins; ++i) {
if(!strcmp(
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),
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] =='%') {

View File

@ -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) : "<NULL>");
@ -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) : "<NULL>");
}