Added a driver with inverted select input.

This makes it possible to implement transmission gates more simple.
This commit is contained in:
hneemann 2016-06-08 12:41:06 +02:00
parent 26bfe62954
commit 18f05c13d3
7 changed files with 78 additions and 5 deletions

View File

@ -53,7 +53,17 @@ public class Driver extends Node implements Element {
@Override
public void writeOutputs() throws NodeException {
output.set(value, !sel);
output.set(value, isOutHigh(sel));
}
/**
* Returns the highZ state depending of the sel state
*
* @param sel the selected input
* @return the highZ state
*/
protected boolean isOutHigh(boolean sel) {
return !sel;
}
@Override

View File

@ -0,0 +1,39 @@
package de.neemann.digital.core.wiring;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import static de.neemann.digital.core.element.PinInfo.input;
/**
* The Driver
*
* @author hneemann
*/
public class DriverInvSel extends Driver {
/**
* The Driver description
*/
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(DriverInvSel.class,
input("in"),
input("sel"))
.addAttribute(Keys.ROTATE)
.addAttribute(Keys.BITS)
.addAttribute(Keys.FLIP_SEL_POSITON);
/**
* Creates a new instance
*
* @param attributes the attributes
*/
public DriverInvSel(ElementAttributes attributes) {
super(attributes);
}
@Override
protected boolean isOutHigh(boolean sel) {
return sel;
}
}

View File

@ -66,6 +66,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
add(Delay.DESCRIPTION, menu);
add(Tunnel.DESCRIPTION, menu);
add(Driver.DESCRIPTION, menu);
add(DriverInvSel.DESCRIPTION, menu);
add(Reset.DESCRIPTION, menu);
add(Break.DESCRIPTION, menu);

View File

@ -22,6 +22,7 @@ import static de.neemann.digital.draw.shapes.GenericShape.SIZE2;
*/
public class DriverShape implements Shape {
private final boolean bottom;
private final boolean invertedInput;
private final PinDescriptions inputs;
private final PinDescriptions outputs;
private Pins pins;
@ -34,9 +35,21 @@ public class DriverShape implements Shape {
* @param outputs the outputs
*/
public DriverShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs) {
this(attr, inputs, outputs, false);
}
/**
* Creates a new instance
*
* @param attr the attributes
* @param inputs the inputs
* @param outputs the outputs
*/
public DriverShape(ElementAttributes attr, PinDescriptions inputs, PinDescriptions outputs, boolean invertedInput) {
this.inputs = inputs;
this.outputs = outputs;
this.bottom = attr.get(Keys.FLIP_SEL_POSITON);
this.invertedInput = invertedInput;
}
@Override
@ -63,9 +76,16 @@ public class DriverShape implements Shape {
.add(SIZE - 1, 0)
.add(-SIZE + 1, SIZE2 + 2), Style.NORMAL
);
if (bottom)
graphic.drawLine(new Vector(0, SIZE), new Vector(0, 7), Style.NORMAL);
else
graphic.drawLine(new Vector(0, -SIZE), new Vector(0, -7), Style.NORMAL);
if (bottom) {
if (invertedInput)
graphic.drawCircle(new Vector(-SIZE2 + 4, SIZE), new Vector(SIZE2 - 4, 8), Style.NORMAL);
else
graphic.drawLine(new Vector(0, SIZE), new Vector(0, 7), Style.NORMAL);
} else {
if (invertedInput)
graphic.drawCircle(new Vector(-SIZE2 + 4, -SIZE), new Vector(SIZE2 - 4, -8), Style.NORMAL);
else
graphic.drawLine(new Vector(0, -SIZE), new Vector(0, -7), Style.NORMAL);
}
}
}

View File

@ -92,6 +92,7 @@ public final class ShapeFactory {
map.put(Splitter.DESCRIPTION.getName(), SplitterShape::new);
map.put(Driver.DESCRIPTION.getName(), DriverShape::new);
map.put(DriverInvSel.DESCRIPTION.getName(), (attributes, inputs, outputs) -> new DriverShape(attributes, inputs, outputs, true));
map.put(Tunnel.DESCRIPTION.getName(), TunnelShape::new);
map.put(DummyElement.TEXTDESCRIPTION.getName(), TextShape::new);

View File

@ -103,6 +103,7 @@ elem_Clock_tt=Ein Takstignal. Dieses Taksignal kann \u00FCber die Echtzeituhr ge
elem_Delay=Verz\u00F6gerung
elem_Delay_tt=Verz\u00F6gert ein Signal f\u00FCr eine Gatterlaufzeit.
elem_Driver=Treiber
elem_DriverInvSel=Treiber, invertierte Auswahl
elem_Reset=Reset
elem_Reset_tt=Der Ausgang dieses Elements ist Null, solange sich die Schaltung nach dem Einschalten in der Stabilisierungsphase befindet.\nHat sich die Schaltung stabilisiert wird der Ausgang auf Eins gesetzt.
elem_Break=Break

View File

@ -91,6 +91,7 @@ elem_Clock_tt=A clock signal. Its possible to control it by the real time clock.
elem_Delay=Delay
elem_Delay_tt=Delays the signal by on gate delay
elem_Driver=Driver
elem_DriverInvSel=Driver, inverted select
elem_Reset=Reset
elem_Reset_tt=The output of this element is hold down during the initialisation of the circuit.\nAfter the circuit has stabilized the output goes up.
elem_Break=Break