From 29090d3b2c11406167f44f3583d9062053a2df6a Mon Sep 17 00:00:00 2001 From: hneemann Date: Thu, 15 Jun 2017 13:56:52 +0200 Subject: [PATCH] In case of oscillations almost all effected components are shown. --- distribution/ReleaseNotes.txt | 2 +- src/main/java/de/neemann/digital/core/Model.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/distribution/ReleaseNotes.txt b/distribution/ReleaseNotes.txt index 428d96019..0b0a6e81b 100644 --- a/distribution/ReleaseNotes.txt +++ b/distribution/ReleaseNotes.txt @@ -1,7 +1,7 @@ Release Notes planned as v0.13 -- unbuffered circular dependencies are detected during circuit analysis +- In case of oscillations almost all effected components are shown. v0.12.1, released on 05. Jun 2016 - added a fuse to simulate a PROM or PAL. diff --git a/src/main/java/de/neemann/digital/core/Model.java b/src/main/java/de/neemann/digital/core/Model.java index acae3a3b3..8c65152b2 100644 --- a/src/main/java/de/neemann/digital/core/Model.java +++ b/src/main/java/de/neemann/digital/core/Model.java @@ -42,6 +42,7 @@ public class Model implements Iterable { * Maximal number of calculation loops before oscillating behaviour is detected */ public static final int MAX_LOOP_COUNTER = 1000; + private static final int COLLECTING_LOOP_COUNTER = MAX_LOOP_COUNTER + 100; private final ArrayList clocks; private final ArrayList breaks; @@ -58,6 +59,7 @@ public class Model implements Iterable { private int version; private boolean isInitialized = false; private WindowPosManager windowPosManager; + private HashSet oscillatingNodes; /** * Creates a new model @@ -192,7 +194,15 @@ public class Model implements Iterable { if (needsUpdate()) { while (needsUpdate()) { if (counter++ > MAX_LOOP_COUNTER) { - throw new NodeException(Lang.get("err_seemsToOscillate")).addNodes(nodesToUpdateNext); + if (oscillatingNodes == null) + oscillatingNodes = new HashSet<>(); + if (counter > COLLECTING_LOOP_COUNTER) { + NodeException seemsToOscillate = new NodeException(Lang.get("err_seemsToOscillate")).addNodes(oscillatingNodes); + oscillatingNodes = null; + throw seemsToOscillate; + } else { + oscillatingNodes.addAll(nodesToUpdateNext); + } } doMicroStep(noise); }