From aedd8fc2a2eb27f0e557a81e7e9813ce4e559384 Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Thu, 7 May 2026 18:54:12 +0100 Subject: [PATCH] Feature Request 72 - "Printing hidden errors to terminal" suggests showing errors in XSPICE code model support functions by default. But errors may occur routinely and be handled by code. To aid developers, setting variable "noisyxspice" will display the messages. Also fix an error report in cm_event_queue(), remove XSPICE parse error messages that are now shown twice and fix errors in d_source that were seen with the new error reporting. --- src/xspice/cm/cmevt.c | 9 ++++++--- src/xspice/evt/evtload.c | 8 +++++++- src/xspice/icm/digital/d_source/cfunc.mod | 6 ++++-- src/xspice/mif/mif_inp2.c | 6 ------ src/xspice/mif/mifload.c | 8 +++++++- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/xspice/cm/cmevt.c b/src/xspice/cm/cmevt.c index beaf49a96..b9e164fbc 100644 --- a/src/xspice/cm/cmevt.c +++ b/src/xspice/cm/cmevt.c @@ -240,10 +240,13 @@ int cm_event_queue( here = g_mif_info.instance; ckt = g_mif_info.ckt; - /* If breakpoint time <= current event time, return error */ - if(time <= g_mif_info.circuit.evt_step) { + /* If breakpoint time < current event time, return error. */ + + if (time < g_mif_info.circuit.evt_step || + (time == g_mif_info.circuit.evt_step && + g_mif_info.circuit.call_type == MIF_EVENT_DRIVEN)) { g_mif_info.errmsg = - "ERROR - cm_event_queue() - Event time cannot be <= current time\n"; + "ERROR - cm_event_queue() - Event time cannot be <= current time\n"; return(MIF_ERROR); } diff --git a/src/xspice/evt/evtload.c b/src/xspice/evt/evtload.c index 35ee44716..db4067592 100644 --- a/src/xspice/evt/evtload.c +++ b/src/xspice/evt/evtload.c @@ -159,7 +159,6 @@ int EVTload_with_event( g_mif_info.ckt = ckt; g_mif_info.instance = inst; - g_mif_info.errmsg = ""; g_mif_info.circuit.call_type = MIF_EVENT_DRIVEN; if(inst->initialized) @@ -250,6 +249,13 @@ int EVTload_with_event( mod_type = MIFmodPtr(inst)->MIFmodType; DEVices[mod_type]->DEVpublic.cm_func (&cm_data); + if (g_mif_info.errmsg && g_mif_info.errmsg[0] && + cp_getvar("noisyxspice", CP_BOOL, NULL, 0)) { + fprintf(stderr, "XSPICE instance %s: %s", + inst->MIFname, g_mif_info.errmsg); + g_mif_info.errmsg = NULL; + } + /* ****************************** */ /* Process the code model outputs */ diff --git a/src/xspice/icm/digital/d_source/cfunc.mod b/src/xspice/icm/digital/d_source/cfunc.mod index 716ebb387..a17f3d83d 100644 --- a/src/xspice/icm/digital/d_source/cfunc.mod +++ b/src/xspice/icm/digital/d_source/cfunc.mod @@ -1089,7 +1089,8 @@ void cm_d_source(ARGS) /* reset current breakpoint */ test_double = loc->all_timepoints[*row_index]; - cm_event_queue( test_double ); + if (test_double != 0) + cm_event_queue( test_double ); /* Output new values... */ for (i=0; iwidth; i++) { @@ -1154,7 +1155,8 @@ void cm_d_source(ARGS) /* reset current breakpoint */ test_double = loc->all_timepoints[*row_index] - 1.0e-10; - cm_event_queue( test_double ); + if (TIME != test_double) + cm_event_queue( test_double ); /* Output new values... */ for (i=0; iwidth; i++) { diff --git a/src/xspice/mif/mif_inp2.c b/src/xspice/mif/mif_inp2.c index f6b170894..3cdfb9fcb 100644 --- a/src/xspice/mif/mif_inp2.c +++ b/src/xspice/mif/mif_inp2.c @@ -370,13 +370,11 @@ MIF_INP2A ( /* First, do a couple of error checks */ if(next_token_type == MIF_LARRAY_TOK) { LITERR("ERROR - Scalar connection expected, [ found"); - printf("ERROR - Scalar connection expected, [ found. Returning . . ."); gc_end(); return; } if(next_token_type == MIF_RARRAY_TOK) { LITERR("ERROR - Unexpected ]"); - printf("ERROR - Unexpected ]. Returning . . ."); gc_end(); return; } @@ -412,7 +410,6 @@ MIF_INP2A ( /* check for required leading array delim character [ and eat it if found */ if(next_token_type != MIF_LARRAY_TOK) { LITERR("Missing [, an array connection was expected"); - printf("Missing [, an array connection was expected. Returning . . ."); gc_end(); return; } else /* eat the [ */ @@ -448,19 +445,16 @@ MIF_INP2A ( or hold a non-null connection (netname) */ if(next_token_type == MIF_NULL_TOK) { LITERR("NULL connection found where not allowed"); - printf("NULL connection found where not allowed. Returning . . ."); gc_end(); return; } if(next_token_type == MIF_LARRAY_TOK) { LITERR("ERROR - Unexpected [ - Arrays of arrays not allowed"); - printf("ERROR - Unexpected [ - Arrays of arrays not allowed. Returning . . ."); gc_end(); return; } if(next_token_type == MIF_RARRAY_TOK) { LITERR("ERROR - Unexpected ]"); - printf("ERROR - Unexpected ]. Returning . . ."); gc_end(); return; } diff --git a/src/xspice/mif/mifload.c b/src/xspice/mif/mifload.c index af36eed55..b4bd3d2d3 100644 --- a/src/xspice/mif/mifload.c +++ b/src/xspice/mif/mifload.c @@ -245,7 +245,6 @@ MIFload( /* Prepare the data needed by the cm_.. functions */ /* ***************************************************************** */ g_mif_info.instance = here; - g_mif_info.errmsg = ""; if(here->initialized) { cm_data.circuit.init = MIF_FALSE; @@ -461,6 +460,13 @@ MIFload( (g_mif_info.auto_partial.global || g_mif_info.auto_partial.local)) MIFauto_partial(here, DEVices[mod_type]->DEVpublic.cm_func, &cm_data); + if (g_mif_info.errmsg && g_mif_info.errmsg[0] && + cp_getvar("noisyxspice", CP_BOOL, NULL, 0)) { + fprintf(stderr, "XSPICE instance %s: %s", + g_mif_info.instance->MIFname, g_mif_info.errmsg); + g_mif_info.errmsg = NULL; + } + /* ***************************************************************** */ /* Loop through all connections on this instance and */ /* load the data into the matrix for each output port */