add abs_path parameter to get_sym_name() for more flexibility
This commit is contained in:
parent
5ce1f01f43
commit
4e236750ed
|
|
@ -1769,7 +1769,7 @@ void launcher(void)
|
||||||
* or get it from inst[inst].name.
|
* or get it from inst[inst].name.
|
||||||
* perform tcl substitution of the result and
|
* perform tcl substitution of the result and
|
||||||
* return the last 'ndir' directory components of symbol reference. */
|
* return the last 'ndir' directory components of symbol reference. */
|
||||||
const char *get_sym_name(int inst, int ndir, int ext)
|
const char *get_sym_name(int inst, int ndir, int ext, int abs_path)
|
||||||
{
|
{
|
||||||
const char *sym, *sch;
|
const char *sym, *sch;
|
||||||
|
|
||||||
|
|
@ -1778,10 +1778,16 @@ const char *get_sym_name(int inst, int ndir, int ext)
|
||||||
get_cell(xctx->inst[inst].name, 0), '\\'));
|
get_cell(xctx->inst[inst].name, 0), '\\'));
|
||||||
|
|
||||||
if(xctx->tok_size) { /* token exists */
|
if(xctx->tok_size) { /* token exists */
|
||||||
sym = add_ext(rel_sym_path(sch), ".sym");
|
if(abs_path)
|
||||||
|
sym = abs_sym_path(sch, ".sym");
|
||||||
|
else
|
||||||
|
sym = add_ext(rel_sym_path(sch), ".sym");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sym = tcl_hook2(xctx->inst[inst].name);
|
if(abs_path)
|
||||||
|
sym = abs_sym_path(tcl_hook2(xctx->inst[inst].name), "");
|
||||||
|
else
|
||||||
|
sym = tcl_hook2(xctx->inst[inst].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ext) return get_cell_w_ext(sym, ndir);
|
if(ext) return get_cell_w_ext(sym, ndir);
|
||||||
|
|
@ -1977,7 +1983,7 @@ void get_additional_symbols(int what)
|
||||||
|
|
||||||
my_strdup2(_ALLOC_ID_, &templ, get_tok_value(symptr->prop_ptr, "template", 0));
|
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=", abs_sym_path(get_sym_name(i, 9999, 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,
|
templ,
|
||||||
|
|
|
||||||
|
|
@ -1761,7 +1761,7 @@ int sym_vs_sch_pins(int all)
|
||||||
statusmsg(str,2);
|
statusmsg(str,2);
|
||||||
err |= 1;
|
err |= 1;
|
||||||
for(j = 0; j < xctx->instances; ++j) {
|
for(j = 0; j < xctx->instances; ++j) {
|
||||||
if(!xctx->x_strcmp(get_sym_name(j, 9999, 1), xctx->sym[i].name)) {
|
if(!xctx->x_strcmp(get_sym_name(j, 9999, 1, 0), xctx->sym[i].name)) {
|
||||||
xctx->inst[j].color = -PINLAYER;
|
xctx->inst[j].color = -PINLAYER;
|
||||||
xctx->hilight_nets=1;
|
xctx->hilight_nets=1;
|
||||||
}
|
}
|
||||||
|
|
@ -1780,7 +1780,7 @@ int sym_vs_sch_pins(int all)
|
||||||
err |= 1;
|
err |= 1;
|
||||||
for(j = 0; j < xctx->instances; ++j) {
|
for(j = 0; j < xctx->instances; ++j) {
|
||||||
dbg(1, "inst.name=%s, sym.name=%s\n", tcl_hook2(xctx->inst[j].name), xctx->sym[i].name);
|
dbg(1, "inst.name=%s, sym.name=%s\n", tcl_hook2(xctx->inst[j].name), xctx->sym[i].name);
|
||||||
if(!xctx->x_strcmp(get_sym_name(j, 9999, 1), xctx->sym[i].name)) {
|
if(!xctx->x_strcmp(get_sym_name(j, 9999, 1, 0), xctx->sym[i].name)) {
|
||||||
xctx->inst[j].color = -PINLAYER;
|
xctx->inst[j].color = -PINLAYER;
|
||||||
xctx->hilight_nets=1;
|
xctx->hilight_nets=1;
|
||||||
}
|
}
|
||||||
|
|
@ -1814,7 +1814,7 @@ int sym_vs_sch_pins(int all)
|
||||||
statusmsg(str,2);
|
statusmsg(str,2);
|
||||||
err |= 1;
|
err |= 1;
|
||||||
for(j = 0; j < xctx->instances; ++j) {
|
for(j = 0; j < xctx->instances; ++j) {
|
||||||
if(!xctx->x_strcmp(get_sym_name(j, 9999, 1), xctx->sym[i].name)) {
|
if(!xctx->x_strcmp(get_sym_name(j, 9999, 1, 0), xctx->sym[i].name)) {
|
||||||
xctx->inst[j].color = -PINLAYER;
|
xctx->inst[j].color = -PINLAYER;
|
||||||
xctx->hilight_nets=1;
|
xctx->hilight_nets=1;
|
||||||
}
|
}
|
||||||
|
|
@ -1838,7 +1838,7 @@ int sym_vs_sch_pins(int all)
|
||||||
statusmsg(str,2);
|
statusmsg(str,2);
|
||||||
err |= 1;
|
err |= 1;
|
||||||
for(k = 0; k < xctx->instances; ++k) {
|
for(k = 0; k < xctx->instances; ++k) {
|
||||||
if(!xctx->x_strcmp(get_sym_name(k, 9999, 1), xctx->sym[i].name)) {
|
if(!xctx->x_strcmp(get_sym_name(k, 9999, 1, 0), xctx->sym[i].name)) {
|
||||||
xctx->inst[k].color = -PINLAYER;
|
xctx->inst[k].color = -PINLAYER;
|
||||||
xctx->hilight_nets=1;
|
xctx->hilight_nets=1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
src/token.c
42
src/token.c
|
|
@ -1003,18 +1003,18 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symref")==0)
|
else if(strcmp(token,"@symref")==0)
|
||||||
{
|
{
|
||||||
const char *s = get_sym_name(inst, 9999, 1);
|
const char *s = get_sym_name(inst, 9999, 1, 0);
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
|
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0, 0)));
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"@symname_ext")==0)
|
else if (strcmp(token,"@symname_ext")==0)
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1, 0)));
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
|
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
|
||||||
|
|
@ -1468,9 +1468,9 @@ void print_vhdl_element(FILE *fd, int inst)
|
||||||
/* print instance name and subckt */
|
/* print instance name and subckt */
|
||||||
dbg(2, "print_vhdl_element(): printing inst name & subcircuit name\n");
|
dbg(2, "print_vhdl_element(): printing inst name & subcircuit name\n");
|
||||||
if( (lab = expandlabel(name, &tmp)) != NULL)
|
if( (lab = expandlabel(name, &tmp)) != NULL)
|
||||||
fprintf(fd, "%d %s : %s\n", tmp, lab, sanitize(translate(inst, get_sym_name(inst, 0, 0))) );
|
fprintf(fd, "%d %s : %s\n", tmp, lab, sanitize(translate(inst, get_sym_name(inst, 0, 0, 0))) );
|
||||||
else /* name in some strange format, probably an error */
|
else /* name in some strange format, probably an error */
|
||||||
fprintf(fd, "1 %s : %s\n", name, sanitize(translate(inst, get_sym_name(inst, 0, 0))) );
|
fprintf(fd, "1 %s : %s\n", name, sanitize(translate(inst, get_sym_name(inst, 0, 0, 0))) );
|
||||||
dbg(2, "print_vhdl_element(): printing generics passed as properties\n");
|
dbg(2, "print_vhdl_element(): printing generics passed as properties\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1845,7 +1845,7 @@ static int has_included_subcircuit(int inst, int symbol, char **result)
|
||||||
my_strdup2(_ALLOC_ID_, &symname, xctx->sym[symbol].name);
|
my_strdup2(_ALLOC_ID_, &symname, xctx->sym[symbol].name);
|
||||||
}
|
}
|
||||||
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=", abs_sym_path(get_sym_name(inst, 9999, 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,
|
templ,
|
||||||
symname_attr);
|
symname_attr);
|
||||||
|
|
@ -2240,20 +2240,20 @@ int print_spice_element(FILE *fd, int inst)
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symref")==0)
|
else if(strcmp(token,"@symref")==0)
|
||||||
{
|
{
|
||||||
const char *s = get_sym_name(inst, 9999, 1);
|
const char *s = get_sym_name(inst, 9999, 1, 0);
|
||||||
/* result_pos += my_snprintf(result + result_pos, tmp, "%s", s); */
|
/* result_pos += my_snprintf(result + result_pos, tmp, "%s", s); */
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"@symname")==0) /* of course symname must not be present in attributes */
|
else if (strcmp(token,"@symname")==0) /* of course symname must not be present in attributes */
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0, 0)));
|
||||||
/* result_pos += my_snprintf(result + result_pos, tmp, "%s", s); */
|
/* result_pos += my_snprintf(result + result_pos, tmp, "%s", s); */
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
/* fputs(s,fd); */
|
/* fputs(s,fd); */
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"@symname_ext")==0) /* of course symname_ext must not be present in attributes */
|
else if (strcmp(token,"@symname_ext")==0) /* of course symname_ext must not be present in attributes */
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1, 0)));
|
||||||
/* result_pos += my_snprintf(result + result_pos, tmp, "%s", s); */
|
/* result_pos += my_snprintf(result + result_pos, tmp, "%s", s); */
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
/* fputs(s,fd); */
|
/* fputs(s,fd); */
|
||||||
|
|
@ -2533,7 +2533,7 @@ void print_tedax_element(FILE *fd, int inst)
|
||||||
Int_hashtable table={NULL, 0};
|
Int_hashtable table={NULL, 0};
|
||||||
subcircuit = 1;
|
subcircuit = 1;
|
||||||
fprintf(fd, "__subcircuit__ %s %s\n",
|
fprintf(fd, "__subcircuit__ %s %s\n",
|
||||||
sanitize(translate(inst, get_sym_name(inst, 0, 0))), xctx->inst[inst].instname);
|
sanitize(translate(inst, get_sym_name(inst, 0, 0, 0))), xctx->inst[inst].instname);
|
||||||
int_hash_init(&table, 37);
|
int_hash_init(&table, 37);
|
||||||
for(i=0;i<no_of_pins; ++i) {
|
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_, &net, net_name(inst,i, &net_mult, 0, 1));
|
||||||
|
|
@ -2665,18 +2665,18 @@ void print_tedax_element(FILE *fd, int inst)
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symref")==0)
|
else if(strcmp(token,"@symref")==0)
|
||||||
{
|
{
|
||||||
const char *s = get_sym_name(inst, 9999, 1);
|
const char *s = get_sym_name(inst, 9999, 1, 0);
|
||||||
fputs(s, fd);
|
fputs(s, fd);
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
|
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0, 0)));
|
||||||
fputs(s, fd);
|
fputs(s, fd);
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"@symname_ext")==0)
|
else if (strcmp(token,"@symname_ext")==0)
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1, 0)));
|
||||||
fputs(s, fd);
|
fputs(s, fd);
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
|
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
|
||||||
|
|
@ -2927,18 +2927,18 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symref")==0)
|
else if(strcmp(token,"@symref")==0)
|
||||||
{
|
{
|
||||||
const char *s = get_sym_name(inst, 9999, 1);
|
const char *s = get_sym_name(inst, 9999, 1, 0);
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
|
else if(strcmp(token,"@symname")==0) /* of course symname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0, 0)));
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"@symname_ext")==0)
|
else if (strcmp(token,"@symname_ext")==0)
|
||||||
{
|
{
|
||||||
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1)));
|
const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 1, 0)));
|
||||||
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
my_mstrcat(_ALLOC_ID_, &result, s, NULL);
|
||||||
}
|
}
|
||||||
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
|
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
|
||||||
|
|
@ -3162,9 +3162,9 @@ void print_verilog_element(FILE *fd, int inst)
|
||||||
get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "verilogprefix", 0));
|
get_tok_value((xctx->inst[inst].ptr + xctx->sym)->prop_ptr, "verilogprefix", 0));
|
||||||
if(verilogprefix) {
|
if(verilogprefix) {
|
||||||
my_strdup(_ALLOC_ID_, &symname, verilogprefix);
|
my_strdup(_ALLOC_ID_, &symname, verilogprefix);
|
||||||
my_strcat(_ALLOC_ID_, &symname, get_sym_name(inst, 0, 0));
|
my_strcat(_ALLOC_ID_, &symname, get_sym_name(inst, 0, 0, 0));
|
||||||
} else {
|
} else {
|
||||||
my_strdup(_ALLOC_ID_, &symname, get_sym_name(inst, 0, 0));
|
my_strdup(_ALLOC_ID_, &symname, get_sym_name(inst, 0, 0, 0));
|
||||||
}
|
}
|
||||||
my_free(_ALLOC_ID_, &verilogprefix);
|
my_free(_ALLOC_ID_, &verilogprefix);
|
||||||
my_strdup(_ALLOC_ID_, &template, (xctx->inst[inst].ptr + xctx->sym)->templ);
|
my_strdup(_ALLOC_ID_, &template, (xctx->inst[inst].ptr + xctx->sym)->templ);
|
||||||
|
|
@ -3709,14 +3709,14 @@ const char *translate(int inst, const char* s)
|
||||||
memcpy(result+result_pos, instname, tmp+1);
|
memcpy(result+result_pos, instname, tmp+1);
|
||||||
result_pos+=tmp;
|
result_pos+=tmp;
|
||||||
} else if(inst >= 0 && strcmp(token,"@symref")==0) {
|
} else if(inst >= 0 && strcmp(token,"@symref")==0) {
|
||||||
tmp_sym_name = get_sym_name(inst, 9999, 1);
|
tmp_sym_name = get_sym_name(inst, 9999, 1, 0);
|
||||||
tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";
|
tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";
|
||||||
tmp=strlen(tmp_sym_name);
|
tmp=strlen(tmp_sym_name);
|
||||||
STR_ALLOC(&result, tmp + result_pos, &size);
|
STR_ALLOC(&result, tmp + result_pos, &size);
|
||||||
memcpy(result+result_pos,tmp_sym_name, tmp+1);
|
memcpy(result+result_pos,tmp_sym_name, tmp+1);
|
||||||
result_pos+=tmp;
|
result_pos+=tmp;
|
||||||
} else if(inst >= 0 && strcmp(token,"@symname")==0) {
|
} else if(inst >= 0 && strcmp(token,"@symname")==0) {
|
||||||
tmp_sym_name = get_sym_name(inst, 0, 0);
|
tmp_sym_name = get_sym_name(inst, 0, 0, 0);
|
||||||
tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";
|
tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";
|
||||||
tmp=strlen(tmp_sym_name);
|
tmp=strlen(tmp_sym_name);
|
||||||
STR_ALLOC(&result, tmp + result_pos, &size);
|
STR_ALLOC(&result, tmp + result_pos, &size);
|
||||||
|
|
@ -3729,7 +3729,7 @@ const char *translate(int inst, const char* s)
|
||||||
memcpy(result+result_pos, path, tmp+1);
|
memcpy(result+result_pos, path, tmp+1);
|
||||||
result_pos+=tmp;
|
result_pos+=tmp;
|
||||||
} else if(inst >= 0 && strcmp(token,"@symname_ext")==0) {
|
} else if(inst >= 0 && strcmp(token,"@symname_ext")==0) {
|
||||||
tmp_sym_name = get_sym_name(inst, 0, 1);
|
tmp_sym_name = get_sym_name(inst, 0, 1, 0);
|
||||||
tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";
|
tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";
|
||||||
tmp=strlen(tmp_sym_name);
|
tmp=strlen(tmp_sym_name);
|
||||||
STR_ALLOC(&result, tmp + result_pos, &size);
|
STR_ALLOC(&result, tmp + result_pos, &size);
|
||||||
|
|
|
||||||
|
|
@ -1520,7 +1520,7 @@ extern char *read_line(FILE *fp, int dbg_level);
|
||||||
extern void read_record(int firstchar, FILE *fp, int dbg_level);
|
extern void read_record(int firstchar, FILE *fp, int dbg_level);
|
||||||
extern void create_sch_from_sym(void);
|
extern void create_sch_from_sym(void);
|
||||||
extern void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback);
|
extern void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback);
|
||||||
extern const char *get_sym_name(int inst, int ndir, int ext);
|
extern const char *get_sym_name(int inst, int ndir, int ext, int abs_path);
|
||||||
extern void toggle_ignore(void);
|
extern void toggle_ignore(void);
|
||||||
extern void get_additional_symbols(int what);
|
extern void get_additional_symbols(int what);
|
||||||
extern int descend_schematic(int instnumber, int fallback, int alert);
|
extern int descend_schematic(int instnumber, int fallback, int alert);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue