Search in sources :

Example 81 with ObservableValue

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

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

Example 83 with ObservableValue

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

the class XOrTest method testXor.

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

Example 84 with ObservableValue

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

the class FlipflopDAsyncTest method testFlipFlop.

public void testFlipFlop() throws Exception {
    ObservableValue set = new ObservableValue("set", 1);
    ObservableValue d = new ObservableValue("d", 8);
    ObservableValue c = new ObservableValue("c", 1);
    ObservableValue clr = new ObservableValue("clr", 1);
    Model model = new Model();
    FlipflopDAsync out = model.add(new FlipflopDAsync(new ElementAttributes().setBits(8)));
    out.setInputs(ovs(set, d, c, clr));
    TestExecuter sc = new TestExecuter(model).setInputs(set, d, c, clr).setOutputs(out.getOutputs());
    // set D  C  clr Q  ~Q
    sc.check(0, 0, 0, 0, 0, 255);
    // set
    sc.check(1, 0, 0, 0, 255, 0);
    sc.check(0, 0, 0, 0, 255, 0);
    // clr
    sc.check(0, 0, 0, 1, 0, 255);
    sc.check(0, 0, 0, 0, 0, 255);
    sc.check(0, 1, 0, 0, 0, 255);
    sc.check(0, 1, 1, 0, 1, 254);
    sc.check(0, 0, 0, 0, 1, 254);
}
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 85 with ObservableValue

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

the class RAMDualPortTest method testRAM.

public void testRAM() throws Exception {
    ObservableValue a = new ObservableValue("a", 4);
    ObservableValue d = new ObservableValue("d", 4);
    ObservableValue str = new ObservableValue("str", 1);
    ObservableValue clk = new ObservableValue("clk", 1);
    ObservableValue ld = new ObservableValue("ld", 1);
    Model model = new Model();
    RAMDualPort out = model.add(new RAMDualPort(new ElementAttributes().set(Keys.ADDR_BITS, 4).setBits(4)));
    out.setInputs(ovs(a, d, str, clk, ld));
    TestExecuter sc = new TestExecuter(model).setInputs(a, d, str, clk, ld).setOutputs(out.getOutputs());
    // A  D  ST C  LD
    // def
    sc.checkZ(0, 0, 0, 0, 0, HIGHZ);
    // st  0->5
    sc.checkZ(0, 5, 1, 1, 0, HIGHZ);
    // def
    sc.checkZ(0, 0, 0, 0, 0, HIGHZ);
    // st  1->9
    sc.checkZ(1, 9, 1, 1, 0, HIGHZ);
    // rd  5
    sc.check(0, 0, 0, 0, 1, 5);
    // rd  5
    sc.check(1, 0, 0, 0, 1, 9);
}
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