Search in sources :

Example 1 with NodeWithoutDelay

use of de.neemann.digital.core.NodeWithoutDelay in project Digital by hneemann.

the class InverterConfig method invert.

/**
 * Handles the inverting of a input signal
 * if the given input is not to invert, the original input is returned,
 * If the input is to invert, a inverted input is returned. This invert does not add
 * a additional delay time.
 *
 * @param name the name of the signal
 * @param orig the original input signal
 * @return the inverted or the original input
 */
public ObservableValue invert(String name, ObservableValue orig) {
    if (inputs == null)
        return orig;
    if (!inputs.contains(name))
        return orig;
    ObservableValue out = new ObservableValue("~" + orig.getName(), orig.getBits());
    orig.addObserver(new NodeWithoutDelay(out) {

        @Override
        public void hasChanged() {
            out.set(~orig.getValue(), orig.getHighZ());
        }
    });
    out.set(~orig.getValue(), orig.getHighZ());
    return out;
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) NodeWithoutDelay(de.neemann.digital.core.NodeWithoutDelay)

Aggregations

NodeWithoutDelay (de.neemann.digital.core.NodeWithoutDelay)1 ObservableValue (de.neemann.digital.core.ObservableValue)1