use of de.neemann.digital.core.Model in project Digital by hneemann.
the class AddTest method testAdd32.
public void testAdd32() throws Exception {
ObservableValue a = new ObservableValue("a", 32);
ObservableValue b = new ObservableValue("b", 32);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
Add node = new Add(new ElementAttributes().setBits(32));
node.setInputs(ovs(a, b, c));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputs(node.getOutputs());
sc.check(-1, 0, 1, 0, 1);
sc.check(-1, 1, 0, 0, 1);
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class AddTest method testAdd64.
public void testAdd64() throws Exception {
ObservableValue a = new ObservableValue("a", 64);
ObservableValue b = new ObservableValue("b", 64);
ObservableValue c = new ObservableValue("c", 1);
Model model = new Model();
Add node = new Add(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(-1, 0, 1, 0, 1);
sc.check(-1, 1, 0, 0, 1);
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class BitCountTest method testBitCount64.
public void testBitCount64() throws Exception {
ObservableValue a = new ObservableValue("a", 64);
Model model = new Model();
BitCount node = new BitCount(new ElementAttributes().setBits(64));
node.setInputs(a.asList());
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(node.getOutputs());
sc.check(0, 0);
sc.check(-1, 64);
sc.check(1, 1);
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class ComparatorTest method testCompSigned64Bit.
public void testCompSigned64Bit() throws Exception {
ObservableValue a = new ObservableValue("a", 64);
ObservableValue b = new ObservableValue("b", 64);
Model model = new Model();
Comparator node = new Comparator(new ElementAttributes().setBits(64).set(Keys.SIGNED, true));
node.setInputs(ovs(a, b));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(node.getOutputs());
// gr eq kl
sc.check(0, 0, 0, 1, 0);
sc.check(0, -2, 1, 0, 0);
sc.check(-2, 0, 0, 0, 1);
sc.check(-1, -2, 1, 0, 0);
sc.check(-2, -1, 0, 0, 1);
sc.check(0x8000000000000000L, 0, 0, 0, 1);
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class ComparatorTest method testCompUnsigned.
public void testCompUnsigned() throws Exception {
ObservableValue a = new ObservableValue("a", 4);
ObservableValue b = new ObservableValue("b", 4);
Model model = new Model();
Comparator node = new Comparator(new ElementAttributes().setBits(4).set(Keys.SIGNED, false));
node.setInputs(ovs(a, b));
model.add(node);
TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(node.getOutputs());
sc.check(0, 0, 0, 1, 0);
sc.check(1, 0, 1, 0, 0);
sc.check(1, 2, 0, 0, 1);
sc.check(14, 2, 1, 0, 0);
}
Aggregations