From 759d3f86c14f9621350553c14c91e28eef416e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rp=C3=A1d=20B=C5=B1rmen?= Date: Sat, 6 Jul 2024 23:11:44 +0200 Subject: [PATCH 1/8] OpenVAF-reloaded compiled model support. --- src/osdi/osdiregistry.c | 48 ++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 9a9dd114a..2d5080ee0 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -312,6 +312,10 @@ static size_t calc_osdi_noise_off(const OsdiDescriptor *descr) { } \ const ty *name = (ty *)sym; +#define GET_PTR_NOCHECK(name, ty) \ + sym = GET_SYM(handle, STRINGIFY(name)); \ + const ty *name = (ty *)sym; + #define INIT_CALLBACK(name, ty) \ sym = GET_SYM(handle, STRINGIFY(name)); \ if (sym) { \ @@ -373,18 +377,40 @@ extern OsdiObjectFile load_object_file(const char *input) { return EMPTY_OBJECT; } + // Try to get OSDI_DESCRIPTOR_SIZE + GET_PTR_NOCHECK(OSDI_DESCRIPTOR_SIZE, uint32_t); + size_t descriptor_size; + + // Get major and minor OSDI version GET_CONST(OSDI_VERSION_MAJOR, uint32_t); GET_CONST(OSDI_VERSION_MINOR, uint32_t); - if (OSDI_VERSION_MAJOR != OSDI_VERSION_MAJOR_CURR || + if (OSDI_DESCRIPTOR_SIZE) { + // This must be openvaf-reloaded + // Must be version>=0.4 + if (!( + (OSDI_VERSION_MAJOR == 0 && OSDI_VERSION_MINOR >= 4) || + OSDI_VERSION_MAJOR >= 1 + )) { + printf("NGSPICE supports OpenVAF-reloaded OSDI >= 0.4 but \"%s\" uses v%d.%d!", + path, OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); + txfree(path); + return INVALID_OBJECT; + } + descriptor_size = *OSDI_DESCRIPTOR_SIZE; + } else { + // Original OpenVAF, must be version==0.3 + if (OSDI_VERSION_MAJOR != OSDI_VERSION_MAJOR_CURR || OSDI_VERSION_MINOR != OSDI_VERSION_MINOR_CURR) { - printf("NGSPICE only supports OSDI v%d.%d but \"%s\" targets v%d.%d!", - OSDI_VERSION_MAJOR_CURR, OSDI_VERSION_MINOR_CURR, path, - OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); - txfree(path); - return INVALID_OBJECT; + printf("NGSPICE only supports OSDI v%d.%d but \"%s\" uses v%d.%d!", + OSDI_VERSION_MAJOR_CURR, OSDI_VERSION_MINOR_CURR, path, + OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); + txfree(path); + return INVALID_OBJECT; + } + descriptor_size = sizeof(OsdiDescriptor); } - + GET_CONST(OSDI_NUM_DESCRIPTORS, uint32_t); GET_PTR(OSDI_DESCRIPTORS, OsdiDescriptor); @@ -420,10 +446,12 @@ extern OsdiObjectFile load_object_file(const char *input) { } OsdiRegistryEntry *dst = TMALLOC(OsdiRegistryEntry, OSDI_NUM_DESCRIPTORS); - + + char* desc_ptr = (char*)OSDI_DESCRIPTORS; for (uint32_t i = 0; i < OSDI_NUM_DESCRIPTORS; i++) { - const OsdiDescriptor *descr = &OSDI_DESCRIPTORS[i]; - + const OsdiDescriptor *descr = (OsdiDescriptor*)desc_ptr; + desc_ptr += descriptor_size; + uint32_t dt = descr->num_params + descr->num_opvars; bool has_m = false; uint32_t temp = descr->num_params + descr->num_opvars + 1; From 45ed95d91ea4b431ef8fd3820ab7bc653b11fdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rp=C3=A1d=20B=C5=B1rmen?= Date: Sat, 6 Jul 2024 23:20:07 +0200 Subject: [PATCH 2/8] Minor change. --- src/osdi/osdiregistry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 2d5080ee0..0e8c431b5 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -392,9 +392,9 @@ extern OsdiObjectFile load_object_file(const char *input) { (OSDI_VERSION_MAJOR == 0 && OSDI_VERSION_MINOR >= 4) || OSDI_VERSION_MAJOR >= 1 )) { - printf("NGSPICE supports OpenVAF-reloaded OSDI >= 0.4 but \"%s\" uses v%d.%d!", + printf("NGSPICE supports OpenVAF-reloaded OSDI>=0.4 but \"%s\" uses v%d.%d!", path, OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); - txfree(path); + txfree(path); return INVALID_OBJECT; } descriptor_size = *OSDI_DESCRIPTOR_SIZE; From 106d2a93cf9314f934c61ce8ed91ee88fcf84e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rp=C3=A1d=20B=C5=B1rmen?= Date: Sat, 6 Jul 2024 23:20:58 +0200 Subject: [PATCH 3/8] Minor change. --- src/osdi/osdiregistry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 0e8c431b5..62b4efbed 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -392,7 +392,7 @@ extern OsdiObjectFile load_object_file(const char *input) { (OSDI_VERSION_MAJOR == 0 && OSDI_VERSION_MINOR >= 4) || OSDI_VERSION_MAJOR >= 1 )) { - printf("NGSPICE supports OpenVAF-reloaded OSDI>=0.4 but \"%s\" uses v%d.%d!", + printf("NGSPICE supports OpenVAF-reloaded OSDI>=v0.4 but \"%s\" uses v%d.%d!", path, OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); txfree(path); return INVALID_OBJECT; From 67df0c227be15f884db4883e0e70f80aa0aaa3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rp=C3=A1d=20B=C5=B1rmen?= Date: Sat, 6 Jul 2024 23:24:11 +0200 Subject: [PATCH 4/8] Minor change. --- src/osdi/osdiregistry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osdi/osdiregistry.c b/src/osdi/osdiregistry.c index 62b4efbed..d865d7c52 100644 --- a/src/osdi/osdiregistry.c +++ b/src/osdi/osdiregistry.c @@ -392,7 +392,7 @@ extern OsdiObjectFile load_object_file(const char *input) { (OSDI_VERSION_MAJOR == 0 && OSDI_VERSION_MINOR >= 4) || OSDI_VERSION_MAJOR >= 1 )) { - printf("NGSPICE supports OpenVAF-reloaded OSDI>=v0.4 but \"%s\" uses v%d.%d!", + printf("NGSPICE supports OpenVAF-reloaded OSDI version >= 0.4 but \"%s\" uses v%d.%d!", path, OSDI_VERSION_MAJOR, OSDI_VERSION_MINOR); txfree(path); return INVALID_OBJECT; From 9b8c7bd62fa4beba26b8a1bac6de0a63cb86512f Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 20 Oct 2024 23:32:16 +0200 Subject: [PATCH 5/8] Fix bug no. 708, reported by Philip Sauvage. --- src/frontend/inpcompat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/inpcompat.c b/src/frontend/inpcompat.c index ce4d96af9..e865997c4 100644 --- a/src/frontend/inpcompat.c +++ b/src/frontend/inpcompat.c @@ -695,7 +695,7 @@ struct card *pspice_compat(struct card *oldcard) nextcard = insert_new_line(nextcard, new_str, 7, 0, "internal"); new_str = copy(".func if(a, b, c) {ternary_fcn( a , b , c )}"); nextcard = insert_new_line(nextcard, new_str, 8, 0, "internal"); - new_str = copy(".func int(x) { sign(x)*floor(abs(x)) }"); + new_str = copy(".func int(x) { sgn(x)*floor(abs(x)) }"); nextcard = insert_new_line(nextcard, new_str, 9, 0, "internal"); nextcard->nextcard = oldcard; From 330ebb4018e1d6ee5cd5433208c2f3dd6fdddb26 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Mon, 21 Oct 2024 13:58:22 +0200 Subject: [PATCH 6/8] Improve comment --- src/spicelib/parser/inpmkmod.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/spicelib/parser/inpmkmod.c b/src/spicelib/parser/inpmkmod.c index 055d7a66b..3ff8ed92d 100644 --- a/src/spicelib/parser/inpmkmod.c +++ b/src/spicelib/parser/inpmkmod.c @@ -20,7 +20,9 @@ NGHASHPTR modtabhash = NULL; * This fcn takes the model name and looks to see if it is already * in the model table. If it is, then just return. Otherwise, * stick the model into the model table. - * Note that the model table INPmodel + * Note that the model table INPmodel *modtab is a linked list, + * in parallel a hash table modtabhash is filled in for faster + * access to modtab elements by giving the model name. *--------------------------------------------------------------*/ int INPmakeMod(char *token, int type, struct card *line) From 8f6187b1ab31756aa1102817a67880c388eea87e Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 25 Oct 2024 23:41:42 +0200 Subject: [PATCH 7/8] Fix bug 711 reported by Sonia Edward --- src/spicelib/devices/hfet1/hfetinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spicelib/devices/hfet1/hfetinit.c b/src/spicelib/devices/hfet1/hfetinit.c index 339035b6e..346b382a5 100644 --- a/src/spicelib/devices/hfet1/hfetinit.c +++ b/src/spicelib/devices/hfet1/hfetinit.c @@ -69,7 +69,7 @@ SPICEdev HFETAinfo = { #ifdef KLU .DEVbindCSC = HFETAbindCSC, - .DEVbindCSCComplex = HFETAbindCSC, + .DEVbindCSCComplex = HFETAbindCSCComplex, .DEVbindCSCComplexToReal = HFETAbindCSCComplexToReal, #endif }; From aa97a05f040fc1a868e4783a8cb863cfee38c532 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 26 Oct 2024 17:32:19 +0200 Subject: [PATCH 8/8] Use the correct type for each vector after S-parameter analysis. Cy_1_1 is still missing (voltage as default). --- src/frontend/outitf.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index c04a91c62..00e6b17bd 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -947,7 +947,7 @@ fileInit(runDesc *run) or special parameter names for @ vecors. FIXME This guessing may fail due to the many options, especially for the @ vectors. */ static int -guess_type(const char *name) +guess_type(const char *name, char* pltypename) { int type; @@ -969,6 +969,20 @@ guess_type(const char *name) type = SV_RES; else if (cieq(name, "i-sweep")) type = SV_CURRENT; + else if (pltypename && ciprefix("sp", pltypename) && ciprefix("S_", name)) + type = SV_SPARAM; + else if (pltypename && ciprefix("sp", pltypename) && ciprefix("Y_", name)) + type = SV_ADMITTANCE; + else if (pltypename && ciprefix("sp", pltypename) && ciprefix("Z_", name)) + type = SV_IMPEDANCE; + else if (pltypename && ciprefix("sp", pltypename) && cieq(name, "NF")) + type = SV_DB; + else if (pltypename && ciprefix("sp", pltypename) && cieq(name, "NFmin")) + type = SV_DB; + else if (pltypename && ciprefix("sp", pltypename) && cieq(name, "Rn")) + type = SV_IMPEDANCE; + else if (pltypename && ciprefix("sp", pltypename) && cieq(name, "SOpt")) + type = SV_NOTYPE; else if (strstr(name, ":power\0")) type = SV_POWER; /* current source ISRC parameters for current */ @@ -1001,7 +1015,7 @@ fileInit_pass2(runDesc *run) char *name = run->data[i].name; - type = guess_type(name); + type = guess_type(name, NULL); if (type == SV_CURRENT && !keepbranch) { char *branch = strstr(name, "#branch"); @@ -1141,7 +1155,7 @@ plotInit(runDesc *run) name = copy(dd->name); v = dvec_alloc(name, - guess_type(name), + guess_type(name, pl->pl_typename), run->isComplex ? (VF_COMPLEX | VF_PERMANENT) : (VF_REAL | VF_PERMANENT),