use of de.neemann.digital.core.element.ElementAttributes 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.element.ElementAttributes 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.element.ElementAttributes 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.element.ElementAttributes in project Digital by hneemann.
the class BitExtenderTest method testSignExtendError2.
public void testSignExtendError2() throws Exception {
try {
ObservableValue in = new ObservableValue("in", 5);
new BitExtender(new ElementAttributes().set(Keys.OUTPUT_BITS, 4)).setInputs(in.asList());
fail();
} catch (NodeException e) {
}
}
use of de.neemann.digital.core.element.ElementAttributes in project Digital by hneemann.
the class BitExtenderTest method testSignExtend64.
public void testSignExtend64() throws Exception {
ObservableValue in = new ObservableValue("in", 63);
BitExtender bitExtender = new BitExtender(new ElementAttributes().set(Keys.INPUT_BITS, 63).set(Keys.OUTPUT_BITS, 64));
bitExtender.setInputs(in.asList());
assertEquals(1, bitExtender.getOutputs().size());
ObservableValue out = bitExtender.getOutputs().get(0);
check(in, out, 0, 0);
check(in, out, 0x4000000000000000L, 0xC000000000000000L);
}
Aggregations