mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-18 09:24:42 -04:00
optimized net creation if nested models are used
This commit is contained in:
parent
c919d824fc
commit
6b7b778313
@ -7,22 +7,25 @@ import de.neemann.digital.core.element.Element;
|
||||
import de.neemann.digital.gui.draw.elements.Circuit;
|
||||
import de.neemann.digital.gui.draw.elements.PinException;
|
||||
import de.neemann.digital.gui.draw.model.ModelDescription;
|
||||
import de.neemann.digital.gui.draw.model.NetList;
|
||||
|
||||
/**
|
||||
* @author hneemann
|
||||
*/
|
||||
public class CustomElement implements Element {
|
||||
|
||||
private Circuit circuit;
|
||||
private ElementLibrary library;
|
||||
private final NetList netList;
|
||||
private final Circuit circuit;
|
||||
private final ElementLibrary library;
|
||||
|
||||
public CustomElement(Circuit circuit, ElementLibrary library) {
|
||||
this.circuit = circuit;
|
||||
this.library = library;
|
||||
netList = new NetList(circuit.getWires());
|
||||
}
|
||||
|
||||
public ModelDescription getModelDescription() throws PinException, NodeException {
|
||||
return new ModelDescription(circuit, library, true);
|
||||
return new ModelDescription(circuit, library, true, new NetList(netList));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,10 +37,13 @@ public class ModelDescription implements Iterable<ModelEntry> {
|
||||
public ModelDescription(Circuit circuit, ElementLibrary library) throws PinException, NodeException {
|
||||
this(circuit, library, false);
|
||||
}
|
||||
|
||||
public ModelDescription(Circuit circuit, ElementLibrary library, boolean readAsCustom) throws PinException, NodeException {
|
||||
this(circuit, library, readAsCustom, new NetList(circuit.getWires()));
|
||||
}
|
||||
|
||||
public ModelDescription(Circuit circuit, ElementLibrary library, boolean readAsCustom, NetList netList) throws PinException, NodeException {
|
||||
this.netList = netList;
|
||||
entries = new ArrayList<>();
|
||||
netList = new NetList(circuit.getWires());
|
||||
if (readAsCustom)
|
||||
ioMap = new HashMap<>();
|
||||
else
|
||||
@ -73,7 +76,6 @@ public class ModelDescription implements Iterable<ModelEntry> {
|
||||
|
||||
for (Pin p : pins)
|
||||
netList.add(p);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,12 @@ public class Net {
|
||||
private final ArrayList<Pin> pins;
|
||||
private final ArrayList<Wire> wires;
|
||||
|
||||
public Net(Net toCopy) {
|
||||
points = toCopy.points; // no deep copy of points necessary
|
||||
wires = null; // wires not needed
|
||||
pins = new ArrayList<>(toCopy.pins); // Pins are changed so create a deep copy
|
||||
}
|
||||
|
||||
public Net(Wire w) {
|
||||
points = new HashSet<>();
|
||||
points.add(w.p1);
|
||||
@ -87,14 +93,15 @@ public class Net {
|
||||
for (Pin i : inputs)
|
||||
i.setValue(value);
|
||||
|
||||
if (bindWiresToValues)
|
||||
if (bindWiresToValues && wires != null)
|
||||
for (Wire w : wires)
|
||||
w.setValue(value);
|
||||
}
|
||||
|
||||
public void setHighLight(boolean highLight) {
|
||||
for (Wire w : wires)
|
||||
w.setHighLight(highLight);
|
||||
if (wires != null)
|
||||
for (Wire w : wires)
|
||||
w.setHighLight(highLight);
|
||||
}
|
||||
|
||||
public boolean containsValue(ObservableValue v) {
|
||||
|
@ -21,6 +21,13 @@ public class NetList implements Iterable<Net> {
|
||||
add(w);
|
||||
}
|
||||
|
||||
public NetList(NetList toCopy) {
|
||||
netList = new ArrayList<>();
|
||||
for (Net net : toCopy)
|
||||
netList.add(new Net(net));
|
||||
}
|
||||
|
||||
|
||||
public void add(NetList netList) {
|
||||
this.netList.addAll(netList.netList);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user