Search in sources :

Example 71 with ElementAttributes

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

Example 72 with ElementAttributes

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

the class FlipflopJKTest method testFlipFlop.

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

Example 73 with ElementAttributes

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

the class FlipflopTTest method testFlipFlop.

public void testFlipFlop() throws Exception {
    ObservableValue c = new ObservableValue("c", 1);
    Model model = new Model();
    FlipflopT out = model.add(new FlipflopT(new ElementAttributes().setBits(1).set(Keys.WITH_ENABLE, false)));
    out.setInputs(c.asList());
    TestExecuter sc = new TestExecuter(model).setInputs(c).setOutputs(out.getOutputs());
    // C  Q  ~Q
    sc.check(0, 0, 1);
    sc.check(1, 1, 0);
    sc.check(1, 1, 0);
    sc.check(0, 1, 0);
    sc.check(0, 1, 0);
    sc.check(1, 0, 1);
    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 74 with ElementAttributes

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

the class FlipflopTTest method testFlipFlopWithEnable.

public void testFlipFlopWithEnable() throws Exception {
    ObservableValue t = new ObservableValue("t", 1);
    ObservableValue c = new ObservableValue("c", 1);
    Model model = new Model();
    FlipflopT out = model.add(new FlipflopT(new ElementAttributes().setBits(1).set(Keys.WITH_ENABLE, true)));
    out.setInputs(new ObservableValues(t, c));
    TestExecuter sc = new TestExecuter(model).setInputs(t, c).setOutputs(out.getOutputs());
    // T  C  Q  ~Q
    sc.check(1, 0, 0, 1);
    sc.check(1, 1, 1, 0);
    sc.check(1, 1, 1, 0);
    sc.check(1, 0, 1, 0);
    sc.check(1, 0, 1, 0);
    sc.check(1, 1, 0, 1);
    sc.check(1, 0, 0, 1);
    sc.check(0, 1, 0, 1);
    sc.check(0, 0, 0, 1);
    sc.check(0, 1, 0, 1);
    sc.check(0, 0, 0, 1);
    sc.check(1, 1, 1, 0);
    sc.check(0, 0, 1, 0);
    sc.check(0, 1, 1, 0);
    sc.check(0, 0, 1, 0);
}
Also used : ObservableValues(de.neemann.digital.core.ObservableValues) 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 75 with ElementAttributes

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

the class CounterTest method testCounter.

public void testCounter() throws Exception {
    ObservableValue clk = new ObservableValue("clk", 1);
    ObservableValue en = new ObservableValue("en", 1);
    ObservableValue clr = new ObservableValue("clr", 1);
    Model model = new Model();
    Counter out = model.add(new Counter(new ElementAttributes().setBits(8)));
    out.setInputs(ovs(en, clk, clr));
    TestExecuter sc = new TestExecuter(model).setInputs(en, clk, clr).setOutputs(out.getOutputs());
    sc.check(1, 0, 0, 0, 0);
    sc.check(1, 1, 0, 1, 0);
    sc.check(1, 0, 0, 1, 0);
    sc.check(1, 1, 0, 2, 0);
    sc.check(1, 0, 0, 2, 0);
    sc.check(1, 1, 0, 3, 0);
    sc.check(1, 0, 0, 3, 0);
    sc.check(0, 0, 1, 3, 0);
    sc.check(0, 1, 1, 0, 0);
    sc.check(0, 0, 1, 0, 0);
    sc.check(1, 0, 0, 0, 0);
    for (int i = 1; i <= 254; i++) {
        sc.check(1, 0, 0, i - 1, 0);
        sc.check(1, 1, 0, i, 0);
    }
    sc.check(1, 0, 0, 254, 0);
    sc.check(1, 1, 0, 255, 1);
    sc.check(1, 0, 0, 255, 1);
    sc.check(1, 1, 0, 0, 0);
    sc.check(1, 0, 0, 0, 0);
    sc.check(1, 1, 0, 1, 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)

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