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