Search in sources :

Example 46 with TestExecuter

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);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 47 with TestExecuter

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);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 48 with TestExecuter

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);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 49 with TestExecuter

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);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 50 with TestExecuter

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);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Aggregations

TestExecuter (de.neemann.digital.TestExecuter)80 ObservableValue (de.neemann.digital.core.ObservableValue)61 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)61 Model (de.neemann.digital.core.Model)49 ObservableValues (de.neemann.digital.core.ObservableValues)16 Circuit (de.neemann.digital.draw.elements.Circuit)5 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)5 ModelCreator (de.neemann.digital.draw.model.ModelCreator)5 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)5 Expression (de.neemann.digital.analyse.expression.Expression)4 Variable (de.neemann.digital.analyse.expression.Variable)4 Node (de.neemann.digital.core.Node)1 FanIn (de.neemann.digital.core.basic.FanIn)1 Delay (de.neemann.digital.core.wiring.Delay)1 ModelEntry (de.neemann.digital.draw.model.ModelEntry)1 File (java.io.File)1