From 0178e1c287a1f144fb4634e17fe96726e7b4b26f Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Wed, 18 Oct 2023 13:18:29 +0200 Subject: [PATCH] add @symref attribute that resolves to the full symbol reference as specified in instance: example: "sky130_fd_pr/pfet_01v8_lvt.sym" --- src/token.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/token.c b/src/token.c index 1358de28..303e213e 100644 --- a/src/token.c +++ b/src/token.c @@ -991,6 +991,11 @@ static void print_vhdl_primitive(FILE *fd, int inst) /* netlist primitives, 200 { fprintf( fd, "%s",xctx->sch_path[xctx->currsch] + 1); } + else if(strcmp(token,"@symref")==0) + { + const char *s = get_sym_name(inst, 9999, 1); + fputs(s, fd); + } else if(strcmp(token,"@symname")==0) /* of course symname must not be present */ /* in hash table */ { @@ -2072,6 +2077,14 @@ int print_spice_element(FILE *fd, int inst) result_pos += my_snprintf(result + result_pos, tmp, "%s", s); /* fputs(s,fd); */ } + else if(strcmp(token,"@symref")==0) + { + const char *s = get_sym_name(inst, 9999, 1); + 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); + } else if (strcmp(token,"@symname")==0) /* of course symname must not be present in attributes */ { const char *s = sanitize(translate(inst, get_sym_name(inst, 0, 0))); @@ -2488,6 +2501,11 @@ void print_tedax_element(FILE *fd, int inst) { fputs(xctx->sch_path[xctx->currsch] + 1, fd); } + else if(strcmp(token,"@symref")==0) + { + const char *s = get_sym_name(inst, 9999, 1); + fputs(s, fd); + } else if(strcmp(token,"@symname")==0) /* of course symname must not be present */ /* in hash table */ { @@ -2748,6 +2766,11 @@ static void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level { fputs(xctx->sch_path[xctx->currsch] + 1, fd); } + else if(strcmp(token,"@symref")==0) + { + const char *s = get_sym_name(inst, 9999, 1); + fputs(s, fd); + } else if(strcmp(token,"@symname")==0) /* of course symname must not be present */ /* in hash table */ { @@ -3454,6 +3477,13 @@ const char *translate(int inst, const char* s) STR_ALLOC(&result, tmp + result_pos, &size); memcpy(result+result_pos, instname, tmp+1); result_pos+=tmp; + } else if(strcmp(token,"@symref")==0) { + tmp_sym_name = get_sym_name(inst, 9999, 1); + tmp_sym_name=tmp_sym_name ? tmp_sym_name : ""; + tmp=strlen(tmp_sym_name); + STR_ALLOC(&result, tmp + result_pos, &size); + memcpy(result+result_pos,tmp_sym_name, tmp+1); + result_pos+=tmp; } else if(strcmp(token,"@symname")==0) { tmp_sym_name = get_sym_name(inst, 0, 0); tmp_sym_name=tmp_sym_name ? tmp_sym_name : "";