diff --git a/src/internals.h b/src/internals.h index 8effe1d..73770f9 100644 --- a/src/internals.h +++ b/src/internals.h @@ -39,8 +39,12 @@ #define NTS 4 #define SMIN 1.e-3 -/* Replaces the "10000" limit used to identiy segment/patch connections */ -#define PCHCON 10000 +/* + * Keep the patch-connection namespace above practical wire-segment counts. + * PCHCON is used to distinguish patch connections from ordinary segment + * connections, so it must not overlap valid generated segment numbers. + */ +#define PCHCON 1000000000 /* carriage return and line feed */ #define CR 0x0d diff --git a/src/reporting.c b/src/reporting.c index 2eebf08..a9c0020 100644 --- a/src/reporting.c +++ b/src/reporting.c @@ -880,11 +880,17 @@ static int process_ex_card(context_t *ctx, const card_t *card, card_state_t *sta if (cabs(voltage) < 1e-20) { voltage = 1.0 + 0.0*I; /* Default to 1 volt */ } - + + /* + * EX specifies a segment relative to its tag, but the queued source is + * subsequently processed using an absolute/global segment number. + */ + int global_seg = segment_number(ctx, tag, seg); + if (extype == 0) { - return add_voltage_source(ctx, tag, seg, voltage); + return add_voltage_source(ctx, tag, global_seg, voltage); } else { - return add_current_source(ctx, tag, seg, voltage); + return add_current_source(ctx, tag, global_seg, voltage); } } else if (extype >= 1 && extype <= 4) {