Search in sources :

Example 46 with Model

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

the class FlipFlopsTest method testFlipFlopNAnd.

public void testFlipFlopNAnd() throws Exception {
    ObservableValue r = new ObservableValue("r", 1);
    ObservableValue s = new ObservableValue("s", 1);
    Model model = new Model();
    FanIn a1 = model.add(new NAnd(new ElementAttributes().setBits(1)));
    FanIn a2 = model.add(new NAnd(new ElementAttributes().setBits(1)));
    a1.setInputs(ovs(r, a2.getOutput()));
    a2.setInputs(ovs(s, a1.getOutput()));
    TestExecuter sc = new TestExecuter(model).setInputs(r, s).setOutputs(a1.getOutput(), a2.getOutput());
    sc.check(1, 0, 0, 1);
    sc.check(1, 1, 0, 1);
    sc.check(0, 1, 1, 0);
    sc.check(1, 1, 1, 0);
    sc.check(1, 0, 0, 1);
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes)

Example 47 with Model

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

the class FlipFlopsTest method testFlipFlopNOr.

public void testFlipFlopNOr() throws Exception {
    ObservableValue r = new ObservableValue("r", 1);
    ObservableValue s = new ObservableValue("s", 1);
    Model model = new Model();
    FanIn a1 = model.add(new NOr(new ElementAttributes().setBits(1)));
    FanIn a2 = model.add(new NOr(new ElementAttributes().setBits(1)));
    a1.setInputs(ovs(r, a2.getOutput()));
    a2.setInputs(ovs(s, a1.getOutput()));
    TestExecuter sc = new TestExecuter(model, true).setInputs(r, s).setOutputs(a1.getOutput(), a2.getOutput());
    sc.check(0, 1, 1, 0);
    sc.check(0, 0, 1, 0);
    sc.check(1, 0, 0, 1);
    sc.check(0, 0, 0, 1);
    sc.check(0, 1, 1, 0);
    // verbotener Zustand!!
    sc.check(1, 1, 0, 0);
    // gehe aus verbotenem Zustand raus!!!
    r.setValue(0);
    s.setValue(0);
    // geht nur mit noise!
    model.doStep(true);
    assertTrue(// endzustand ist undefiniert!
    (a1.getOutput().getValue() == 1 && a2.getOutput().getValue() == 0) || (a1.getOutput().getValue() == 0 && a2.getOutput().getValue() == 1));
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes)

Example 48 with Model

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

the class CycleDetectorTest method testCycles.

public void testCycles() throws Exception {
    for (String name : nameTableSequential) {
        Model model = new ToBreakRunner("../../main/dig/sequential/" + name, false).getModel();
        try {
            new ModelAnalyser(model).analyse();
            fail("in " + name + " cycle detection failes!");
        } catch (CycleDetector.CycleException e) {
            assertTrue(true);
        }
    }
}
Also used : Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 49 with Model

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

the class ModelAnalyserTest method testAnalyzerUniqueNames.

public void testAnalyzerUniqueNames() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/uniqueNames.dig", false).getModel();
    try {
        new ModelAnalyser(model);
        fail();
    } catch (AnalyseException e) {
    }
}
Also used : Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 50 with Model

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

the class ModelAnalyserTest method testAnalyzerTFFEnable.

public void testAnalyzerTFFEnable() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/analyzeTestTFFEnable.dig", false).getModel();
    TruthTable tt = new ModelAnalyser(model).analyse();
    check2BitCounter(tt);
}
Also used : Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

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