mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
Nodes now has a state flag which is true if the node has a state.
Combinatorial elements don't have a state, flipflops do.
This commit is contained in:
parent
a19c191076
commit
3848d8985a
@ -2,10 +2,7 @@ package de.neemann.digital.analyse;
|
|||||||
|
|
||||||
import de.neemann.digital.analyse.expression.BitSetter;
|
import de.neemann.digital.analyse.expression.BitSetter;
|
||||||
import de.neemann.digital.analyse.quinemc.BoolTableIntArray;
|
import de.neemann.digital.analyse.quinemc.BoolTableIntArray;
|
||||||
import de.neemann.digital.core.Model;
|
import de.neemann.digital.core.*;
|
||||||
import de.neemann.digital.core.NodeException;
|
|
||||||
import de.neemann.digital.core.ObservableValue;
|
|
||||||
import de.neemann.digital.core.Signal;
|
|
||||||
import de.neemann.digital.core.flipflops.FlipflopD;
|
import de.neemann.digital.core.flipflops.FlipflopD;
|
||||||
import de.neemann.digital.lang.Lang;
|
import de.neemann.digital.lang.Lang;
|
||||||
|
|
||||||
@ -36,6 +33,10 @@ public class ModelAnalyser {
|
|||||||
inputs = checkBinary(model.getInputs());
|
inputs = checkBinary(model.getInputs());
|
||||||
outputs = checkBinary(model.getOutputs());
|
outputs = checkBinary(model.getOutputs());
|
||||||
|
|
||||||
|
for (Node n : model)
|
||||||
|
if (n.hasState() && !(n instanceof FlipflopD))
|
||||||
|
throw new AnalyseException(Lang.get("err_cannotAnalyse_N", n.getClass().getSimpleName()));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
List<FlipflopD> flipflops = model.findNode(FlipflopD.class);
|
List<FlipflopD> flipflops = model.findNode(FlipflopD.class);
|
||||||
for (FlipflopD ff : flipflops) {
|
for (FlipflopD ff : flipflops) {
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
package de.neemann.digital.core;
|
package de.neemann.digital.core;
|
||||||
|
|
||||||
import de.neemann.digital.core.memory.ROM;
|
|
||||||
import de.neemann.digital.core.wiring.Break;
|
import de.neemann.digital.core.wiring.Break;
|
||||||
import de.neemann.digital.core.wiring.Clock;
|
import de.neemann.digital.core.wiring.Clock;
|
||||||
import de.neemann.digital.core.wiring.Reset;
|
import de.neemann.digital.core.wiring.Reset;
|
||||||
import de.neemann.digital.lang.Lang;
|
import de.neemann.digital.lang.Lang;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Model contains all the nodes of the model.
|
* The Model contains all the nodes of the model.
|
||||||
@ -38,7 +34,7 @@ import java.util.List;
|
|||||||
* @author hneemann
|
* @author hneemann
|
||||||
* @see de.neemann.digital.core.element.Element#registerNodes(Model)
|
* @see de.neemann.digital.core.element.Element#registerNodes(Model)
|
||||||
*/
|
*/
|
||||||
public class Model {
|
public class Model implements Iterable<Node> {
|
||||||
/**
|
/**
|
||||||
* Maximal number of calculation loops before oscillating behaviour is detected
|
* Maximal number of calculation loops before oscillating behaviour is detected
|
||||||
*/
|
*/
|
||||||
@ -47,10 +43,10 @@ public class Model {
|
|||||||
private final ArrayList<Clock> clocks;
|
private final ArrayList<Clock> clocks;
|
||||||
private final ArrayList<Break> breaks;
|
private final ArrayList<Break> breaks;
|
||||||
private final ArrayList<Reset> resets;
|
private final ArrayList<Reset> resets;
|
||||||
|
|
||||||
private final ArrayList<Signal> signals;
|
private final ArrayList<Signal> signals;
|
||||||
private final ArrayList<Signal> inputs;
|
private final ArrayList<Signal> inputs;
|
||||||
private final ArrayList<Signal> outputs;
|
private final ArrayList<Signal> outputs;
|
||||||
private final ArrayList<ROM> roms;
|
|
||||||
|
|
||||||
private final ArrayList<Node> nodes;
|
private final ArrayList<Node> nodes;
|
||||||
private final ArrayList<ModelStateObserver> observers;
|
private final ArrayList<ModelStateObserver> observers;
|
||||||
@ -69,7 +65,6 @@ public class Model {
|
|||||||
this.signals = new ArrayList<>();
|
this.signals = new ArrayList<>();
|
||||||
this.outputs = new ArrayList<>();
|
this.outputs = new ArrayList<>();
|
||||||
this.inputs = new ArrayList<>();
|
this.inputs = new ArrayList<>();
|
||||||
this.roms = new ArrayList<>();
|
|
||||||
this.nodes = new ArrayList<>();
|
this.nodes = new ArrayList<>();
|
||||||
this.nodesToUpdateAct = new ArrayList<>();
|
this.nodesToUpdateAct = new ArrayList<>();
|
||||||
this.nodesToUpdateNext = new ArrayList<>();
|
this.nodesToUpdateNext = new ArrayList<>();
|
||||||
@ -433,23 +428,6 @@ public class Model {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* registers a ROM to the model
|
|
||||||
*
|
|
||||||
* @param rom the ROM
|
|
||||||
*/
|
|
||||||
public void addRomListing(ROM rom) {
|
|
||||||
roms.add(rom);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return all registered Roms
|
|
||||||
*/
|
|
||||||
public ArrayList<ROM> getRoms() {
|
|
||||||
return roms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fires a model changed event to all listeners
|
* fires a model changed event to all listeners
|
||||||
*/
|
*/
|
||||||
@ -478,4 +456,9 @@ public class Model {
|
|||||||
found.add((NODE) n);
|
found.add((NODE) n);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Node> iterator() {
|
||||||
|
return nodes.iterator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,26 @@ package de.neemann.digital.core;
|
|||||||
*/
|
*/
|
||||||
public abstract class Node implements Observer {
|
public abstract class Node implements Observer {
|
||||||
|
|
||||||
|
private final boolean hasState;
|
||||||
private Model model;
|
private Model model;
|
||||||
private int version;
|
private int version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new stateless Node
|
||||||
|
*/
|
||||||
|
public Node() {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new node
|
||||||
|
*
|
||||||
|
* @param hasState true if node has a state
|
||||||
|
*/
|
||||||
|
public Node(boolean hasState) {
|
||||||
|
this.hasState = hasState;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the model for this node.
|
* Sets the model for this node.
|
||||||
*
|
*
|
||||||
@ -58,4 +75,11 @@ public abstract class Node implements Observer {
|
|||||||
model.add(this);
|
model.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the element has a state and is not only combinatorial
|
||||||
|
*/
|
||||||
|
public boolean hasState() {
|
||||||
|
return hasState;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ public class FlipflopD extends Node implements Element {
|
|||||||
* @param attributes the attributes
|
* @param attributes the attributes
|
||||||
*/
|
*/
|
||||||
public FlipflopD(ElementAttributes attributes) {
|
public FlipflopD(ElementAttributes attributes) {
|
||||||
|
super(true);
|
||||||
bits = attributes.getBits();
|
bits = attributes.getBits();
|
||||||
this.q = new ObservableValue("Q", bits);
|
this.q = new ObservableValue("Q", bits);
|
||||||
this.qn = new ObservableValue("\u00ACQ", bits);
|
this.qn = new ObservableValue("\u00ACQ", bits);
|
||||||
|
@ -43,6 +43,7 @@ public class FlipflopJK extends Node implements Element {
|
|||||||
* @param attributes the attributes
|
* @param attributes the attributes
|
||||||
*/
|
*/
|
||||||
public FlipflopJK(ElementAttributes attributes) {
|
public FlipflopJK(ElementAttributes attributes) {
|
||||||
|
super(true);
|
||||||
this.q = new ObservableValue("Q", 1);
|
this.q = new ObservableValue("Q", 1);
|
||||||
this.qn = new ObservableValue("\u00ACQ", 1);
|
this.qn = new ObservableValue("\u00ACQ", 1);
|
||||||
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
||||||
|
@ -43,6 +43,7 @@ public class FlipflopRS extends Node implements Element {
|
|||||||
* @param attributes the attributes
|
* @param attributes the attributes
|
||||||
*/
|
*/
|
||||||
public FlipflopRS(ElementAttributes attributes) {
|
public FlipflopRS(ElementAttributes attributes) {
|
||||||
|
super(true);
|
||||||
this.q = new ObservableValue("Q", 1);
|
this.q = new ObservableValue("Q", 1);
|
||||||
this.qn = new ObservableValue("\u00ACQ", 1);
|
this.qn = new ObservableValue("\u00ACQ", 1);
|
||||||
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
||||||
|
@ -41,6 +41,7 @@ public class FlipflopT extends Node implements Element {
|
|||||||
* @param attributes the attributes
|
* @param attributes the attributes
|
||||||
*/
|
*/
|
||||||
public FlipflopT(ElementAttributes attributes) {
|
public FlipflopT(ElementAttributes attributes) {
|
||||||
|
super(true);
|
||||||
this.q = new ObservableValue("Q", 1);
|
this.q = new ObservableValue("Q", 1);
|
||||||
this.qn = new ObservableValue("\u00ACQ", 1);
|
this.qn = new ObservableValue("\u00ACQ", 1);
|
||||||
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
||||||
|
@ -39,6 +39,7 @@ public class Counter extends Node implements Element {
|
|||||||
* @param attributes the elements attributes
|
* @param attributes the elements attributes
|
||||||
*/
|
*/
|
||||||
public Counter(ElementAttributes attributes) {
|
public Counter(ElementAttributes attributes) {
|
||||||
|
super(true);
|
||||||
int bits = attributes.getBits();
|
int bits = attributes.getBits();
|
||||||
this.out = new ObservableValue("out", bits);
|
this.out = new ObservableValue("out", bits);
|
||||||
this.ovf = new ObservableValue("ovf", 1);
|
this.ovf = new ObservableValue("ovf", 1);
|
||||||
|
@ -53,6 +53,7 @@ public class RAMDualPort extends Node implements Element, RAMInterface {
|
|||||||
* @param attr the elemets attributes
|
* @param attr the elemets attributes
|
||||||
*/
|
*/
|
||||||
public RAMDualPort(ElementAttributes attr) {
|
public RAMDualPort(ElementAttributes attr) {
|
||||||
|
super(true);
|
||||||
bits = attr.get(Keys.BITS);
|
bits = attr.get(Keys.BITS);
|
||||||
output = createOutput();
|
output = createOutput();
|
||||||
addrBits = attr.get(Keys.ADDR_BITS);
|
addrBits = attr.get(Keys.ADDR_BITS);
|
||||||
|
@ -106,11 +106,11 @@ public class ROM extends Node implements Element {
|
|||||||
return listFile;
|
return listFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void setModel(Model model) {
|
* @return true if there is a listing to show
|
||||||
super.setModel(model);
|
*/
|
||||||
if (showList && listFile != null)
|
public boolean showListing() {
|
||||||
model.addRomListing(this);
|
return showList && listFile != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +42,7 @@ public class Register extends Node implements Element {
|
|||||||
* @param attributes the elements attributes
|
* @param attributes the elements attributes
|
||||||
*/
|
*/
|
||||||
public Register(ElementAttributes attributes) {
|
public Register(ElementAttributes attributes) {
|
||||||
|
super(true);
|
||||||
bits = attributes.getBits();
|
bits = attributes.getBits();
|
||||||
this.q = new ObservableValue("Q", bits);
|
this.q = new ObservableValue("Q", bits);
|
||||||
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
||||||
|
@ -625,12 +625,13 @@ public class Main extends JFrame implements ClosingWindowListener.ConfirmSave, E
|
|||||||
|
|
||||||
if (settings.get(Keys.SHOW_LISTING)) {
|
if (settings.get(Keys.SHOW_LISTING)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ROM rom : model.getRoms())
|
for (ROM rom : model.findNode(ROM.class))
|
||||||
try {
|
if (rom.showListing())
|
||||||
windowPosManager.register("rom" + (i++), new ROMListingDialog(this, rom)).setVisible(true);
|
try {
|
||||||
} catch (IOException e) {
|
windowPosManager.register("rom" + (i++), new ROMListingDialog(this, rom)).setVisible(true);
|
||||||
new ErrorMessage(Lang.get("msg_errorReadingListing_N0", rom.getListFile().toString())).addCause(e).show(this);
|
} catch (IOException e) {
|
||||||
}
|
new ErrorMessage(Lang.get("msg_errorReadingListing_N0", rom.getListFile().toString())).addCause(e).show(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,6 +196,7 @@ err_pinMap_noEqualsfound=Kein \"=\" gefunden!
|
|||||||
err_pinMap_NoNameForPin_N=Kein Name f\u00FCr Pin {0}
|
err_pinMap_NoNameForPin_N=Kein Name f\u00FCr Pin {0}
|
||||||
err_pinMap_input_N_notAllowed=Eingang {0} ist nicht erlaubt!
|
err_pinMap_input_N_notAllowed=Eingang {0} ist nicht erlaubt!
|
||||||
err_pinMap_output_N_notAllowed=Ausgang {0} ist nicht erlaubt!
|
err_pinMap_output_N_notAllowed=Ausgang {0} ist nicht erlaubt!
|
||||||
|
err_cannotAnalyse_N=Element {0} kann nicht analysiert werden.
|
||||||
|
|
||||||
attr_dialogTitle=Eigenschaften
|
attr_dialogTitle=Eigenschaften
|
||||||
msg_errorEditingValue=Fehler bei der Eingabe eines Wertes
|
msg_errorEditingValue=Fehler bei der Eingabe eines Wertes
|
||||||
|
@ -176,6 +176,7 @@ err_pinMap_noEqualsfound=No = found!
|
|||||||
err_pinMap_NoNameForPin_N=No Name for pin {0}
|
err_pinMap_NoNameForPin_N=No Name for pin {0}
|
||||||
err_pinMap_input_N_notAllowed=Input {0} not allowed!
|
err_pinMap_input_N_notAllowed=Input {0} not allowed!
|
||||||
err_pinMap_output_N_notAllowed=Output {0} not allowed!
|
err_pinMap_output_N_notAllowed=Output {0} not allowed!
|
||||||
|
err_cannotAnalyse_N=Cannot analyse Node {0}
|
||||||
|
|
||||||
attr_dialogTitle=Attributes
|
attr_dialogTitle=Attributes
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user