From fa4d4a0970fe2e46ee5c13bea034655b31196582 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 14 Jun 2024 08:55:35 +0200 Subject: [PATCH] enhance spice_sym_def used in instances (with schematic=...) by substituting @param with values defined in instance if any (param=xxx) --- src/actions.c | 10 ++++++++++ src/token.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/actions.c b/src/actions.c index f1ffde79..774b86a1 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1957,6 +1957,8 @@ void get_additional_symbols(int what) if(xctx->tok_size && xctx->inst[i].ptr>= 0) { /* token exists and instance points to valid symbol */ int j; char *sym = NULL; + char *templ = NULL; + char *symname_attr = NULL; int ignore_schematic = 0; xSymbol *symptr = xctx->inst[i].ptr + xctx->sym; my_strdup2(_ALLOC_ID_, &default_schematic, get_tok_value(symptr->prop_ptr,"default_schematic",0)); @@ -1973,6 +1975,14 @@ void get_additional_symbols(int what) my_strdup2(_ALLOC_ID_, &sym, add_ext(rel_sym_path(sch), ".sym")); } + my_strdup2(_ALLOC_ID_, &templ, get_tok_value(symptr->prop_ptr, "template", 0)); + my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(sym, 0), NULL); + my_strdup(_ALLOC_ID_, &spice_sym_def, + translate3(spice_sym_def, 1, xctx->inst[i].prop_ptr, + templ, + symname_attr)); + my_free(_ALLOC_ID_, &templ); + my_free(_ALLOC_ID_, &symname_attr); /* if instance symbol has default_schematic set to ignore copy the symbol anyway, since * the base symbol will not be netlisted by *_block_netlist() */ found = ignore_schematic ? NULL : int_hash_lookup(&sym_table, sym, 0, XLOOKUP); diff --git a/src/token.c b/src/token.c index 63e5839f..892b0455 100644 --- a/src/token.c +++ b/src/token.c @@ -1845,7 +1845,7 @@ static int has_included_subcircuit(int inst, int symbol, char **result) my_strdup2(_ALLOC_ID_, &symname, xctx->sym[symbol].name); } my_mstrcat(_ALLOC_ID_, &symname_attr, "symname=", get_cell(symname, 0), NULL); - translated_sym_def = translate3(spice_sym_def, 1, "", + translated_sym_def = translate3(spice_sym_def, 1, xctx->inst[inst].prop_ptr, templ, symname_attr); strtolower(symname);