Search in sources :

Example 61 with TestExecuter

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

the class MultiplexerTest method testMux.

public void testMux() throws Exception {
    Model model = new Model();
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    ObservableValue c = new ObservableValue("c", 4);
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue sel = new ObservableValue("sel", 2);
    FanIn out = model.add(new Multiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.SELECTOR_BITS, 2)));
    out.setInputs(ovs(sel, a, b, c, d));
    TestExecuter te = new TestExecuter(model).setInputs(a, b, c, d, sel).setOutputs(out.getOutputs());
    te.check(3, 4, 5, 6, 0, 3);
    te.check(3, 4, 5, 6, 1, 4);
    te.check(3, 4, 5, 6, 2, 5);
    te.check(3, 4, 5, 6, 3, 6);
}
Also used : FanIn(de.neemann.digital.core.basic.FanIn) 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 62 with TestExecuter

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

the class PriorityEncoderTest method testEncoder2.

public void testEncoder2() throws Exception {
    Model model = new Model();
    ObservableValue d0 = new ObservableValue("d0", 1);
    ObservableValue d1 = new ObservableValue("d1", 1);
    PriorityEncoder out = model.add(new PriorityEncoder(new ElementAttributes().set(Keys.SELECTOR_BITS, 1)));
    out.setInputs(ovs(d0, d1));
    TestExecuter te = new TestExecuter(model).setInputs(d1, d0).setOutputs(out.getOutputs());
    te.check(0, 0, 0, 0);
    te.check(0, 1, 0, 1);
    te.check(1, 0, 1, 1);
    te.check(1, 1, 1, 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 63 with TestExecuter

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

the class Splitter1Test method testMoreBits2.

public void testMoreBits2() 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, "8,8"));
    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(2, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(b, a, d, c).setOutputsOf(splitter);
    sc.check(0x0, 0x0, 0x0, 0x0, 0x00, 0x00);
    sc.check(0x1, 0x0, 0x0, 0x0, 0x10, 0x00);
    sc.check(0x0, 0x1, 0x0, 0x0, 0x01, 0x00);
    sc.check(0x0, 0x0, 0x1, 0x0, 0x00, 0x10);
    sc.check(0x0, 0x0, 0x0, 0x1, 0x00, 0x01);
    sc.check(0xf, 0x0, 0x0, 0x0, 0xf0, 0x00);
    sc.check(0x0, 0xf, 0x0, 0x0, 0x0f, 0x00);
    sc.check(0x0, 0x0, 0xf, 0x0, 0x00, 0xf0);
    sc.check(0x0, 0x0, 0x0, 0xf, 0x00, 0x0f);
    sc.check(0x1, 0x1, 0x0, 0x0, 0x11, 0x00);
    sc.check(0x0, 0x0, 0x1, 0x1, 0x00, 0x11);
    sc.check(0xf, 0xf, 0x0, 0x0, 0xff, 0x00);
    sc.check(0x0, 0x0, 0xf, 0xf, 0x00, 0xff);
    sc.check(0xf, 0xf, 0xf, 0xf, 0xff, 0xff);
}
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 64 with TestExecuter

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

the class Splitter2Test method testMoreBits.

public void testMoreBits() throws Exception {
    ObservableValue a = new ObservableValue("a", 16);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "16").set(Keys.OUTPUT_SPLIT, "4,4,4,4"));
    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(0x0000, 0x0, 0x0, 0x0, 0x0);
    sc.check(0x1000, 0x0, 0x0, 0x0, 0x1);
    sc.check(0x0100, 0x0, 0x0, 0x1, 0x0);
    sc.check(0x0010, 0x0, 0x1, 0x0, 0x0);
    sc.check(0x0001, 0x1, 0x0, 0x0, 0x0);
    sc.check(0xa000, 0x0, 0x0, 0x0, 0xa);
    sc.check(0x0b00, 0x0, 0x0, 0xb, 0x0);
    sc.check(0x00c0, 0x0, 0xc, 0x0, 0x0);
    sc.check(0x000d, 0xd, 0x0, 0x0, 0x0);
}
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 65 with TestExecuter

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

the class Splitter2Test method testMix.

public void testMix() throws Exception {
    ObservableValue a = new ObservableValue("a", 8);
    ObservableValue b = new ObservableValue("b", 8);
    Splitter splitter = new Splitter(new ElementAttributes().set(Keys.INPUT_SPLIT, "8,8").set(Keys.OUTPUT_SPLIT, "4,4,4,4"));
    splitter.setInputs(ovs(a, b));
    assertEquals(2, a.observerCount());
    assertEquals(2, b.observerCount());
    ObservableValues outputs = splitter.getOutputs();
    assertEquals(4, outputs.size());
    TestExecuter sc = new TestExecuter().setInputs(a, b).setOutputsOf(splitter);
    sc.check(0x00, 0x00, 0x0, 0x0, 0x0, 0x0);
    sc.check(0x10, 0x00, 0x0, 0x1, 0x0, 0x0);
    sc.check(0x01, 0x00, 0x1, 0x0, 0x0, 0x0);
    sc.check(0x00, 0x10, 0x0, 0x0, 0x0, 0x1);
    sc.check(0x00, 0x01, 0x0, 0x0, 0x1, 0x0);
    sc.check(0xf0, 0x00, 0x0, 0xf, 0x0, 0x0);
    sc.check(0x0f, 0x00, 0xf, 0x0, 0x0, 0x0);
    sc.check(0x00, 0xf0, 0x0, 0x0, 0x0, 0xf);
    sc.check(0x00, 0x0f, 0x0, 0x0, 0xf, 0x0);
    sc.check(0xff, 0xff, 0xf, 0xf, 0xf, 0xf);
}
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