use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.
the class NegTest method testNeg64.
public void testNeg64() throws Exception {
ObservableValue a = new ObservableValue("a", 64);
Model model = new Model();
Neg out = model.add(new Neg(new ElementAttributes().setBits(64)));
out.setInputs(a.asList());
TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
sc.check(0, 0);
sc.check(-1, 1);
sc.check(1, -1);
}
use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.
the class SubTest method testSub64.
public void testSub64() throws Exception {
ObservableValue a = new ObservableValue("a", 64);
ObservableValue b = new ObservableValue("b", 64);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
Sub node = new Sub(new ElementAttributes().setBits(64));
node.setInputs(ovs(a, b, c));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputs(node.getOutputs());
sc.check(0, 0, 1, -1, 1);
sc.check(0, 1, 0, -1, 1);
sc.check(2, 2, 1, -1, 1);
sc.check(2, 3, 0, -1, 1);
}
use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.
the class SubTest method testSub.
public void testSub() throws Exception {
ObservableValue a = new ObservableValue("a", 4);
ObservableValue b = new ObservableValue("b", 4);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
Add node = new Sub(new ElementAttributes().setBits(4));
node.setInputs(ovs(a, b, c));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputsOf(node);
sc.check(0, 0, 0, 0, 0);
sc.check(3, 2, 0, 1, 0);
sc.check(2, 3, 0, 15, 1);
sc.check(3, 3, 0, 0, 0);
sc.check(3, 3, 1, 15, 1);
}
use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.
the class DelayTest method testDelay.
public void testDelay() throws Exception {
ObservableValue a = new ObservableValue("a", 2);
Model model = new Model();
Delay out = model.add(new Delay(new ElementAttributes().setBits(2)));
out.setInputs(a.asList());
TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
sc.check(0, 0);
sc.check(1, 1);
sc.check(2, 2);
sc.check(3, 3);
}
use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.
the class DemultiplexerTest method testDemux.
public void testDemux() throws Exception {
Model model = new Model();
ObservableValue a = new ObservableValue("a", 4);
ObservableValue sel = new ObservableValue("sel", 2);
Demultiplexer demul = model.add(new Demultiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.SELECTOR_BITS, 2)));
demul.setInputs(ovs(sel, a));
TestExecuter te = new TestExecuter(model).setInputs(a, sel).setOutputs(demul.getOutputs());
te.check(2, 0, 2, 0, 0, 0);
te.check(3, 0, 3, 0, 0, 0);
te.check(3, 1, 0, 3, 0, 0);
te.check(4, 2, 0, 0, 4, 0);
te.check(5, 3, 0, 0, 0, 5);
}
Aggregations