fixed bug concerning speed testing

This commit is contained in:
hneemann 2016-07-09 22:15:37 +02:00
parent 377674f7c4
commit 7d22c4c273
6 changed files with 23 additions and 9 deletions

View File

@ -31,7 +31,7 @@ This are the main features of Digital:
- You can test your design by creating test cases and execute them.
- Many examples: From a transmission gate D-flipflop to a complete (simple) MIPS-like processor.
- Fast-run mode to perform a simulation without updating the HMI.
A simple processor can be clocked at 3MHz.
A simple processor can be clocked at 100kHz.
- Displaying a LST file when executing assembler programs within such a processor.
- Simple remote TCP interface to allow e.g. an assembler IDE to control the simulator.
- SVG export of circuits, including a LaTeX-compatible SVG version (see [ctan](https://www.ctan.org/tex-archive/info/svg-inkscape))
@ -105,7 +105,7 @@ Logisim works somewhat different, which sometimes leads to surprises like unexpe
If a complete processors is simulated, it is possible to calculate the simulation without an update of the
graphical representation.
A simple processor (see example) can so simulated with a roughly 3MHz clock (Intel® Core ™ i5-3230M CPU @ 2.60GHz)
A simple processor (see example) can so simulated with a roughly 100kHz clock (Intel® Core ™ i5-3230M CPU @ 2.60GHz)
which is suitable also for more complex exercises.
There is a break gate having a single input. If this input changes from low to high this quick run is stopped.
In this way, an assembler instruction BRK can be implemented, which then can be used to insert break points

View File

@ -26,7 +26,7 @@ Folgende Features zeichnen Digital aus:
- Analyse und Synthese von kombinatorischen Schaltungen und Schaltwerken.
- Viele Beispiele: Vom Transmision-Gate D-FF bis zum kompletten MIPS-ähnlichem Prozessor.
- Fast-Run-Mode um eine Simulation ohne Aktualisierung des HMI durchzuführen.
Ein einfacher Prozessor kann mit 3MHz getaktet werden.
Ein einfacher Prozessor kann mit 100kHz getaktet werden.
- Anzeige von LST-Files bei der Ausführung von Assembler-Programmen.
- Einfache Remote TCP-Schnittstelle um z.B. mit einer Assembler-IDE den Simulator zu steuern.
- SVG-Export von Schaltungen, incl. einer LaTeX-tauglichen SVG-Variante (siehe [ctan](ftp://ftp.fau.de/ctan/info/svg-inkscape/InkscapePDFLaTeX.pdf))
@ -97,7 +97,7 @@ Logisim arbeitet hier etwas anders, was gelegentlich zu Überraschungen führt,
### Performance ###
Werden komplette Prozessoren simuliert, ist es möglich die Simulation zu berechnen ohne die grafische Anzeige zu aktualisieren.
Ein einfacher Prozessor (siehe Beispiel) lässt sich so mit etwa 3MHz takten (Intel® Core™ i5-3230M CPU @ 2.60GHz) was auch für
Ein einfacher Prozessor (siehe Beispiel) lässt sich so mit etwa 100kHz takten (Intel® Core™ i5-3230M CPU @ 2.60GHz) was auch für
komplexere Übungen ausreichend ist.
Es gibt ein Break-Gatter welches einen einzelnen Eingang hat. Wechselt dieser Eingang von low auf high wird dieser
schnelle Lauf beendet. Auf diese Weise lässt sich eine Assembler-Anweisung BRK implementieren, womit sich dann Break-Points

View File

@ -49,6 +49,7 @@ public class SpeedTest {
for (int i = 0; i < LOOPCOUNTER; i++) {
state = 1 - state;
clockValue.setValue(state);
model.doStep();
}
loops++;
aktTime = System.currentTimeMillis();

View File

@ -110,16 +110,23 @@ public class RealTimeClock implements ModelStateObserver {
@Override
public void run() {
System.out.println("thread start");
long time= System.currentTimeMillis();
long counter=0;
try {
while (!interrupted()) {
modelSync.accessNEx(() -> {
output.setValue(1 - output.getValue());
model.doStep();
});
counter++;
}
} catch (NodeException e1) {
stopper.showErrorAndStopModel(Lang.get("msg_clockError"), e1);
}
time=System.currentTimeMillis()-time;
System.out.println(counter/time/2+"kHz");
System.out.println("thread end");
}
};

View File

@ -20,6 +20,7 @@ public class GuiModelObserver implements Observer, ModelStateObserver {
private final CircuitComponent component;
private final ModelEvent type;
private boolean changed = false;
private volatile boolean paintPending;
/**
* Creates a new instance.
@ -40,9 +41,13 @@ public class GuiModelObserver implements Observer, ModelStateObserver {
@Override
public void handleEvent(ModelEvent event) {
if (changed && event == type) {
SwingUtilities.invokeLater(() -> {
component.paintImmediately(0, 0, component.getWidth(), component.getHeight());
});
if (!paintPending) {
paintPending = true;
SwingUtilities.invokeLater(() -> {
component.paintImmediately(0, 0, component.getWidth(), component.getHeight());
paintPending = false;
});
}
changed = false;
}
}

View File

@ -255,10 +255,11 @@ public class CircuitComponent extends JComponent {
this.modelSync = modelSync;
if (runMode)
mouseRun.activate();
else
else {
mouseNormal.activate();
circuit.clearState();
}
requestFocusInWindow();
circuit.clearState();
}
/**