allow @model as alternative to @symname in format strings (format and spectre_format) of subcircuit symbols, where "model=something" is given in symbol template string. This allows to use subcircuit with name that is different from the filename.

This commit is contained in:
stefan schippers 2025-07-21 08:31:42 +02:00
parent aa99f1b174
commit 6f6f4a3028
3 changed files with 15 additions and 4 deletions

View File

@ -558,7 +558,9 @@ int spectre_block_netlist(FILE *fd, int i, int alert)
fprintf(fd, "%s\n", translated_sym_def);
my_free(_ALLOC_ID_, &sym_def);
} else {
const char *s = get_cell(sanitize(name), 0);
const char *s = get_tok_value(xctx->sym[i].templ,"model",0);
if(!s[0]) s = get_cell(sanitize(name), 0);
fprintf(fd, "** sch_path: %s\n", sanitized_abs_sym_path(filename, ""));
if(uppercase_subckt)
fprintf(fd, "SUBCKT %s ( ", s);

View File

@ -672,7 +672,8 @@ int spice_block_netlist(FILE *fd, int i, int alert)
fprintf(fd, "%s\n", translated_sym_def);
my_free(_ALLOC_ID_, &sym_def);
} else {
const char *s = get_cell(sanitize(name), 0);
const char *s = get_tok_value(xctx->sym[i].templ, "model",0);
if(!s[0]) s = get_cell(sanitize(name), 0);
fprintf(fd, "** sch_path: %s\n", sanitized_abs_sym_path(filename, ""));
if(uppercase_subckt)
fprintf(fd, ".SUBCKT %s ", s);

View File

@ -589,7 +589,8 @@ const char *get_sym_template(char *s,char *extra)
if( (with_quotes & 1) || escape || (c != '\\' && c != '"')) value[value_pos++]=(char)c;
} else if(state==TOK_END) {
value[value_pos]='\0';
if((!extra || !strstr(extra, token)) && strcmp(token,"name") && strcmp(token,"spiceprefix")) {
if((!extra || !strstr(extra, token)) && strcmp(token,"name") &&
strcmp(token,"spiceprefix") && strcmp(token,"model")) {
memcpy(result+result_pos, value, value_pos+1);
result_pos+=value_pos;
}
@ -601,7 +602,8 @@ const char *get_sym_template(char *s,char *extra)
if(token_pos) {
token[token_pos]='\0';
dbg(1, "token=|%s|\n", token);
if((!extra || !strstr(extra, token)) && strcmp(token,"name") && strcmp(token,"spiceprefix")) {
if((!extra || !strstr(extra, token)) && strcmp(token,"name") &&
strcmp(token,"spiceprefix") && strcmp(token,"model")) {
memcpy(result+result_pos, token, token_pos+1);
result_pos+=token_pos;
result[result_pos++] = (char)c;
@ -2081,6 +2083,9 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
else if(strcmp(token, "@symname")==0) {
break ;
}
else if(strcmp(token, "@model")==0) {
break ;
}
else if(strcmp(token, "@pinlist")==0) {
Int_hashtable table = {NULL, 0};
int_hash_init(&table, 37);
@ -2239,6 +2244,9 @@ void print_spectre_subckt_nodes(FILE *fd, int symbol)
else if(strcmp(token, "@symname")==0) {
break ;
}
else if(strcmp(token, "@model")==0) {
break ;
}
else if(strcmp(token, "@pinlist")==0) {
Int_hashtable table = {NULL, 0};
int_hash_init(&table, 37);