Search in sources :

Example 66 with TestExecuter

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

the class Splitter64BitTest method test64Bit.

public void test64Bit() throws NodeException, PinException {
    ObservableValue a = new ObservableValue("a", 16);
    ObservableValue b = new ObservableValue("b", 16);
    ObservableValue c = new ObservableValue("c", 16);
    ObservableValue d = new ObservableValue("d", 16);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "16,16,16,16").set(Keys.OUTPUT_SPLIT, "64"));
    splitter.setInputs(ovs(d, c, b, a));
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(1, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a, b, c, d).setOutputsOf(splitter);
    sc.check(0x0, 0x0, 0x0, 0x0, 0x00);
    sc.check(0x1, 0x1, 0x1, 0x1, 0x0001000100010001L);
    sc.check(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFFFFFFFFFFFFFFL);
    sc.check(0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0xFFFFFFFFFFFF0000L);
    sc.check(0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFFFFFF0000FFFFL);
    sc.check(0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF0000FFFFFFFFL);
    sc.check(0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000FFFFFFFFFFFFL);
}
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 67 with TestExecuter

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

the class SplitterHighZTest method testHighZEnabled.

public void testHighZEnabled() throws NodeException, PinException {
    ObservableValue a = new ObservableValue("a", 2).setToHighZ();
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "2").set(Keys.OUTPUT_SPLIT, "1,1"));
    splitter.setInputs(ovs(a));
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(2, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a).setOutputsOf(splitter);
    sc.check(0, 0, 0);
    sc.check(1, 1, 0);
    sc.check(2, 0, 1);
    sc.check(3, 1, 1);
    sc.checkZ(HIGHZ, HIGHZ, HIGHZ);
}
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 68 with TestExecuter

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

the class SplitterHighZTest method testHighZError.

public void testHighZError() throws NodeException, PinException {
    ObservableValue a = new ObservableValue("a", 1).setToHighZ();
    ObservableValue b = new ObservableValue("b", 1);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "1,1").set(Keys.OUTPUT_SPLIT, "2"));
    splitter.setInputs(ovs(a, b));
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(1, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a, b).setOutputsOf(splitter);
    sc.check(0, 0, 0);
    sc.check(0, 1, 2);
    sc.check(1, 0, 1);
    sc.check(1, 1, 3);
    sc.checkZ(HIGHZ, HIGHZ, HIGHZ);
}
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 69 with TestExecuter

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

the class FlipflopDTest method testFlipFlop.

public void testFlipFlop() throws Exception {
    ObservableValue d = new ObservableValue("d", 8);
    ObservableValue c = new ObservableValue("c", 1);
    Model model = new Model();
    FlipflopD out = model.add(new FlipflopD(new ElementAttributes().setBits(8)));
    out.setInputs(ovs(d, c));
    TestExecuter sc = new TestExecuter(model).setInputs(d, c).setOutputs(out.getOutputs());
    // D  C  Q  ~Q
    sc.check(0, 0, 0, 255);
    sc.check(1, 0, 0, 255);
    sc.check(1, 1, 1, 254);
    sc.check(1, 0, 1, 254);
    sc.check(0, 0, 1, 254);
    sc.check(7, 0, 1, 254);
    sc.check(7, 1, 7, 248);
}
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)

Example 70 with TestExecuter

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

the class FlipflopJKAsyncTest method testFlipFlop.

public void testFlipFlop() throws Exception {
    ObservableValue set = new ObservableValue("set", 1);
    ObservableValue j = new ObservableValue("j", 1);
    ObservableValue c = new ObservableValue("c", 1);
    ObservableValue k = new ObservableValue("k", 1);
    ObservableValue clr = new ObservableValue("clr", 1);
    Model model = new Model();
    FlipflopJKAsync out = model.add(new FlipflopJKAsync(new ElementAttributes()));
    out.setInputs(ovs(set, j, c, k, clr));
    TestExecuter sc = new TestExecuter(model).setInputs(set, j, c, k, clr).setOutputs(out.getOutputs());
    // Set J  C  K  clr Q  ~Q
    sc.check(0, 0, 0, 0, 0, 0, 1);
    sc.check(0, 0, 0, 0, 0, 0, 1);
    sc.check(0, 1, 0, 0, 0, 0, 1);
    sc.check(0, 0, 1, 0, 0, 0, 1);
    sc.check(0, 1, 0, 0, 0, 0, 1);
    sc.check(0, 1, 1, 0, 0, 1, 0);
    sc.check(0, 1, 0, 1, 0, 1, 0);
    sc.check(0, 1, 1, 1, 0, 0, 1);
    sc.check(0, 1, 0, 1, 0, 0, 1);
    sc.check(0, 1, 1, 1, 0, 1, 0);
    sc.check(0, 0, 0, 1, 0, 1, 0);
    sc.check(0, 0, 1, 1, 0, 0, 1);
    sc.check(0, 0, 0, 0, 0, 0, 1);
    // async
    sc.check(1, 0, 0, 0, 0, 1, 0);
    sc.check(0, 0, 0, 0, 0, 1, 0);
    sc.check(0, 0, 0, 0, 1, 0, 1);
    sc.check(0, 0, 0, 0, 0, 0, 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