mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-10 13:26:43 -04:00
reset gates are usable in async mode
This commit is contained in:
parent
8ef8c9895a
commit
bc43f0433b
@ -74,6 +74,7 @@ public class Model implements Iterable<Node> {
|
|||||||
private HashSet<Node> oscillatingNodes;
|
private HashSet<Node> oscillatingNodes;
|
||||||
private boolean isInvalidSignal = false;
|
private boolean isInvalidSignal = false;
|
||||||
private AsyncSeq asyncInfos;
|
private AsyncSeq asyncInfos;
|
||||||
|
private boolean asyncMode = false;
|
||||||
|
|
||||||
private final ArrayList<ModelStateObserver> observers;
|
private final ArrayList<ModelStateObserver> observers;
|
||||||
private ArrayList<ModelStateObserver> observersStep;
|
private ArrayList<ModelStateObserver> observersStep;
|
||||||
@ -96,6 +97,17 @@ public class Model implements Iterable<Node> {
|
|||||||
this.observers = new ArrayList<>();
|
this.observers = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets this model to async mode.
|
||||||
|
* Async mode means that the circuit is not able to reach a stable state once the reset gates are released.
|
||||||
|
*
|
||||||
|
* @return this for chained calls
|
||||||
|
*/
|
||||||
|
public Model setAsyncMode() {
|
||||||
|
this.asyncMode = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the window position manager.
|
* Sets the window position manager.
|
||||||
* Allows the model to place new and close old gui windows.
|
* Allows the model to place new and close old gui windows.
|
||||||
@ -168,7 +180,8 @@ public class Model implements Iterable<Node> {
|
|||||||
if (!resets.isEmpty()) {
|
if (!resets.isEmpty()) {
|
||||||
for (Reset reset : resets)
|
for (Reset reset : resets)
|
||||||
reset.clearReset();
|
reset.clearReset();
|
||||||
doStep(false);
|
if (!asyncMode)
|
||||||
|
doStep(false);
|
||||||
}
|
}
|
||||||
LOGGER.debug("stabilizing took " + version + " micro steps");
|
LOGGER.debug("stabilizing took " + version + " micro steps");
|
||||||
state = State.RUNNING;
|
state = State.RUNNING;
|
||||||
|
@ -1194,10 +1194,15 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
// no real clock
|
// no real clock
|
||||||
AsyncSeq ai = model.getAsyncInfos();
|
AsyncSeq ai = model.getAsyncInfos();
|
||||||
if (ai != null && ai.getFrequency() > 0) {
|
if (ai != null && ai.getFrequency() > 0) {
|
||||||
|
|
||||||
|
if (!model.getClocks().isEmpty())
|
||||||
|
throw new RuntimeException(Lang.get("err_clocksNotAllowedInAsyncMode"));
|
||||||
|
|
||||||
modelSync = new LockSync();
|
modelSync = new LockSync();
|
||||||
model.addObserver(
|
model.addObserver(
|
||||||
new AsyncSequentialClock(model, ai, timerExecutor, this, modelSync));
|
new AsyncSequentialClock(model, ai, timerExecutor, this, modelSync));
|
||||||
realTimeClockRunning = true;
|
realTimeClockRunning = true;
|
||||||
|
model.setAsyncMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1235,9 +1240,11 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (NodeException | PinException | RuntimeException | ElementNotFoundException e) {
|
} catch (NodeException | PinException | RuntimeException | ElementNotFoundException e) {
|
||||||
if (model != null)
|
if (model != null) {
|
||||||
|
if (modelSync == null)
|
||||||
|
modelSync = NoSync.INST;
|
||||||
showErrorAndStopModel(Lang.get("msg_errorCreatingModel"), e);
|
showErrorAndStopModel(Lang.get("msg_errorCreatingModel"), e);
|
||||||
else
|
} else
|
||||||
showErrorWithoutARunningModel(Lang.get("msg_errorCreatingModel"), e);
|
showErrorWithoutARunningModel(Lang.get("msg_errorCreatingModel"), e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -897,6 +897,7 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
|||||||
<string name="err_errorAnalysingCircuit_N">Fehler bei der Analyse der Schaltung: {0}</string>
|
<string name="err_errorAnalysingCircuit_N">Fehler bei der Analyse der Schaltung: {0}</string>
|
||||||
<string name="err_romNeedsALabelToBeExported">Jedes ROM braucht eine eindeutige Bezeichnung um exportiert zu werden!</string>
|
<string name="err_romNeedsALabelToBeExported">Jedes ROM braucht eine eindeutige Bezeichnung um exportiert zu werden!</string>
|
||||||
<string name="err_counterNeedsMoreBits">Der Zähler benötigt mindestens zwei Bits.</string>
|
<string name="err_counterNeedsMoreBits">Der Zähler benötigt mindestens zwei Bits.</string>
|
||||||
|
<string name="err_clocksNotAllowedInAsyncMode">Taktelemente können im asynchronen Modus nicht verwendet werden.</string>
|
||||||
|
|
||||||
<string name="key_AddrBits">Adress-Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
|
<string name="key_AddrBits">Adress-Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
|
||||||
<string name="key_AddrBits_tt">Anzahl der Adress-Bits, die verwendet werden.</string>
|
<string name="key_AddrBits_tt">Anzahl der Adress-Bits, die verwendet werden.</string>
|
||||||
|
@ -892,6 +892,7 @@
|
|||||||
<string name="err_romNeedsALabelToBeExported">Every ROM needs a unique label to be exported!</string>
|
<string name="err_romNeedsALabelToBeExported">Every ROM needs a unique label to be exported!</string>
|
||||||
<string name="err_counterNeedsMoreBits">The counter needs at least two bits.</string>
|
<string name="err_counterNeedsMoreBits">The counter needs at least two bits.</string>
|
||||||
<string name="err_namesAreNotUnique_N">The name "{0}" is not unique!</string>
|
<string name="err_namesAreNotUnique_N">The name "{0}" is not unique!</string>
|
||||||
|
<string name="err_clocksNotAllowedInAsyncMode">Clock elements can not be used in asynchronous mode.</string>
|
||||||
|
|
||||||
<string name="key_AddrBits">Address Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
|
<string name="key_AddrBits">Address Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
|
||||||
<string name="key_AddrBits_tt">Number of address bits used.</string>
|
<string name="key_AddrBits_tt">Number of address bits used.</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user