Search in sources :

Example 16 with ObservableValue

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

the class NOrTest method testNOr.

public void testNOr() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    Model model = new Model();
    NOr nor = model.add(new NOr(new ElementAttributes().setBits(1)));
    nor.setInputs(ovs(a, b));
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(nor.getOutputs());
    sc.check(0, 0, 1);
    sc.check(1, 0, 0);
    sc.check(0, 1, 0);
    sc.check(1, 1, 0);
    sc.check(1, 0, 0);
    sc.check(0, 1, 0);
    sc.check(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)

Example 17 with ObservableValue

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

the class NotTest method testNot.

public void testNot() throws Exception {
    ObservableValue a = new ObservableValue("a", 2);
    Model model = new Model();
    Not out = model.add(new Not(new ElementAttributes().setBits(2)));
    out.setInputs(a.asList());
    TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
    sc.check(0, 3);
    sc.check(1, 2);
    sc.check(2, 1);
    sc.check(3, 0);
}
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 18 with ObservableValue

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

the class OrTest method testOr.

public void testOr() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    Model model = new Model();
    FanIn and = model.add(new Or(new ElementAttributes().setBits(1)));
    and.setInputs(ovs(a, b));
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(and.getOutput());
    sc.check(0, 0, 0);
    sc.check(1, 0, 1);
    sc.check(0, 1, 1);
    sc.check(1, 1, 1);
    sc.check(1, 0, 1);
    sc.check(0, 1, 1);
    sc.check(0, 0, 0);
}
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 19 with ObservableValue

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

the class XNOrTest method testXor.

public void testXor() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    Model model = new Model();
    XNOr out = model.add(new XNOr(new ElementAttributes().setBits(1)));
    out.setInputs(ovs(a, b));
    TestExecuter sc = new TestExecuter(model).setInputs(a, b).setOutputs(out.getOutputs());
    sc.check(0, 0, 1);
    sc.check(1, 0, 0);
    sc.check(0, 1, 0);
    sc.check(1, 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)

Example 20 with ObservableValue

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

the class LUTTest method testLut.

public void testLut() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    ObservableValue c = new ObservableValue("c", 1);
    Model model = new Model();
    DataField data = new DataField(8);
    data.setData(3, 1);
    data.setData(7, 1);
    LookUpTable out = model.add(new LookUpTable(new ElementAttributes().setBits(1).set(Keys.DATA, data)));
    out.setInputs(ovs(a, b));
    TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputs(out.getOutputs());
    sc.check(0, 0, 0, 0);
    sc.check(1, 0, 0, 0);
    sc.check(0, 1, 0, 0);
    sc.check(1, 1, 0, 1);
    sc.check(0, 0, 1, 0);
    sc.check(1, 0, 1, 0);
    sc.check(0, 1, 1, 0);
    sc.check(1, 1, 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

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