pass name and symname to tcl_hook, add @symname_ext in print_spice_element
This commit is contained in:
parent
c70aa9b06d
commit
8bb6b0e3f7
|
|
@ -393,7 +393,7 @@ void set_inst_prop(int i)
|
||||||
|
|
||||||
my_strdup(104, &ptr, (xctx.inst[i].ptr+ xctx.sym)->templ);
|
my_strdup(104, &ptr, (xctx.inst[i].ptr+ xctx.sym)->templ);
|
||||||
/* my_strdup(104, &ptr, translate(i, (xctx.inst[i].ptr+ xctx.sym)->templ)); */
|
/* my_strdup(104, &ptr, translate(i, (xctx.inst[i].ptr+ xctx.sym)->templ)); */
|
||||||
/* tcl_hook(&ptr); */
|
/* tcl_hook(&ptr, i); */
|
||||||
dbg(1, "set_inst_prop(): i=%d, name=%s, prop_ptr = %s, template=%s\n",
|
dbg(1, "set_inst_prop(): i=%d, name=%s, prop_ptr = %s, template=%s\n",
|
||||||
i, xctx.inst[i].name, xctx.inst[i].prop_ptr, ptr);
|
i, xctx.inst[i].name, xctx.inst[i].prop_ptr, ptr);
|
||||||
my_strdup(69, &xctx.inst[i].prop_ptr, ptr);
|
my_strdup(69, &xctx.inst[i].prop_ptr, ptr);
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,12 @@ BEGIN{
|
||||||
|
|
||||||
|
|
||||||
$0 ~ pattern "[0-9]+" {
|
$0 ~ pattern "[0-9]+" {
|
||||||
|
if($0 !~/^ *\/\*/) {
|
||||||
a = $0
|
a = $0
|
||||||
sub("^.*" pattern,"", a)
|
sub("^.*" pattern,"", a)
|
||||||
sub(/ *,.*/,"", a)
|
sub(/ *,.*/,"", a)
|
||||||
print a "\t" FILENAME "\t" $0
|
print a "\t" FILENAME "\t" $0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
' \
|
' \
|
||||||
actions.c \
|
actions.c \
|
||||||
|
|
|
||||||
60
src/token.c
60
src/token.c
|
|
@ -156,19 +156,16 @@ void hash_all_names(int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tcl_hook(char **res)
|
void tcl_hook(char **res, int inst)
|
||||||
{
|
{
|
||||||
char * result = *res;
|
char * result = *res;
|
||||||
if(result && strstr(result, "tcleval(")== result) {
|
if(result && strstr(result, "tcleval(")== result) {
|
||||||
size_t s;
|
dbg(1, "tcl_hook(): %s %s %s\n", result, xctx.inst[inst].instname,
|
||||||
char *tclcmd=NULL;
|
get_cell((xctx.inst[inst].ptr + xctx.sym)->name, 0));
|
||||||
s = strlen(result) + 100;
|
Tcl_VarEval(interp,
|
||||||
tclcmd = my_malloc(1197, s);
|
"tclpropeval2 {", result, "} {", xctx.inst[inst].instname, "} {",
|
||||||
my_snprintf(tclcmd, s, "tclpropeval2 {%s}", result);
|
get_cell((xctx.inst[inst].ptr + xctx.sym)->name, 0), "}", NULL);
|
||||||
dbg(1, "tclpropeval2 {%s}", result);
|
|
||||||
tcleval(tclcmd);
|
|
||||||
my_strdup2(1198, res, tclresult());
|
my_strdup2(1198, res, tclresult());
|
||||||
my_free(1199, &tclcmd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1429,7 +1426,7 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
|
|
||||||
my_strdup(483, &template, (xctx.inst[inst].ptr+ xctx.sym)->templ);
|
my_strdup(483, &template, (xctx.inst[inst].ptr+ xctx.sym)->templ);
|
||||||
/* my_strdup(483, &template, translate(inst, (xctx.inst[inst].ptr+ xctx.sym)->templ) ); */
|
/* my_strdup(483, &template, translate(inst, (xctx.inst[inst].ptr+ xctx.sym)->templ) ); */
|
||||||
/* tcl_hook(&template); */
|
/* tcl_hook(&template, inst); */
|
||||||
my_strdup(484, &name,xctx.inst[inst].instname);
|
my_strdup(484, &name,xctx.inst[inst].instname);
|
||||||
if (!name) my_strdup(43, &name, get_tok_value(template, "name", 0));
|
if (!name) my_strdup(43, &name, get_tok_value(template, "name", 0));
|
||||||
|
|
||||||
|
|
@ -1452,16 +1449,17 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
/* always make room for some characters so the single char writes to result do not need reallocs */
|
/* always make room for some characters so the single char writes to result do not need reallocs */
|
||||||
str_alloc(&result, 0, result_pos, &size);
|
str_alloc(&result, 100, result_pos, &size);
|
||||||
c=*s++;
|
c=*s++;
|
||||||
if(c=='\\') {
|
if(c=='\\') {
|
||||||
escape=1;
|
escape=1;
|
||||||
c=*s++;
|
c=*s++;
|
||||||
}
|
}
|
||||||
else escape=0;
|
else escape=0;
|
||||||
|
|
||||||
if (c=='\n' && escape) c=*s++; /* 20171030 eat escaped newlines */
|
if (c=='\n' && escape) c=*s++; /* 20171030 eat escaped newlines */
|
||||||
space=SPACE(c);
|
space=SPACE(c);
|
||||||
if (state==XBEGIN && (c=='@'|| c=='$') && !escape) state=XTOKEN;
|
if ( state==XBEGIN && (c=='@'|| c=='$') && !escape ) state=XTOKEN;
|
||||||
else if(state==XTOKEN && token_pos > 1 &&
|
else if(state==XTOKEN && token_pos > 1 &&
|
||||||
(
|
(
|
||||||
( (space || c == '$' || c == '@') && !escape ) ||
|
( (space || c == '$' || c == '@') && !escape ) ||
|
||||||
|
|
@ -1530,6 +1528,16 @@ void 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,"@symname_ext")==0) /* of course symname must not be present */
|
||||||
|
/* in hash table */
|
||||||
|
{
|
||||||
|
const char *s = get_cell_w_ext(xctx.inst[inst].name, 0);
|
||||||
|
tmp = strlen(s) +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", s);
|
||||||
|
/* fputs(s,fd); */
|
||||||
|
}
|
||||||
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
|
else if(strcmp(token,"@schname")==0) /* of course schname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
{
|
{
|
||||||
|
|
@ -1553,7 +1561,6 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
* so 1-char writes to result do not need reallocs */
|
* so 1-char writes to result do not need reallocs */
|
||||||
str_alloc(&result, tmp, result_pos, &size);
|
str_alloc(&result, tmp, result_pos, &size);
|
||||||
result_pos += my_snprintf(result + result_pos, tmp, "@%d %s ", mult, str_ptr);
|
result_pos += my_snprintf(result + result_pos, tmp, "@%d %s ", mult, str_ptr);
|
||||||
/* fprintf(fd, "@%d %s ", mult, str_ptr); */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1568,7 +1575,6 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
* so 1-char writes to result do not need reallocs */
|
* so 1-char writes to result do not need reallocs */
|
||||||
str_alloc(&result, tmp, result_pos, &size);
|
str_alloc(&result, tmp, result_pos, &size);
|
||||||
result_pos += my_snprintf(result + result_pos, tmp, "@%d %s ", mult, str_ptr);
|
result_pos += my_snprintf(result + result_pos, tmp, "@%d %s ", mult, str_ptr);
|
||||||
/* fprintf(fd, "@%d %s ", mult, str_ptr); */
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1588,7 +1594,6 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
* so 1-char writes to result do not need reallocs */
|
* so 1-char writes to result do not need reallocs */
|
||||||
str_alloc(&result, tmp, result_pos, &size);
|
str_alloc(&result, tmp, result_pos, &size);
|
||||||
result_pos += my_snprintf(result + result_pos, tmp, "@%d %s ", mult, str_ptr);
|
result_pos += my_snprintf(result + result_pos, tmp, "@%d %s ", mult, str_ptr);
|
||||||
/* fprintf(fd, "@%d %s ", mult, str_ptr); */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1634,7 +1639,9 @@ void print_spice_element(FILE *fd, int inst)
|
||||||
|
|
||||||
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
|
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
|
||||||
* can be calculated */
|
* can be calculated */
|
||||||
tcl_hook(&result);
|
|
||||||
|
/* do one level of substitutions to resolve @params and equations*/
|
||||||
|
/* my_strdup(22, &result, translate(inst, result)); */
|
||||||
|
|
||||||
fprintf(fd, "%s", result);
|
fprintf(fd, "%s", result);
|
||||||
my_free(1019, &template);
|
my_free(1019, &template);
|
||||||
|
|
@ -1794,6 +1801,10 @@ void print_tedax_element(FILE *fd, int inst)
|
||||||
{
|
{
|
||||||
fputs(skip_dir(xctx.inst[inst].name),fd);
|
fputs(skip_dir(xctx.inst[inst].name),fd);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(token,"@symname_ext")==0)
|
||||||
|
{
|
||||||
|
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")==0) /* of course schname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
{
|
{
|
||||||
|
|
@ -2202,6 +2213,10 @@ void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 20071217 *
|
||||||
{
|
{
|
||||||
fprintf( fd, "%s",skip_dir(xctx.inst[inst].name) );
|
fprintf( fd, "%s",skip_dir(xctx.inst[inst].name) );
|
||||||
}
|
}
|
||||||
|
else if (strcmp(token,"@symname_ext")==0)
|
||||||
|
{
|
||||||
|
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")==0) /* of course schname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
{
|
{
|
||||||
|
|
@ -2369,7 +2384,11 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti
|
||||||
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 */
|
||||||
{
|
{
|
||||||
fprintf( fd, "%s",skip_dir(xctx.inst[inst].name) );
|
fprintf( fd, "%s",skip_dir(xctx.inst[inst]. name) );
|
||||||
|
}
|
||||||
|
else if (strcmp(token,"@symname_ext")==0)
|
||||||
|
{
|
||||||
|
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")==0) /* of course schname must not be present */
|
||||||
/* in hash table */
|
/* in hash table */
|
||||||
|
|
@ -2514,7 +2533,7 @@ const char *translate(int inst, const char* s)
|
||||||
my_realloc(527, &result,size);
|
my_realloc(527, &result,size);
|
||||||
result[0]='\0';
|
result[0]='\0';
|
||||||
|
|
||||||
dbg(2, "translate(): substituting props in <%s>, instance <%s>\n",
|
dbg(1, "translate(): substituting props in <%s>, instance <%s>\n",
|
||||||
s?s:"NULL",xctx.inst[inst].instname?xctx.inst[inst].instname:"NULL");
|
s?s:"NULL",xctx.inst[inst].instname?xctx.inst[inst].instname:"NULL");
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
|
|
@ -2750,7 +2769,7 @@ const char *translate(int inst, const char* s)
|
||||||
|
|
||||||
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
|
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
|
||||||
* can be calculated */
|
* can be calculated */
|
||||||
tcl_hook(&result);
|
tcl_hook(&result, inst);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2857,9 +2876,6 @@ const char *translate2(struct Lcc *lcc, int level, char* s)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
|
|
||||||
* can be calculated */
|
|
||||||
tcl_hook(&result);
|
|
||||||
my_free(1070, &token);
|
my_free(1070, &token);
|
||||||
my_free(1071, &value1);
|
my_free(1071, &value1);
|
||||||
my_free(1072, &value2);
|
my_free(1072, &value2);
|
||||||
|
|
|
||||||
|
|
@ -902,7 +902,7 @@ extern const char *tcleval(const char str[]);
|
||||||
extern const char *tclresult(void);
|
extern const char *tclresult(void);
|
||||||
extern const char *tclgetvar(const char *s);
|
extern const char *tclgetvar(const char *s);
|
||||||
extern void tclsetvar(const char *s, const char *value);
|
extern void tclsetvar(const char *s, const char *value);
|
||||||
extern void tcl_hook(char **res);
|
extern void tcl_hook(char **res, int inst);
|
||||||
extern void statusmsg(char str[],int n);
|
extern void statusmsg(char str[],int n);
|
||||||
extern void place_text(int draw_text, double mx, double my);
|
extern void place_text(int draw_text, double mx, double my);
|
||||||
extern void init_inst_iterator(double x1, double y1, double x2, double y2);
|
extern void init_inst_iterator(double x1, double y1, double x2, double y2);
|
||||||
|
|
|
||||||
|
|
@ -1854,20 +1854,20 @@ proc property_search {} {
|
||||||
# attributes.
|
# attributes.
|
||||||
#
|
#
|
||||||
proc tclpropeval {s instname symname} {
|
proc tclpropeval {s instname symname} {
|
||||||
# puts ">>>> $s $instname $symname"
|
# puts "tclpropeval: $s $instname $symname"
|
||||||
regsub {^@tcleval\(} $s {} s
|
regsub {^@tcleval\(} $s {} s
|
||||||
regsub {\)$} $s {} s
|
regsub {\)$} $s {} s
|
||||||
return [eval $s]
|
return [eval $s]
|
||||||
}
|
}
|
||||||
|
|
||||||
# this hook is called in translate() if whole string is contained in a tcleval(...) construct
|
# this hook is called in translate() if whole string is contained in a tcleval(...) construct
|
||||||
proc tclpropeval2 {s} {
|
proc tclpropeval2 {s instname symname} {
|
||||||
# puts ">>>> $s $instname $symname"
|
# puts "tclpropeval2: $s $instname $symname"
|
||||||
regsub {^tcleval\(} $s {} s
|
regsub {^tcleval\(} $s {} s
|
||||||
regsub {\)([ \n\t]*)$} $s {\1} s
|
regsub {\)([ \n\t]*)$} $s {\1} s
|
||||||
if { [catch {subst $s} res] } {
|
if { [catch {subst $s} res] } {
|
||||||
puts "tclpropeval2: $res"
|
puts "tclpropeval2: $res"
|
||||||
set res {<ERROR>}
|
set res $s
|
||||||
}
|
}
|
||||||
return $res
|
return $res
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue