added @topschname predefined attribute that expands to the toplevel schematic name (no path) with no .sch extension

This commit is contained in:
Stefan Frederik 2022-08-10 01:45:07 +02:00
parent bd35e177f1
commit 0e25935254
2 changed files with 39 additions and 0 deletions

View File

@ -458,6 +458,11 @@ verilog_format="xnor #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );"
this expands to the name of the schematic (.sch) <b>containing</b> this expands to the name of the schematic (.sch) <b>containing</b>
the symbol instance. the symbol instance.
</p> </p>
<li><kbd>@topschname</kbd></li>
<p>
this expands to the name of the tol level schematic (.sch) <b>containing</b>
the symbol instance.
</p>
<li><kbd>@prop_ptr</kbd></li> <li><kbd>@prop_ptr</kbd></li>
<p> <p>
this expandes to the <b>entire</b> property string passed to the component. this expandes to the <b>entire</b> property string passed to the component.

View File

@ -829,6 +829,12 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
/* fputs(xctx->sch[xctx->currsch],fd); */ /* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd); fputs(xctx->current_name, fd);
} }
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
topsch = get_trailing_path(xctx->sch[0], 0, 1);
fputs(topsch, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */ else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */ /* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */ { /* and node number: m1 n1 m2 n2 .... */
@ -1859,6 +1865,15 @@ int print_spice_element(FILE *fd, int inst)
result_pos += my_snprintf(result + result_pos, tmp, "%s", s); result_pos += my_snprintf(result + result_pos, tmp, "%s", s);
/* fputs(s,fd); */ /* fputs(s,fd); */
} }
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
topsch = get_trailing_path(xctx->sch[0], 0, 1);
tmp = strlen(topsch) + 100 ; /* always make room for some extra chars
* so 1-char writes to result do not need reallocs */
STR_ALLOC(&result, tmp + result_pos, &size);
result_pos += my_snprintf(result + result_pos, tmp, "%s", topsch);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present in attributes */ else if(strcmp(token,"@schname")==0) /* of course schname must not be present in attributes */
{ {
tmp = strlen(xctx->current_name) +100 ; /* always make room for some extra chars tmp = strlen(xctx->current_name) +100 ; /* always make room for some extra chars
@ -2191,6 +2206,12 @@ void print_tedax_element(FILE *fd, int inst)
/* fputs(xctx->sch[xctx->currsch],fd); */ /* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd); fputs(xctx->current_name, fd);
} }
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
topsch = get_trailing_path(xctx->sch[0], 0, 1);
fputs(topsch, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */ else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */ /* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */ { /* and node number: m1 n1 m2 n2 .... */
@ -2406,6 +2427,12 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
/* fputs(xctx->sch[xctx->currsch],fd); */ /* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd); fputs(xctx->current_name, fd);
} }
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
topsch = get_trailing_path(xctx->sch[0], 0, 1);
fputs(topsch, fd);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */ else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present */
/* in hash table. print multiplicity */ /* in hash table. print multiplicity */
{ /* and node number: m1 n1 m2 n2 .... */ { /* and node number: m1 n1 m2 n2 .... */
@ -2969,6 +2996,13 @@ const char *translate(int inst, const char* s)
/* memcpy(result+result_pos,xctx->sch[xctx->currsch], tmp+1); */ /* memcpy(result+result_pos,xctx->sch[xctx->currsch], tmp+1); */
memcpy(result+result_pos, xctx->current_name, tmp+1); memcpy(result+result_pos, xctx->current_name, tmp+1);
result_pos+=tmp; result_pos+=tmp;
} else if(strcmp(token,"@topschname")==0) {
const char *topsch;
topsch = get_trailing_path(xctx->sch[0], 0, 1);
tmp = strlen(topsch);
STR_ALLOC(&result, tmp + result_pos, &size);
memcpy(result+result_pos, topsch, tmp+1);
result_pos+=tmp;
} else if(strcmp(token,"@prop_ptr")==0 && xctx->inst[inst].prop_ptr) { } else if(strcmp(token,"@prop_ptr")==0 && xctx->inst[inst].prop_ptr) {
tmp=strlen(xctx->inst[inst].prop_ptr); tmp=strlen(xctx->inst[inst].prop_ptr);
STR_ALLOC(&result, tmp + result_pos, &size); STR_ALLOC(&result, tmp + result_pos, &size);