adds a not connected symbol

This commit is contained in:
hneemann 2020-11-16 13:02:27 +01:00
parent 27c8478d2d
commit a45808919f
8 changed files with 132 additions and 1 deletions

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2016 Helmut Neemann
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.core.io;
import de.neemann.digital.core.Model;
import de.neemann.digital.core.NodeException;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.ObservableValues;
import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.lang.Lang;
/**
* A constant
*/
public class NotConnected implements Element {
/**
* The Constant description
*/
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(NotConnected.class)
.addAttribute(Keys.BITS);
private final ObservableValue output;
/**
* Creates a new instance
*
* @param attributes the attributes
*/
public NotConnected(ElementAttributes attributes) {
output = new ObservableValue("out", attributes.get(Keys.BITS)).setPinDescription(DESCRIPTION);
output.setToHighZ();
output.setConstant();
}
@Override
public void setInputs(ObservableValues inputs) throws NodeException {
throw new NodeException(Lang.get("err_noInputsAvailable"));
}
@Override
public ObservableValues getOutputs() {
return output.asList();
}
@Override
public void registerNodes(Model model) {
}
}

View File

@ -162,7 +162,8 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
.add(DriverInvSel.DESCRIPTION)
.add(Delay.DESCRIPTION)
.add(PullUp.DESCRIPTION)
.add(PullDown.DESCRIPTION))
.add(PullDown.DESCRIPTION)
.add(NotConnected.DESCRIPTION))
.add(new LibraryNode(Lang.get("lib_mux"))
.add(Multiplexer.DESCRIPTION)
.add(Demultiplexer.DESCRIPTION)

View File

@ -186,6 +186,14 @@ public class Net {
value = new DataBus(this, m, outputs).getReadableOutput();
}
if (outputs.size() > 1) {
for (Pin o : outputs) {
ObservableValue ov = o.getValue();
if (ov.isConstant() && ov.isHighZ())
throw new PinException(Lang.get("err_notConnectedNotAllowed", o), this);
}
}
if (value == null)
throw new PinException(Lang.get("err_output_N_notDefined", outputs.get(0)), this);

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2016 Helmut Neemann
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;
import de.neemann.digital.draw.graphics.Graphic;
import de.neemann.digital.draw.graphics.Style;
import de.neemann.digital.draw.graphics.Vector;
import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
/**
* The ground shape
*/
public class NotConnectedShape implements Shape {
private final PinDescriptions outputs;
/**
* Creates a new instance
*
* @param attr the attributes
* @param inputs the inputs
* @param outputs the outputs
*/
public NotConnectedShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
this.outputs = outputs;
}
@Override
public Pins getPins() {
return new Pins().add(new Pin(new Vector(0, 0), outputs.get(0)));
}
@Override
public Interactor applyStateMonitor(IOState ioState) {
return null;
}
@Override
public void drawTo(Graphic graphic, Style heighLight) {
int rad = SIZE2 / 5 * 3;
graphic.drawLine(new Vector(-rad, -rad), new Vector(rad, rad), Style.NORMAL);
graphic.drawLine(new Vector(-rad, rad), new Vector(rad, -rad), Style.NORMAL);
}
}

View File

@ -105,6 +105,7 @@ public final class ShapeFactory {
map.put(Const.DESCRIPTION.getName(), ConstShape::new);
map.put(Ground.DESCRIPTION.getName(), GroundShape::new);
map.put(VDD.DESCRIPTION.getName(), VDDShape::new);
map.put(NotConnected.DESCRIPTION.getName(), NotConnectedShape::new);
map.put(Out.DESCRIPTION.getName(), OutputShape::new);
map.put(Out.LEDDESCRIPTION.getName(), LEDShape::new);
map.put(LightBulb.DESCRIPTION.getName(), LightBulbShape::new);

View File

@ -334,6 +334,10 @@
<string name="elem_VDD">Betriebsspannung</string>
<string name="elem_VDD_tt">Anschluss zur Betriebsspannung. Gibt immer Eins aus.</string>
<string name="elem_VDD_pin_out">Dieser Ausgang gibt immer 1 aus.</string>
<string name="elem_NotConnected">Nicht Verbunden</string>
<string name="elem_NotConnected_tt">Kann verwendet werden, um eine Leitung auf High-Z zu legen.</string>
<string name="elem_NotConnected_pin_out">Dieser Ausgang gibt immer High-Z aus.</string>
<string name="err_notConnectedNotAllowed">Das Nicht-Verbunden Symbol ist hier nicht erlaubt!</string>
<string name="elem_Const">Konstante</string>
<string name="elem_Const_tt">Ein Element, welches einen konstanten Wert ausgibt. Die Konstante kann über den Attribute-Dialog festgelegt werden.</string>
<string name="elem_Const_pin_out">Gibt den gesetzten Wert als Konstante aus.</string>

View File

@ -331,6 +331,10 @@
<string name="elem_VDD">Supply voltage</string>
<string name="elem_VDD_tt">A connection to the supply voltage. Output is always one.</string>
<string name="elem_VDD_pin_out">This output always returns 1.</string>
<string name="elem_NotConnected">Not Connected</string>
<string name="elem_NotConnected_tt">Can be used to set a wire to High-Z.</string>
<string name="elem_NotConnected_pin_out">This output always outputs High-Z.</string>
<string name="err_notConnectedNotAllowed">The NotConnected symbol is not allowed here!</string>
<string name="elem_Const">Constant value</string>
<string name="elem_Const_tt">A component which returns a given value as a simple constant value. The value can be set in the attribute dialog.</string>
<string name="elem_Const_pin_out">Returns the given value as a constant.</string>

View File

@ -663,6 +663,11 @@
<elementAttributes/>
<pos x="100" y="440"/>
</visualElement>
<visualElement>
<elementName>NotConnected</elementName>
<elementAttributes/>
<pos x="120" y="620"/>
</visualElement>
</visualElements>
<wires>
<wire>