Search in sources :

Example 76 with Model

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

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

the class ProbeTest method testProbeNesting.

public void testProbeNesting() throws Exception {
    Model m = new ToBreakRunner("dig/probe/probeNest.dig").getModel();
    ArrayList<Signal> signals = m.getSignals();
    assertEquals(6, signals.size());
    assertTrue(signals.contains(new Signal("M-Probe1", null)));
    assertTrue(signals.contains(new Signal("M-Nest-Probe1", null)));
    assertTrue(signals.contains(new Signal("M-Nest-Probe2", null)));
}
Also used : Signal(de.neemann.digital.core.Signal) Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 78 with Model

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

the class ProbeTest method testProbe.

public void testProbe() throws Exception {
    Model m = new ToBreakRunner("dig/probe/probe.dig").getModel();
    ArrayList<Signal> signals = m.getSignals();
    assertEquals(5, signals.size());
    assertTrue(signals.contains(new Signal("M-Probe1", null)));
    assertTrue(signals.contains(new Signal("M-Probe2", null)));
}
Also used : Signal(de.neemann.digital.core.Signal) Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 79 with Model

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

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

Aggregations

Model (de.neemann.digital.core.Model)85 ObservableValue (de.neemann.digital.core.ObservableValue)56 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)52 TestExecuter (de.neemann.digital.TestExecuter)49 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)16 ValueTable (de.neemann.digital.data.ValueTable)6 Signal (de.neemann.digital.core.Signal)4 ModelCreator (de.neemann.digital.draw.model.ModelCreator)4 ObservableValues (de.neemann.digital.core.ObservableValues)3 Expression (de.neemann.digital.analyse.expression.Expression)2 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)2 Node (de.neemann.digital.core.Node)2 Delay (de.neemann.digital.core.wiring.Delay)2 Circuit (de.neemann.digital.draw.elements.Circuit)2 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)2 ShapeFactory (de.neemann.digital.draw.shapes.ShapeFactory)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Variable (de.neemann.digital.analyse.expression.Variable)1 Parser (de.neemann.digital.analyse.parser.Parser)1