From 77c99c22022ae2b58a73dcc6495555c02fbe7f4a Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 22 Dec 2023 12:01:55 +0100 Subject: [PATCH] handle xyce y-devices in nspice netlists --- src/scheduler.c | 4 ++-- src/spice.awk | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 295369e9..176db083 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -4229,7 +4229,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg constrained_move = atoi(argv[3]); } else if(!strcmp(argv[2], "cursor1_x")) { /* set graph cursor1 position */ - xctx->graph_cursor1_x = atof(argv[3]); + xctx->graph_cursor1_x = atof_spice(argv[3]); if(xctx->rects[GRIDLAYER] > 0) { Graph_ctx *gr = &xctx->graph_struct; @@ -4240,7 +4240,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } } else if(!strcmp(argv[2], "cursor2_x")) { /* set graph cursor2 position */ - xctx->graph_cursor2_x = atof(argv[3]); + xctx->graph_cursor2_x = atof_spice(argv[3]); if(xctx->rects[GRIDLAYER] > 0) { Graph_ctx *gr = &xctx->graph_struct; diff --git a/src/spice.awk b/src/spice.awk index 9a14f2ea..f0d5bb82 100755 --- a/src/spice.awk +++ b/src/spice.awk @@ -27,6 +27,15 @@ BEGIN{ first=1 user_code=0 #20180129 + # used to handle strange xyce primitives that have a type word before the instance name + xyceydev["ymemristor"] = 1 + xyceydev["ylin"] = 1 + xyceydev["ydelay"] = 1 + xyceydev["ytransline"] = 1 + xyceydev["ypgbr"] = 1 + xyceydev["ypowergridbranch"] = 1 + xyceydev["yacc"] = 1 + while( (ARGV[1] ~ /^[-]/) || (ARGV[1] ~ /^$/) ) { if(ARGV[1] == "-xyce") { xyce = 1} for(i=2; i<= ARGC;i++) { @@ -270,7 +279,20 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis) gsub(","," ",$0) print $0 } else { - num=split($1,name,",") + # handle uncommon xyce primitives that have a prefix before the device name + if(tolower($1) in xyceydev) { + devprefix = $1 + num = split($3, name, ",") + $1 = "" + for(i = 0; i < num; i++) { + if(i) $1 = $1 "," + $1 = $1 devprefix + } + num = split($1, name, ",") + $0 = $0 + } else { + num = split($1, name, ",") + } if(num==0) print ""