Search in sources :

Example 66 with ObservableValue

use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.

the class DemultiplexerTest method testDemuxDefault.

public void testDemuxDefault() throws Exception {
    Model model = new Model();
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue sel = new ObservableValue("sel", 2);
    Demultiplexer demul = model.add(new Demultiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.DEFAULT, 7).set(Keys.SELECTOR_BITS, 2)));
    demul.setInputs(ovs(sel, a));
    TestExecuter te = new TestExecuter(model).setInputs(a, sel).setOutputs(demul.getOutputs());
    te.check(2, 0, 2, 7, 7, 7);
    te.check(3, 0, 3, 7, 7, 7);
    te.check(3, 1, 7, 3, 7, 7);
    te.check(4, 2, 7, 7, 4, 7);
    te.check(5, 3, 7, 7, 7, 5);
}
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 67 with ObservableValue

use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.

the class DriverTest method testDriver.

public void testDriver() throws Exception {
    ObservableValue a = new ObservableValue("a", 2);
    ObservableValue sel = new ObservableValue("sel", 1);
    Model model = new Model();
    Driver out = model.add(new Driver(new ElementAttributes().setBits(2)));
    out.setInputs(ovs(a, sel));
    TestExecuter sc = new TestExecuter(model).setInputs(a, sel).setOutputs(out.getOutputs());
    sc.check(0, 1, 0);
    sc.check(2, 1, 2);
    sc.checkZ(2, 0, HIGHZ);
    sc.check(2, 1, 2);
}
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 68 with ObservableValue

use of de.neemann.digital.core.ObservableValue in project Digital by hneemann.

the class MultiplexerTest method testMux3.

public void testMux3() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    ObservableValue c = new ObservableValue("c", 4);
    ObservableValue sel = new ObservableValue("sel", 2);
    FanIn out = new Multiplexer(new ElementAttributes().set(Keys.BITS, 4).set(Keys.SELECTOR_BITS, 2));
    try {
        out.setInputs(ovs(sel, a, b, c));
        assertTrue(false);
    } catch (BitsException e) {
        assertTrue(true);
    }
}
Also used : FanIn(de.neemann.digital.core.basic.FanIn) ObservableValue(de.neemann.digital.core.ObservableValue) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) BitsException(de.neemann.digital.core.BitsException)

Example 69 with ObservableValue

use of de.neemann.digital.core.ObservableValue 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 70 with ObservableValue

use of de.neemann.digital.core.ObservableValue 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)

Aggregations

ObservableValue (de.neemann.digital.core.ObservableValue)88 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)73 TestExecuter (de.neemann.digital.TestExecuter)61 Model (de.neemann.digital.core.Model)56 ObservableValues (de.neemann.digital.core.ObservableValues)17 NodeException (de.neemann.digital.core.NodeException)5 ArrayList (java.util.ArrayList)4 BitsException (de.neemann.digital.core.BitsException)3 FanIn (de.neemann.digital.core.basic.FanIn)3 Signal (de.neemann.digital.core.Signal)2 Element (de.neemann.digital.core.element.Element)2 Clock (de.neemann.digital.core.wiring.Clock)2 Delay (de.neemann.digital.core.wiring.Delay)2 DataBus (de.neemann.digital.core.wiring.bus.DataBus)2 IOState (de.neemann.digital.draw.elements.IOState)2 CircuitComponent (de.neemann.digital.gui.components.CircuitComponent)2 Sync (de.neemann.digital.gui.sync.Sync)2 BurnException (de.neemann.digital.core.BurnException)1 Node (de.neemann.digital.core.Node)1 NodeWithoutDelay (de.neemann.digital.core.NodeWithoutDelay)1