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);
}
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));
}
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);
}
}
}
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) {
}
}
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);
}
Aggregations