update docs (#pattern#@name tag)

This commit is contained in:
stefan schippers 2025-02-23 12:12:59 +01:00
parent 7144ead895
commit a306d97725
4 changed files with 27 additions and 3 deletions

View File

@ -551,6 +551,19 @@ verilog_format="xnor #(@risedel , @falldel ) @name ( @@Z , @@A , @@B );"
</ul> </ul>
<h3>PREDEFINED SYMBOL VALUES</h3> <h3>PREDEFINED SYMBOL VALUES</h3>
<ul> <ul>
<li><kbd>@name</kbd></li>
<p> This expands to the instance name of the symbol (like C1, R2, X3, ...)
It is replaced with the value of the <kbd>name=...</kbd> attribute given when placing an instance of the symbol
in a schematic.</p>
<li><kbd>#pattern#@name</kbd></li>
<p> This is a variation of the above where <kbd>pattern</kbd> is prefixed to all substituted <kbd>@name</kbd>
patterns. The difference with <kbd>pattern@name</kbd> is that in case of vector instances (this means
a placement of an instance with <kbd>name=R2[3:0]</kbd>, for example) the <kbd>pattern</kbd> string
is added to all single instances when expanding the name. see below examples.<br>
<kbd>pattern@name</kbd> where <kbd>name=R2[2:0]</kbd> is given in the instance placement,
expands to <kbd>patternR2[2],R2[1],R2[0]</kbd><br>
<kbd>#pattern#@name</kbd> where <kbd>name=R2[2:0]</kbd> is given in the instance placement,
expands to <kbd>patternR2[2],patternR2[1],patternR2[0]</kbd><br>
<li><kbd>@symname</kbd></li> <li><kbd>@symname</kbd></li>
<p> This expands to the name of the symbol</p> <p> This expands to the name of the symbol</p>
<li><kbd>@symref</kbd></li> <li><kbd>@symref</kbd></li>

View File

@ -594,7 +594,11 @@ FILE *my_fopen(const char *f, const char *m)
st = stat(f, &buf); st = stat(f, &buf);
if(st) return NULL; /* not existing or error */ if(st) return NULL; /* not existing or error */
#ifdef __unix__
if(!S_ISREG(buf.st_mode)) return NULL; /* not a regular file/symlink to a regular file */ if(!S_ISREG(buf.st_mode)) return NULL; /* not a regular file/symlink to a regular file */
#else
/* TBD */
#endif
fd = fopen(f, m); fd = fopen(f, m);
return fd; return fd;
} }

View File

@ -2783,7 +2783,8 @@ static void load_inst(int k, FILE *fd)
if(name[0] == '/') my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, rel_sym_path(name)); if(name[0] == '/') my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, rel_sym_path(name));
else my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, name); else my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, name);
#else #else
my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, rel_sym_path(name)); if(isupper(name[0]) && name[1] == ':' && name[1] == '/') my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, rel_sym_path(name));
else my_strdup2(_ALLOC_ID_, &xctx->inst[i].name, name);
#endif #endif
my_free(_ALLOC_ID_, &tmp); my_free(_ALLOC_ID_, &tmp);
if(fscanf(fd, "%lf %lf %hd %hd", &xctx->inst[i].x0, &xctx->inst[i].y0, if(fscanf(fd, "%lf %lf %hd %hd", &xctx->inst[i].x0, &xctx->inst[i].y0,

View File

@ -6744,9 +6744,15 @@ proc rel_sym_path {symbol} {
global OS pathlist env global OS pathlist env
regsub {^~/} $symbol ${env(HOME)}/ symbol regsub {^~/} $symbol ${env(HOME)}/ symbol
if {$OS eq "Windows"} {
if {![regexp {^[A-Za-z]\:/} $symbol]} {
set symbol [pwd]/$symbol
}
} else {
if {![regexp {^/} $symbol]} { if {![regexp {^/} $symbol]} {
set symbol [pwd]/$symbol set symbol [pwd]/$symbol
} }
}
set curr_dirname [pwd] set curr_dirname [pwd]
set name {} set name {}
foreach path_elem $pathlist { foreach path_elem $pathlist {