Search in sources :

Example 56 with ElementAttributes

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

the class SubTest method testSub.

public void testSub() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue b = new ObservableValue("b", 4);
    ObservableValue c = new ObservableValue("c", 1);
    Model model = new Model();
    Add node = new Sub(new ElementAttributes().setBits(4));
    node.setInputs(ovs(a, b, c));
    model.add(node);
    TestExecuter sc = new TestExecuter(model).setInputs(a, b, c).setOutputsOf(node);
    sc.check(0, 0, 0, 0, 0);
    sc.check(3, 2, 0, 1, 0);
    sc.check(2, 3, 0, 15, 1);
    sc.check(3, 3, 0, 0, 0);
    sc.check(3, 3, 1, 15, 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 57 with ElementAttributes

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

the class DelayTest method testDelay.

public void testDelay() throws Exception {
    ObservableValue a = new ObservableValue("a", 2);
    Model model = new Model();
    Delay out = model.add(new Delay(new ElementAttributes().setBits(2)));
    out.setInputs(a.asList());
    TestExecuter sc = new TestExecuter(model).setInputs(a).setOutputs(out.getOutputs());
    sc.check(0, 0);
    sc.check(1, 1);
    sc.check(2, 2);
    sc.check(3, 3);
}
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) Delay(de.neemann.digital.core.wiring.Delay)

Example 58 with ElementAttributes

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

the class DemultiplexerTest method testDemux.

public void testDemux() 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.SELECTOR_BITS, 2)));
    demul.setInputs(ovs(sel, a));
    TestExecuter te = new TestExecuter(model).setInputs(a, sel).setOutputs(demul.getOutputs());
    te.check(2, 0, 2, 0, 0, 0);
    te.check(3, 0, 3, 0, 0, 0);
    te.check(3, 1, 0, 3, 0, 0);
    te.check(4, 2, 0, 0, 4, 0);
    te.check(5, 3, 0, 0, 0, 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 59 with ElementAttributes

use of de.neemann.digital.core.element.ElementAttributes 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 60 with ElementAttributes

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

Aggregations

ElementAttributes (de.neemann.digital.core.element.ElementAttributes)87 ObservableValue (de.neemann.digital.core.ObservableValue)73 TestExecuter (de.neemann.digital.TestExecuter)61 Model (de.neemann.digital.core.Model)52 ObservableValues (de.neemann.digital.core.ObservableValues)16 BitsException (de.neemann.digital.core.BitsException)3 FanIn (de.neemann.digital.core.basic.FanIn)3 NodeException (de.neemann.digital.core.NodeException)2 Delay (de.neemann.digital.core.wiring.Delay)2 Circuit (de.neemann.digital.draw.elements.Circuit)2 And (de.neemann.digital.core.basic.And)1 Not (de.neemann.digital.core.basic.Not)1 Or (de.neemann.digital.core.basic.Or)1 Element (de.neemann.digital.core.element.Element)1 Key (de.neemann.digital.core.element.Key)1 FlipflopD (de.neemann.digital.core.flipflops.FlipflopD)1 FlipflopJK (de.neemann.digital.core.flipflops.FlipflopJK)1 Clock (de.neemann.digital.core.wiring.Clock)1 VisualElement (de.neemann.digital.draw.elements.VisualElement)1 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)1