Search in sources :

Example 6 with TestExecuter

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

the class PriorityEncoderTest method testEncoder4.

public void testEncoder4() throws Exception {
    Model model = new Model();
    ObservableValue d0 = new ObservableValue("d0", 1);
    ObservableValue d1 = new ObservableValue("d1", 1);
    ObservableValue d2 = new ObservableValue("d2", 1);
    ObservableValue d3 = new ObservableValue("d3", 1);
    PriorityEncoder out = model.add(new PriorityEncoder(new ElementAttributes().set(Keys.SELECTOR_BITS, 2)));
    out.setInputs(ovs(d0, d1, d2, d3));
    TestExecuter te = new TestExecuter(model).setInputs(d3, d2, d1, d0).setOutputs(out.getOutputs());
    te.check(0, 0, 0, 0, 0, 0);
    te.check(0, 0, 0, 1, 0, 1);
    te.check(0, 0, 1, 0, 1, 1);
    te.check(0, 0, 1, 1, 1, 1);
    te.check(0, 1, 0, 0, 2, 1);
    te.check(0, 1, 0, 1, 2, 1);
    te.check(0, 1, 1, 0, 2, 1);
    te.check(0, 1, 1, 1, 2, 1);
    te.check(1, 0, 0, 0, 3, 1);
    te.check(1, 0, 0, 1, 3, 1);
    te.check(1, 0, 1, 0, 3, 1);
    te.check(1, 0, 1, 1, 3, 1);
    te.check(1, 1, 0, 0, 3, 1);
    te.check(1, 1, 0, 1, 3, 1);
    te.check(1, 1, 1, 0, 3, 1);
    te.check(1, 1, 1, 1, 3, 1);
}
Also used : Model(de.neemann.digital.core.Model) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 7 with TestExecuter

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

the class Splitter1Test method testMoreBits.

public void testMoreBits() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    ObservableValue c = new ObservableValue("c", 4);
    ObservableValue d = new ObservableValue("d", 4);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "4,4,4,4").set(Keys.OUTPUT_SPLIT, "16"));
    splitter.setInputs(ovs(a, b, c, d));
    assertEquals(1, a.observerCount());
    assertEquals(1, b.observerCount());
    assertEquals(1, c.observerCount());
    assertEquals(1, d.observerCount());
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(1, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(d, c, b, a).setOutputsOf(splitter);
    sc.check(0, 0, 0, 0, 0x0000);
    sc.check(0, 0, 0, 1, 0x0001);
    sc.check(0, 0, 1, 0, 0x0010);
    sc.check(0, 1, 0, 0, 0x0100);
    sc.check(1, 0, 0, 0, 0x1000);
    sc.check(0, 0, 0, 15, 0x000F);
    sc.check(0, 0, 15, 0, 0x00F0);
    sc.check(0, 15, 0, 0, 0x0F00);
    sc.check(15, 0, 0, 0, 0xF000);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 8 with TestExecuter

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

the class Splitter1Test method testBits.

public void testBits() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    ObservableValue c = new ObservableValue("c", 1);
    ObservableValue d = new ObservableValue("d", 1);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "1,1,1,1").set(Keys.OUTPUT_SPLIT, "4"));
    splitter.setInputs(ovs(a, b, c, d));
    assertEquals(1, a.observerCount());
    assertEquals(1, b.observerCount());
    assertEquals(1, c.observerCount());
    assertEquals(1, d.observerCount());
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(1, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a, b, c, d).setOutputsOf(splitter);
    sc.check(0, 0, 0, 0, 0);
    sc.check(1, 0, 0, 0, 1);
    sc.check(0, 1, 0, 0, 2);
    sc.check(0, 0, 1, 0, 4);
    sc.check(0, 0, 0, 1, 8);
    sc.check(1, 1, 0, 0, 3);
    sc.check(1, 1, 1, 0, 7);
    sc.check(1, 1, 1, 1, 15);
    sc.check(0, 0, 1, 1, 12);
    sc.check(0, 1, 1, 1, 14);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 9 with TestExecuter

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

the class Splitter2Test method testBits.

public void testBits() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "4").set(Keys.OUTPUT_SPLIT, "1,1,1,1"));
    splitter.setInputs(a.asList());
    assertEquals(4, a.observerCount());
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(4, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a).setOutputsOf(splitter);
    sc.check(0, 0, 0, 0, 0);
    sc.check(1, 1, 0, 0, 0);
    sc.check(2, 0, 1, 0, 0);
    sc.check(4, 0, 0, 1, 0);
    sc.check(8, 0, 0, 0, 1);
    sc.check(15, 1, 1, 1, 1);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) TestExecuter(de.neemann.digital.TestExecuter)

Example 10 with TestExecuter

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

the class Splitter64BitTest method test64Bit2.

public void test64Bit2() throws NodeException, PinException {
    ObservableValue a = new ObservableValue("a", 64);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "64").set(Keys.OUTPUT_SPLIT, "16,16,16,16"));
    splitter.setInputs(ovs(a));
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(4, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a).setOutputsOf(splitter);
    sc.check(0x0, 0x0, 0x0, 0x0, 0x0);
    sc.check(-1, 0xffff, 0xffff, 0xffff, 0xffff);
    sc.check(0xffffffffffffffffL, 0xffff, 0xffff, 0xffff, 0xffff);
    sc.check(0xffffffffffff0000L, 0, 0xffff, 0xffff, 0xffff);
    sc.check(0xffffffff0000ffffL, 0xffff, 0, 0xffff, 0xffff);
    sc.check(0xffff0000ffffffffL, 0xffff, 0xffff, 0, 0xffff);
    sc.check(0x0000ffffffffffffL, 0xffff, 0xffff, 0xffff, 0);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) ObservableValue(de.neemann.digital.core.ObservableValue) 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