use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class BarrelShifterTest method testArithmeticUnsignedRight33.
public void testArithmeticUnsignedRight33() throws Exception {
TestExecuter bsTest = getTestExecuter(BarrelShifterMode.arithmetic, false, LeftRightFormat.right, 33, 6);
bsTest.check(0x100000000L, 0, 0x100000000L);
bsTest.check(0x100000000L, 1, 0x180000000L);
bsTest.check(0x100000000L, 2, 0x1c0000000L);
bsTest.check(0x100000000L, 3, 0x1e0000000L);
bsTest.check(0x100000000L, 4, 0x1f0000000L);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class BarrelShifterTest method testRotateUnsignedRight.
public void testRotateUnsignedRight() throws Exception {
TestExecuter bsTest = getTestExecuter(BarrelShifterMode.rotate, false, LeftRightFormat.right, 6, 3);
bsTest.check(0b001100, 0, 0b001100);
bsTest.check(0b001100, 1, 0b000110);
bsTest.check(0b001100, 2, 0b000011);
bsTest.check(0b010001, 2, 0b010100);
bsTest.check(0b001100, 3, 0b100001);
bsTest.check(0b001100, 5, 0b011000);
bsTest.check(0b001100, -1, 0b000110);
bsTest.check(0b001100, -4, 0b110000);
bsTest.check(0b001100, -5, 0b100001);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class BarrelShifterTest method testNormalSignedLeft.
public void testNormalSignedLeft() throws Exception {
TestExecuter bsTest = getTestExecuter(BarrelShifterMode.logical, true, LeftRightFormat.left, 6, 4);
bsTest.check(0b001100, 0, 0b001100);
bsTest.check(0b001100, 1, 0b011000);
bsTest.check(0b001100, 2, 0b110000);
bsTest.check(0b010001, 2, 0b000100);
bsTest.check(0b001100, 3, 0b100000);
bsTest.check(0b001100, 5, 0b000000);
bsTest.check(0b001100, -1, 0b000110);
bsTest.check(0b001100, -4, 0b000000);
bsTest.check(0b001100, -5, 0b000000);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class BitCountTest method testBitCount.
public void testBitCount() throws Exception {
ObservableValue a = new ObservableValue("a", 6);
Model model = new Model();
BitCount node = new BitCount(new ElementAttributes().setBits(6));
node.setInputs(a.asList());
model.add(node);
ObservableValues outputs = node.getOutputs();
assertEquals(1, outputs.size());
assertEquals(3, outputs.get(0).getBits());
TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(outputs);
sc.check(0, 0);
sc.check(1, 1);
sc.check(2, 1);
sc.check(4, 1);
sc.check(8, 1);
sc.check(16, 1);
sc.check(32, 1);
sc.check(3, 2);
sc.check(6, 2);
sc.check(12, 2);
sc.check(24, 2);
sc.check(48, 2);
sc.check(63, 6);
sc.check(255, 6);
}
use of de.neemann.digital.TestExecuter in project Digital by hneemann.
the class ComparatorTest method testCompSigned.
public void testCompSigned() 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, true));
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(7, 2, 1, 0, 0);
sc.check(8, 2, 0, 0, 1);
sc.check(15, 2, 0, 0, 1);
sc.check(13, 15, 0, 0, 1);
sc.check(-2, -3, 1, 0, 0);
sc.check(-7, -8, 1, 0, 0);
}
Aggregations