mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-10 13:26:43 -04:00
allows recovering from oscillations
This commit is contained in:
parent
34c9832656
commit
2e22d5fe85
@ -6,6 +6,7 @@ HEAD, planned as v0.31
|
|||||||
- FSM editor highlights the current transition
|
- FSM editor highlights the current transition
|
||||||
- Adds drivers with inverted output
|
- Adds drivers with inverted output
|
||||||
- Adds a minified circuit as a new shape for embedded circuits
|
- Adds a minified circuit as a new shape for embedded circuits
|
||||||
|
- Allows recovering from oscillations.
|
||||||
|
|
||||||
v0.30, released on 3. February 2023
|
v0.30, released on 3. February 2023
|
||||||
- Added a search function
|
- Added a search function
|
||||||
|
@ -80,6 +80,7 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
private AsyncSeq asyncInfos;
|
private AsyncSeq asyncInfos;
|
||||||
private boolean asyncMode = false;
|
private boolean asyncMode = false;
|
||||||
private boolean allowGlobalValues = false;
|
private boolean allowGlobalValues = false;
|
||||||
|
private boolean recoverFromOscillation = false;
|
||||||
private File rootPath;
|
private File rootPath;
|
||||||
|
|
||||||
private final ArrayList<ModelStateObserver> observers;
|
private final ArrayList<ModelStateObserver> observers;
|
||||||
@ -293,20 +294,21 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
try {
|
try {
|
||||||
if (cond.doNextMicroStep()) {
|
if (cond.doNextMicroStep()) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
oscillatingNodes = null;
|
||||||
while (cond.doNextMicroStep() && state != State.CLOSED) {
|
while (cond.doNextMicroStep() && state != State.CLOSED) {
|
||||||
if (counter++ > oscillationDetectionCounter) {
|
if (counter++ > oscillationDetectionCounter) {
|
||||||
if (oscillatingNodes == null)
|
if (oscillatingNodes == null)
|
||||||
oscillatingNodes = new HashSet<>();
|
oscillatingNodes = new HashSet<>();
|
||||||
if (counter > oscillationDetectionCounter + COLLECTING_LOOP_COUNTER_OFFS) {
|
if (counter > oscillationDetectionCounter + COLLECTING_LOOP_COUNTER_OFFS) {
|
||||||
NodeException seemsToOscillate = new NodeException(Lang.get("err_seemsToOscillate")).addNodes(oscillatingNodes);
|
throw new NodeException(Lang.get("err_seemsToOscillate")).addNodes(oscillatingNodes);
|
||||||
oscillatingNodes = null;
|
|
||||||
throw seemsToOscillate;
|
|
||||||
} else {
|
} else {
|
||||||
oscillatingNodes.addAll(nodesToUpdateNext);
|
oscillatingNodes.addAll(nodesToUpdateNext);
|
||||||
}
|
}
|
||||||
}
|
doMicroStep(noise || recoverFromOscillation);
|
||||||
|
} else {
|
||||||
doMicroStep(noise);
|
doMicroStep(noise);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// if a calculation is initiated but there is nothing to do because there was
|
// if a calculation is initiated but there is nothing to do because there was
|
||||||
// no gate input change, perform a burn check to detect short circuits caused by
|
// no gate input change, perform a burn check to detect short circuits caused by
|
||||||
@ -947,6 +949,20 @@ public class Model implements Iterable<Node>, SyncAccess {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I set, the model tries to recover from oszillation by introducing noise
|
||||||
|
* to the model execution.
|
||||||
|
* Use with extreme care because is covers bugs in the simulation that lead
|
||||||
|
* to an unpredictable behaviour and makes the simulation very slow!
|
||||||
|
*
|
||||||
|
* @param recoverFromOscillation if true, the model tries to recover from an oszillation
|
||||||
|
* @return this for chained calls
|
||||||
|
*/
|
||||||
|
public Model setRecoverFromOscillation(boolean recoverFromOscillation) {
|
||||||
|
this.recoverFromOscillation = recoverFromOscillation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets async execution infos
|
* Sets async execution infos
|
||||||
*
|
*
|
||||||
|
@ -566,7 +566,13 @@ public final class Keys {
|
|||||||
new Key.KeyInteger("oscillationDetectionCounter", 1000)
|
new Key.KeyInteger("oscillationDetectionCounter", 1000)
|
||||||
.setComboBoxValues(1000, 5000, 10000)
|
.setComboBoxValues(1000, 5000, 10000)
|
||||||
.setMin(1000)
|
.setMin(1000)
|
||||||
.setMax(100000);
|
.setMax(100000).setSecondary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counter used to detect oscillations
|
||||||
|
*/
|
||||||
|
public static final Key<Boolean> RECOVER_FROM_OSCILLATION =
|
||||||
|
new Key<>("recoverFromOscillation", false).setSecondary();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* output format for numbers
|
* output format for numbers
|
||||||
|
@ -1475,6 +1475,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
modelCreator = new ModelCreator(circuitComponent.getCircuit(), library);
|
modelCreator = new ModelCreator(circuitComponent.getCircuit(), library);
|
||||||
model = modelCreator.createModel(true);
|
model = modelCreator.createModel(true);
|
||||||
|
|
||||||
|
model.setRecoverFromOscillation(circuitComponent.getCircuit().getAttributes().get(Keys.RECOVER_FROM_OSCILLATION));
|
||||||
|
|
||||||
time = System.currentTimeMillis() - time;
|
time = System.currentTimeMillis() - time;
|
||||||
LOGGER.debug("model creation: " + time + " ms, " + model.getNodes().size() + " nodes");
|
LOGGER.debug("model creation: " + time + " ms, " + model.getNodes().size() + " nodes");
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
ATTR_LIST.add(Keys.PINCOUNT);
|
ATTR_LIST.add(Keys.PINCOUNT);
|
||||||
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
|
ATTR_LIST.add(Keys.BACKGROUND_COLOR);
|
||||||
ATTR_LIST.add(Keys.DESCRIPTION);
|
ATTR_LIST.add(Keys.DESCRIPTION);
|
||||||
ATTR_LIST.add(Keys.OSCILLATION_DETECTION_COUNTER);
|
|
||||||
ATTR_LIST.add(Keys.LOCKED_MODE);
|
ATTR_LIST.add(Keys.LOCKED_MODE);
|
||||||
ATTR_LIST.add(Keys.ROMMANAGER);
|
ATTR_LIST.add(Keys.ROMMANAGER);
|
||||||
ATTR_LIST.add(Keys.SHOW_DATA_TABLE);
|
ATTR_LIST.add(Keys.SHOW_DATA_TABLE);
|
||||||
@ -94,6 +93,8 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
|||||||
ATTR_LIST.add(Keys.BIG_ENDIAN_SETTING);
|
ATTR_LIST.add(Keys.BIG_ENDIAN_SETTING);
|
||||||
ATTR_LIST.add(Keys.SKIP_HDL);
|
ATTR_LIST.add(Keys.SKIP_HDL);
|
||||||
ATTR_LIST.add(Keys.IS_GENERIC);
|
ATTR_LIST.add(Keys.IS_GENERIC);
|
||||||
|
ATTR_LIST.add(Keys.OSCILLATION_DETECTION_COUNTER);
|
||||||
|
ATTR_LIST.add(Keys.RECOVER_FROM_OSCILLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1684,6 +1684,8 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
|||||||
<string name="key_oscillationDetectionCounter">Oszillationserkennung</string>
|
<string name="key_oscillationDetectionCounter">Oszillationserkennung</string>
|
||||||
<string name="key_oscillationDetectionCounter_tt">Anzahl der Gatterlaufzeiten, bei der eine Oszillation erkannt
|
<string name="key_oscillationDetectionCounter_tt">Anzahl der Gatterlaufzeiten, bei der eine Oszillation erkannt
|
||||||
wird, wenn sich die Schaltung bis dahin noch nicht stabilisiert hat.</string>
|
wird, wenn sich die Schaltung bis dahin noch nicht stabilisiert hat.</string>
|
||||||
|
<string name="key_recoverFromOscillation">Bei Oszillationen mit Zufallswerten weitermachen.</string>
|
||||||
|
<string name="key_recoverFromOscillation_tt">Wird diese Option gesetzt, wird das Verhalten der Simulation im Falle einer Oszillation unvorhersehbar und zudem extrem langsam!</string>
|
||||||
|
|
||||||
<string name="key_telnetEscape">Telnet-Modus</string>
|
<string name="key_telnetEscape">Telnet-Modus</string>
|
||||||
<string name="key_telnetEscape_tt">Wenn gesetzt, werden die Telnet Steuerkommandos ausgewertet.
|
<string name="key_telnetEscape_tt">Wenn gesetzt, werden die Telnet Steuerkommandos ausgewertet.
|
||||||
|
@ -1667,6 +1667,8 @@
|
|||||||
<string name="key_oscillationDetectionCounter">Oscillation detection</string>
|
<string name="key_oscillationDetectionCounter">Oscillation detection</string>
|
||||||
<string name="key_oscillationDetectionCounter_tt">Number of gate propagation times at which a oscillation is
|
<string name="key_oscillationDetectionCounter_tt">Number of gate propagation times at which a oscillation is
|
||||||
detected if the circuit has not stabilized by then.</string>
|
detected if the circuit has not stabilized by then.</string>
|
||||||
|
<string name="key_recoverFromOscillation">In case of oscillations, continue with random values.</string>
|
||||||
|
<string name="key_recoverFromOscillation_tt">If this option is set, the behavior of the simulation becomes unpredictable and extremely slow if there is an oscillation!</string>
|
||||||
|
|
||||||
<string name="key_telnetEscape">Telnet mode</string>
|
<string name="key_telnetEscape">Telnet mode</string>
|
||||||
<string name="key_telnetEscape_tt">If set, the Telnet control commands are evaluated.
|
<string name="key_telnetEscape_tt">If set, the Telnet control commands are evaluated.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user