Search in sources :

Example 26 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class BarrelShifterTest method testNormalUnsignedLeft.

public void testNormalUnsignedLeft() throws Exception {
    TestExecuter bsTest = getTestExecuter(BarrelShifterMode.logical, false, LeftRightFormat.left, 6, 3);
    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, 0b000000);
    bsTest.check(0b001100, -4, 0b000000);
    bsTest.check(0b001100, -5, 0b100000);
    for (int s = 0; s < 7; s++) bsTest.check(1, s, (1 << s) & 0b111111);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 27 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class BarrelShifterTest method testArithmeticUnsignedRight.

public void testArithmeticUnsignedRight() throws Exception {
    TestExecuter bsTest = getTestExecuter(BarrelShifterMode.arithmetic, false, LeftRightFormat.right, 6, 3);
    bsTest.check(0b001100, 0, 0b001100);
    bsTest.check(0b001100, 1, 0b000110);
    bsTest.check(0b001100, 2, 0b000011);
    bsTest.check(0b010001, 2, 0b000100);
    bsTest.check(0b001100, 3, 0b000001);
    bsTest.check(0b001100, 5, 0b000000);
    bsTest.check(0b001100, -1, 0b000000);
    bsTest.check(0b001100, -4, 0b000000);
    bsTest.check(0b001100, -5, 0b000001);
    bsTest.check(0b101000, 0, 0b101000);
    bsTest.check(0b101000, 1, 0b110100);
    bsTest.check(0b101000, 2, 0b111010);
    bsTest.check(0b101000, 3, 0b111101);
    bsTest.check(0b101000, 5, 0b111111);
    bsTest.check(0b101000, -1, 0b111111);
    bsTest.check(0b101000, -4, 0b111110);
    bsTest.check(0b101000, -5, 0b111101);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 28 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class BarrelShifterTest method testRotateSignedLeft.

public void testRotateSignedLeft() throws Exception {
    TestExecuter bsTest = getTestExecuter(BarrelShifterMode.rotate, true, LeftRightFormat.left, 6, 4);
    bsTest.check(0b001100, 0, 0b001100);
    bsTest.check(0b001100, 1, 0b011000);
    bsTest.check(0b001100, 2, 0b110000);
    bsTest.check(0b010001, 2, 0b000101);
    bsTest.check(0b001100, 3, 0b100001);
    bsTest.check(0b001100, 5, 0b000110);
    bsTest.check(0b001100, -1, 0b000110);
    bsTest.check(0b001100, -4, 0b110000);
    bsTest.check(0b001100, -5, 0b011000);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 29 with TestExecuter

use of de.neemann.digital.TestExecuter in project Digital by hneemann.

the class BarrelShifterTest method testArithmeticUnsignedRight32.

public void testArithmeticUnsignedRight32() throws Exception {
    TestExecuter bsTest = getTestExecuter(BarrelShifterMode.arithmetic, false, LeftRightFormat.right, 32, 6);
    bsTest.check(0x80000000L, 0, 0x80000000L);
    bsTest.check(0x80000000L, 1, 0xc0000000L);
    bsTest.check(0x80000000L, 2, 0xe0000000L);
    bsTest.check(0x80000000L, 3, 0xf0000000L);
    bsTest.check(0x80000000L, 4, 0xf8000000L);
}
Also used : TestExecuter(de.neemann.digital.TestExecuter)

Example 30 with TestExecuter

use of de.neemann.digital.TestExecuter 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);
}
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