Search in sources :

Example 31 with Model

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

the class AndTest method testAnd.

public void testAnd() throws Exception {
    ObservableValue a = new ObservableValue("a", 1);
    ObservableValue b = new ObservableValue("b", 1);
    Model model = new Model();
    FanIn out = model.add(new And(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, 0);
    sc.check(0, 1, 0);
    sc.check(1, 1, 1);
    sc.check(1, 0, 0);
    sc.check(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 32 with Model

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

the class DelayTest method testDelayVar.

public void testDelayVar() throws Exception {
    for (int delayTime = 0; delayTime < 5; delayTime++) {
        ObservableValue in = new ObservableValue("in", 1);
        Model model = new Model();
        Delay delay = model.add(new Delay(new ElementAttributes().set(Keys.DELAY_TIME, delayTime)));
        delay.setInputs(in.asList());
        assertEquals(1, delay.getOutputs().size());
        ObservableValue out = delay.getOutputs().get(0);
        model.init();
        in.setValue(0);
        model.doStep();
        assertEquals(0, out.getValue());
        in.setValue(1);
        for (int i = 1; i < delayTime; i++) {
            assertTrue(model.needsUpdate());
            model.doMicroStep(false);
            assertEquals(0, out.getValue());
        }
        assertTrue(model.needsUpdate());
        model.doMicroStep(false);
        assertEquals(1, out.getValue());
        assertFalse(model.needsUpdate());
    }
}
Also used : ObservableValue(de.neemann.digital.core.ObservableValue) Model(de.neemann.digital.core.Model) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) Delay(de.neemann.digital.core.wiring.Delay)

Example 33 with Model

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

the class ModelAnalyserTest method testAnalyzerMultiBit3.

// test with non zero default values set
public void testAnalyzerMultiBit3() throws Exception {
    Model model = new ToBreakRunner("dig/analyze/multiBitInOutDef.dig", false).getModel();
    TruthTable tt = new ModelAnalyser(model).analyse();
    checkIdent(tt);
}
Also used : Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 34 with Model

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

the class ModelAnalyserTest method testAnalyzerDFF.

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

Example 35 with Model

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

the class ModelAnalyserTest method testAnalyzerTFF.

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