changed @schname to @schname_ext and added @schname that expands to the schematic name containing the instance, with no extension (no .sch)

This commit is contained in:
Stefan Frederik 2022-08-10 08:38:49 +02:00
parent 0e25935254
commit ce4bd4837a
5 changed files with 51 additions and 16 deletions

View File

@ -453,10 +453,15 @@ verilog_format="xnor #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );"
this indicates the last modification time of the schematic (.sch) <b>containing</b>
the symbol instance.
</p>
<li><kbd>@schname_ext</kbd></li>
<p>
this expands to the name of the schematic (.sch) <b>containing</b>
the symbol instance.
</p>
<li><kbd>@schname</kbd></li>
<p>
this expands to the name of the schematic (.sch) <b>containing</b>
the symbol instance.
this expands to the name of the schematic <b>containing</b>
the symbol instance, without the extension (no .sch).
</p>
<li><kbd>@topschname</kbd></li>
<p>

View File

@ -823,12 +823,16 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@schname")==0)
{
fputs(get_cell(xctx->current_name, 0), fd);
}
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
@ -1874,14 +1878,21 @@ int print_spice_element(FILE *fd, int inst)
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_ext")==0) /* of course schname must not be present in attributes */
{
tmp = strlen(xctx->current_name) +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", xctx->current_name);
/* fputs(xctx->current_name, fd); */
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present in attributes */
{
const char *schname = get_cell(xctx->current_name, 0);
tmp = strlen(schname) +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", schname);
}
else if(strcmp(token,"@pinlist")==0) /* of course pinlist must not be present in attributes */
/* print multiplicity */
@ -2200,12 +2211,17 @@ void print_tedax_element(FILE *fd, int inst)
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
{
fputs(get_cell(xctx->current_name, 0), fd);
}
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
@ -2421,12 +2437,17 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level
{
fputs(get_cell_w_ext(xctx->inst[inst].name, 0), fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
else if(strcmp(token,"@schname_ext")==0) /* of course schname must not be present */
/* in hash table */
{
/* fputs(xctx->sch[xctx->currsch],fd); */
fputs(xctx->current_name, fd);
}
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
/* in hash table */
{
fputs(get_cell(xctx->current_name, 0), fd);
}
else if(strcmp(token,"@topschname")==0) /* of course topschname must not be present in attributes */
{
const char *topsch;
@ -2989,13 +3010,19 @@ const char *translate(int inst, const char* s)
memcpy(result+result_pos, date, tmp+1);
result_pos+=tmp;
}
} else if(strcmp(token,"@schname")==0) {
} else if(strcmp(token,"@schname_ext")==0) {
/* tmp=strlen(xctx->sch[xctx->currsch]);*/
tmp = strlen(xctx->current_name);
STR_ALLOC(&result, tmp + result_pos, &size);
/* memcpy(result+result_pos,xctx->sch[xctx->currsch], tmp+1); */
memcpy(result+result_pos, xctx->current_name, tmp+1);
result_pos+=tmp;
} else if(strcmp(token,"@schname")==0) {
const char *schname = get_cell(xctx->current_name, 0);
tmp = strlen(schname);
STR_ALLOC(&result, tmp + result_pos, &size);
memcpy(result+result_pos, schname, tmp+1);
result_pos+=tmp;
} else if(strcmp(token,"@topschname")==0) {
const char *topsch;
topsch = get_trailing_path(xctx->sch[0], 0, 1);

View File

@ -1,4 +1,4 @@
v {xschem version=2.9.8 file_version=1.2}
v {xschem version=3.1.0 file_version=1.2 }
G {}
K {type=logo
template="name=l1 author=\\"Stefan Schippers\\""
@ -12,7 +12,7 @@ E {}
L 6 225 0 1020 0 {}
L 6 -160 0 -95 0 {}
P 5 13 5 -30 -25 0 5 30 -15 30 -35 10 -55 30 -75 30 -45 0 -75 -30 -55 -30 -35 -10 -15 -30 5 -30 {fill=true}
T {@schname} 235 5 0 0 0.4 0.4 {}
T {@schname_ext} 235 5 0 0 0.4 0.4 {}
T {@author} 235 -25 0 0 0.4 0.4 {}
T {@time_last_modified} 1020 -25 0 1 0.4 0.3 {}
T {SCHEM} 5 -25 0 0 1 1 {}

View File

@ -1,4 +1,4 @@
v {xschem version=3.0.0 file_version=1.2 }
v {xschem version=3.1.0 file_version=1.2 }
G {}
K {type=subcircuit
format="@name @pinlist @symname"
@ -32,4 +32,3 @@ T {VSS} -125 -4 0 0 0.2 0.2 {}
T {OUT} 125 -44 0 1 0.2 0.2 {}
T {VPP} -125 16 0 0 0.2 0.2 {}
T {VNN} -125 36 0 0 0.2 0.2 {}
T {MOS Power amplifier} -110 -90 0 0 0.4 0.4 {hide=true}

View File

@ -1,11 +1,15 @@
v {xschem version=3.0.0 file_version=1.2}
v {xschem version=3.1.0 file_version=1.2 }
G {}
K {type=subcircuit
format="@name @pinlist @symname"
template="name=x1"
}
T {@symname} -67.5 -6 0 0 0.3 0.3 {}
T {@name} 135 -22 0 0 0.2 0.2 {}
V {}
S {}
E {}
L 4 -130 -10 130 -10 {}
L 4 -130 10 130 10 {}
L 4 -130 -10 -130 10 {}
L 4 130 -10 130 10 {}
T {@symname} -67.5 -6 0 0 0.3 0.3 {}
T {@name} 135 -22 0 0 0.2 0.2 {}