Search in sources :

Example 51 with Model

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

the class ModelAnalyserTest method testAnalyzerBacktrack.

public void testAnalyzerBacktrack() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/analyzeBacktrack.dig", false).getModel();
    TruthTable tt = new ModelAnalyser(model).analyse();
    final BoolTable Y1 = tt.getResult("1Y");
    checkRemaining(Y1, "1A", "1B");
    checkTable(getInner(Y1), zero, one, one, zero);
    final BoolTable Y2 = tt.getResult("2Y");
    checkRemaining(Y2, "2A", "2B");
    checkTable(getInner(Y2), one, zero, zero, one);
    final BoolTable Y3 = tt.getResult("3Y");
    checkRemaining(Y3, "3A", "3B");
    checkTable(getInner(Y3), zero, one, one, one);
    final BoolTable Y4 = tt.getResult("4Y");
    checkRemaining(Y4, "4A", "4B", "4C");
    checkTable(getInner(Y4), zero, zero, zero, zero, zero, zero, zero, one);
}
Also used : BoolTable(de.neemann.digital.analyse.quinemc.BoolTable) Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 52 with Model

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

the class ModelAnalyserTest method testAnalyzerJKFF.

public void testAnalyzerJKFF() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/analyzeTestJKFF.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)

Example 53 with Model

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

the class ModelAnalyserTest method testAnalyzerMultiBit2.

public void testAnalyzerMultiBit2() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/multiBitInOut.dig", false).getModel();
    TruthTable tt = new ModelAnalyser(model).analyse();
    checkIdent(tt);
    TreeMap<String, String> p = tt.getModelAnalyzerInfo().getPins();
    assertEquals("i1", p.get("A0"));
    assertEquals("i2", p.get("A1"));
    assertEquals("o1", p.get("B0"));
    assertEquals("o2", p.get("B1"));
}
Also used : Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 54 with Model

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

the class TestExecutor method create.

/**
 * Creates the result by comparing the testing vector with the given model-
 *
 * @param model the model to check
 * @return this for chained calls
 * @throws TestingDataException DataException
 * @throws NodeException        NodeException
 */
public TestExecutor create(Model model) throws TestingDataException, NodeException {
    allPassed = true;
    HashSet<String> usedSignals = new HashSet<>();
    inputs = new ArrayList<>();
    outputs = new ArrayList<>();
    for (Signal s : model.getInputs()) {
        final int index = getIndexOf(s.getName());
        if (index >= 0) {
            inputs.add(new TestSignal(index, s.getValue()));
            addTo(usedSignals, s.getName());
        }
        ObservableValue outValue = s.getBidirectionalReader();
        if (outValue != null) {
            final String outName = s.getName() + "_out";
            final int inIndex = getIndexOf(outName);
            if (inIndex >= 0) {
                outputs.add(new TestSignal(inIndex, outValue));
                addTo(usedSignals, outName);
            }
        }
    }
    for (Clock c : model.getClocks()) {
        final int index = getIndexOf(c.getLabel());
        if (index >= 0) {
            inputs.add(new TestSignal(index, c.getClockOutput()));
            addTo(usedSignals, c.getLabel());
        }
    }
    for (Signal s : model.getOutputs()) {
        final int index = getIndexOf(s.getName());
        if (index >= 0) {
            outputs.add(new TestSignal(index, s.getValue()));
            addTo(usedSignals, s.getName());
        }
    }
    for (String name : names) if (!usedSignals.contains(name))
        throw new TestingDataException(Lang.get("err_testSignal_N_notFound", name));
    if (inputs.size() == 0)
        throw new TestingDataException(Lang.get("err_noTestInputSignalsDefined"));
    if (outputs.size() == 0)
        throw new TestingDataException(Lang.get("err_noTestOutputSignalsDefined"));
    model.init();
    try {
        lines.emitLines(new LineListenerResolveDontCare(values -> checkRow(model, values), inputs), new Context());
    } catch (ParserException e) {
        throw new TestingDataException(Lang.get("err_errorParsingTestdata"), e);
    } catch (RuntimeException e) {
        if (allPassed) {
            allPassed = false;
            exception = e;
        }
    }
    return this;
}
Also used : Clock(de.neemann.digital.core.wiring.Clock) LineEmitter(de.neemann.digital.testing.parser.LineEmitter) Signal(de.neemann.digital.core.Signal) ParserException(de.neemann.digital.testing.parser.ParserException) ObservableValue(de.neemann.digital.core.ObservableValue) Lang(de.neemann.digital.lang.Lang) ValueTable(de.neemann.digital.data.ValueTable) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Model(de.neemann.digital.core.Model) Value(de.neemann.digital.data.Value) Context(de.neemann.digital.testing.parser.Context) NodeException(de.neemann.digital.core.NodeException) Context(de.neemann.digital.testing.parser.Context) ParserException(de.neemann.digital.testing.parser.ParserException) ObservableValue(de.neemann.digital.core.ObservableValue) Clock(de.neemann.digital.core.wiring.Clock) Signal(de.neemann.digital.core.Signal) HashSet(java.util.HashSet)

Example 55 with Model

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

the class AddTest method testAdd31.

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