diff --git a/src/xspice/icm/digital/d_and/cfunc.mod b/src/xspice/icm/digital/d_and/cfunc.mod index 7ba465417..921b273f8 100644 --- a/src/xspice/icm/digital/d_and/cfunc.mod +++ b/src/xspice/icm/digital/d_and/cfunc.mod @@ -168,7 +168,7 @@ void cm_d_and(ARGS) if (val == *out) { /* output value is not changing */ OUTPUT_CHANGED(out) = FALSE; - } else { /* output value not changing */ + } else { switch (val) { /* fall to zero value */ @@ -209,6 +209,14 @@ void cm_d_and(ARGS) /* Third value: cancel earlier change and output as usual. */ cm_schedule_output(1, 0, (idp->when - TIME) / 2.0, &ov); + if (val == UNKNOWN) { + /* Delay based in idp->prev, not *out. */ + + if (idp->prev == ZERO) + OUTPUT_DELAY(out) = PARAM(rise_delay); + else + OUTPUT_DELAY(out) = PARAM(fall_delay); + } idp->when = TIME + OUTPUT_DELAY(out); // Actual output time } else { /* Changing back: override pending change. */ diff --git a/src/xspice/icm/digital/d_buffer/cfunc.mod b/src/xspice/icm/digital/d_buffer/cfunc.mod index 92a6e6734..1ee0f75cc 100644 --- a/src/xspice/icm/digital/d_buffer/cfunc.mod +++ b/src/xspice/icm/digital/d_buffer/cfunc.mod @@ -176,6 +176,14 @@ void cm_d_buffer(ARGS) /* Third value: cancel earlier change and output as usual. */ cm_schedule_output(1, 0, (idp->when - TIME) / 2.0, &ov); + if (val == UNKNOWN) { + /* Delay based in idp->prev, not *out. */ + + if (idp->prev == ZERO) + OUTPUT_DELAY(out) = PARAM(rise_delay); + else + OUTPUT_DELAY(out) = PARAM(fall_delay); + } idp->when = TIME + OUTPUT_DELAY(out); // Actual output time } else { /* Changing back: override pending change. */ diff --git a/src/xspice/icm/digital/d_inverter/cfunc.mod b/src/xspice/icm/digital/d_inverter/cfunc.mod index ea7856d8c..cb76cf874 100644 --- a/src/xspice/icm/digital/d_inverter/cfunc.mod +++ b/src/xspice/icm/digital/d_inverter/cfunc.mod @@ -147,7 +147,7 @@ void cm_d_inverter(ARGS) if (val == *out) { /* output value is changing */ OUTPUT_CHANGED(out) = FALSE; - } else { /* output value not changing */ + } else { switch (val) { /* fall to zero value */ @@ -186,6 +186,14 @@ void cm_d_inverter(ARGS) /* Third value: cancel earlier change and output as usual. */ cm_schedule_output(1, 0, (idp->when - TIME) / 2.0, &ov); + if (val == UNKNOWN) { + /* Delay based in idp->prev, not *out. */ + + if (idp->prev == ZERO) + OUTPUT_DELAY(out) = PARAM(rise_delay); + else + OUTPUT_DELAY(out) = PARAM(fall_delay); + } idp->when = TIME + OUTPUT_DELAY(out); // Actual output time } else { /* Changing back: override pending change. */ diff --git a/src/xspice/icm/digital/d_nor/cfunc.mod b/src/xspice/icm/digital/d_nor/cfunc.mod index 883ef90d7..85e5561c7 100644 --- a/src/xspice/icm/digital/d_nor/cfunc.mod +++ b/src/xspice/icm/digital/d_nor/cfunc.mod @@ -175,7 +175,7 @@ void cm_d_nor(ARGS) if (val == *out) { /* output value is not changing */ OUTPUT_CHANGED(out) = FALSE; - } else { /* output value not changing */ + } else { switch (val) { /* fall to zero value */ @@ -214,6 +214,14 @@ void cm_d_nor(ARGS) /* Third value: cancel earlier change and output as usual. */ cm_schedule_output(1, 0, (idp->when - TIME) / 2.0, &ov); + if (val == UNKNOWN) { + /* Delay based in idp->prev, not *out. */ + + if (idp->prev == ZERO) + OUTPUT_DELAY(out) = PARAM(rise_delay); + else + OUTPUT_DELAY(out) = PARAM(fall_delay); + } idp->when = TIME + OUTPUT_DELAY(out); // Actual output time } else { /* Changing back: override pending change. */