mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 08:55:05 -04:00
analyser is able to analyse sequential circuits build with D flipflops
This commit is contained in:
parent
9123aba31c
commit
a2c761266b
@ -4,9 +4,12 @@ import de.neemann.digital.analyse.expression.BitSetter;
|
||||
import de.neemann.digital.analyse.quinemc.BoolTableIntArray;
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.flipflops.FlipflopD;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Analyses a given model.
|
||||
@ -30,11 +33,33 @@ public class ModelAnalyser {
|
||||
public ModelAnalyser(Model model) throws AnalyseException {
|
||||
this.model = model;
|
||||
inputs = checkBinary(model.getInputs());
|
||||
outputs = checkBinary(model.getOutputs());
|
||||
|
||||
int i = 0;
|
||||
List<FlipflopD> flipflops = model.findNode(FlipflopD.class);
|
||||
for (FlipflopD ff : flipflops) {
|
||||
ff.getDInput().removeObserver(ff); // turn off flipflop
|
||||
String label = ff.getLabel();
|
||||
if (label.length() == 0)
|
||||
throw new AnalyseException(Lang.get("err_DFlipflopWithoutALabel"));
|
||||
|
||||
if (!label.endsWith("n"))
|
||||
label += "n";
|
||||
|
||||
outputs.add(i++, new Model.Signal(label + "+1", ff.getDInput()));
|
||||
|
||||
ObservableValue q = ff.getOutputs().get(0);
|
||||
inputs.add(new Model.Signal(label, q));
|
||||
|
||||
ObservableValue notQ = ff.getOutputs().get(1);
|
||||
if (notQ.observerCount() > 0)
|
||||
q.addObserver(() -> notQ.setValue(~q.getValue()));
|
||||
}
|
||||
|
||||
if (inputs.size() == 0)
|
||||
throw new AnalyseException(Lang.get("err_analyseNoInputs"));
|
||||
if (inputs.size() > 9)
|
||||
throw new AnalyseException(Lang.get("err_toManyInputs_N", 9));
|
||||
outputs = checkBinary(model.getOutputs());
|
||||
if (outputs.size() == 0)
|
||||
throw new AnalyseException(Lang.get("err_analyseNoOutputs"));
|
||||
rows = 1 << inputs.size();
|
||||
|
@ -87,4 +87,17 @@ public class FlipflopD extends Node implements Element {
|
||||
model.addSignal(label, q);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the D input
|
||||
*/
|
||||
public ObservableValue getDInput() {
|
||||
return dVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
@ -109,10 +109,8 @@ public class TableDialog extends JDialog {
|
||||
JMenu sizeMenu = new JMenu(Lang.get("menu_table_size"));
|
||||
for (int i = 2; i <= 8; i++)
|
||||
sizeMenu.add(new JMenuItem(new SizeAction(i)));
|
||||
if (Main.enableExperimental()) {
|
||||
for (int i = 2; i <= 5; i++)
|
||||
sizeMenu.add(new JMenuItem(new SizeSequentialAction(i)));
|
||||
}
|
||||
for (int i = 2; i <= 5; i++)
|
||||
sizeMenu.add(new JMenuItem(new SizeSequentialAction(i)));
|
||||
bar.add(sizeMenu);
|
||||
|
||||
reorderMenu = new JMenu(Lang.get("menu_table_reorder"));
|
||||
|
@ -176,6 +176,7 @@ err_notAllOutputsSameBits=Es haben nicht alle Ausg\u00E4nge die gleiche Bitbreit
|
||||
err_notAllOutputsSupportHighZ=Wenn mehrere Ausg\u00E4nge verbunden sind, m\u00FCssen alle Ausg\u00E4nge Tri-State Ausg\u00E4nge sein
|
||||
err_breakTimeOut=Nach {0} Zyklen ist kein Break aufgetreten
|
||||
err_labelNotConnectedToNet_N=Ein Tunnel {0} ist nicht verbunden!
|
||||
err_DFlipflopWithoutALabel=D-Flipflop hat keinen Label!
|
||||
err_analyseNoInputs=Die Schaltung hat keine benannten Eing\u00E4nge
|
||||
err_analyseNoOutputs=Die Schaltung hat keine benannten Ausg\u00E4nge
|
||||
err_analyseValue_N_IsNotBinary=Der Wert {0} hat mehr als ein Bit.
|
||||
|
@ -309,6 +309,7 @@ key_Width_tt=With of symbol if this circuit is used in an element ins an other c
|
||||
err_analyseNoInputs=The circuit has no Inputs
|
||||
err_analyseNoOutputs=The circuit has no outputs
|
||||
err_analyseValue_N_IsNotBinary=The value {0} has more the one bit.
|
||||
err_DFlipflopWithoutALabel=D-Flipflop has no label set
|
||||
msg_annalyseErr=Error analysing the circuit
|
||||
win_table=Table
|
||||
win_allSolutions=All possible solutions
|
||||
|
Loading…
x
Reference in New Issue
Block a user