use of de.neemann.digital.core.BitsException in project Digital by hneemann.
the class Multiplexer method setInputs.
@Override
public void setInputs(ObservableValues inputs) throws NodeException {
selector = inputs.get(0).addObserverToValue(this).checkBits(selectorBits, this);
ObservableValues in = new ObservableValues(inputs, 1, inputs.size());
super.setInputs(in);
if (in.size() != (1 << selectorBits))
throw new BitsException(Lang.get("err_selectorInputCountMismatch"), this, -1, selector);
}
use of de.neemann.digital.core.BitsException in project Digital by hneemann.
the class MultiplexerTest method testMux2.
public void testMux2() throws Exception {
ObservableValue a = new ObservableValue("a", 4);
ObservableValue b = new ObservableValue("b", 4);
ObservableValue c = new ObservableValue("c", 4);
ObservableValue d = new ObservableValue("d", 4);
ObservableValue sel = new ObservableValue("sel", 1);
FanIn out = new Multiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.SELECTOR_BITS, 2));
try {
out.setInputs(ovs(a, b, c, d, sel));
assertTrue(false);
} catch (BitsException e) {
assertTrue(true);
}
}
use of de.neemann.digital.core.BitsException in project Digital by hneemann.
the class Splitter1Test method testBitMismatch.
public void testBitMismatch() throws NodeException {
ObservableValue a = new ObservableValue("a", 1);
ObservableValue b = new ObservableValue("b", 1);
Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "1,1").set(Keys.OUTPUT_SPLIT, "3"));
try {
splitter.setInputs(ovs(a, b));
fail("splitter bit mismatch not detected!");
} catch (BitsException e) {
assertTrue(true);
}
}
use of de.neemann.digital.core.BitsException in project Digital by hneemann.
the class MultiplexerTest method testMux3.
public void testMux3() throws Exception {
ObservableValue a = new ObservableValue("a", 4);
ObservableValue b = new ObservableValue("b", 4);
ObservableValue c = new ObservableValue("c", 4);
ObservableValue sel = new ObservableValue("sel", 2);
FanIn out = new Multiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.SELECTOR_BITS, 2));
try {
out.setInputs(ovs(sel, a, b, c));
assertTrue(false);
} catch (BitsException e) {
assertTrue(true);
}
}
Aggregations