use of de.neemann.digital.core.Model in project Digital by hneemann.
the class ModelAnalyserTest method testAnalyzerUniqueNames2.
public void testAnalyzerUniqueNames2() throws Exception {
Model model = new ToBreakRunner("dig/analyze/uniqueNames2.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 testAnalyzerMultiBitPins.
public void testAnalyzerMultiBitPins() throws Exception {
Model model = new ToBreakRunner("dig/analyze/multiBitInOutXOr.dig", false).getModel();
ModelAnalyserInfo mai = new ModelAnalyser(model).analyse().getModelAnalyzerInfo();
assertEquals(2, mai.getInputBusMap().size());
checkBus(mai.getInputBusMap(), "A", "A0", "A1", "A2", "A3");
checkBus(mai.getInputBusMap(), "B", "B0", "B1", "B2", "B3");
assertEquals(1, mai.getOutputBusMap().size());
checkBus(mai.getOutputBusMap(), "S", "S0", "S1", "S2", "S3");
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class TestExamples method check.
/**
* Loads the model and initializes and test it if test cases are present
*
* @param dig the model file
*/
public static void check(File dig) throws Exception {
boolean shouldFail = dig.getName().endsWith("Error.dig");
ToBreakRunner br;
try {
br = new ToBreakRunner(dig);
} catch (Exception e) {
if (shouldFail) {
return;
} else
throw e;
}
try {
boolean isLib = dig.getPath().replace('\\', '/').contains("/lib/");
assertTrue("wrong locked mode", isLib == br.getCircuit().getAttributes().get(Keys.LOCKED_MODE));
try {
for (VisualElement el : br.getCircuit().getElements()) if (el.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION)) {
String label = el.getElementAttributes().getCleanLabel();
TestCaseDescription td = el.getElementAttributes().get(TestCaseElement.TESTDATA);
Model model = new ModelCreator(br.getCircuit(), br.getLibrary()).createModel(false);
try {
TestExecutor tr = new TestExecutor(td).create(model);
if (label.contains("Failing"))
assertFalse(dig.getName() + ":" + label, tr.allPassed());
else
assertTrue(dig.getName() + ":" + label, tr.allPassed());
testCasesInFiles++;
} finally {
model.close();
}
}
} catch (Exception e) {
if (shouldFail) {
return;
} else
throw e;
}
assertFalse("File should fail but doesn't!", shouldFail);
} finally {
br.close();
}
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class TestProcessor method createProcessor.
private ToBreakRunner createProcessor(String program, String processor) throws IOException, PinException, NodeException, ElementNotFoundException {
ToBreakRunner runner = new ToBreakRunner(processor, false);
Model model = runner.getModel();
ROM rom = null;
for (ROM r : model.findNode(ROM.class)) {
if (r.isProgramMemory())
rom = r;
}
assertNotNull(rom);
rom.setData(new DataField(new File(Resources.getRoot(), program)));
runner.getModel().init(true);
return runner;
}
use of de.neemann.digital.core.Model in project Digital by hneemann.
the class TestTrans method testTrans.
public void testTrans() throws Exception {
Model model = new ToBreakRunner("dig/test/transp/transtest3.dig").getModel();
assertEquals(2, model.getInputs().size());
assertEquals(1, model.getOutputs().size());
assertEquals(1, model.getNodes().size());
Node node = model.getNodes().get(0);
assertTrue(node instanceof XOr);
XOr xor = (XOr) node;
// The models inputs are the xor input values!
// All the intermediate transparent stuff is removed!
ArrayList<ObservableValue> ins = new ArrayList<>();
for (Signal s : model.getInputs()) ins.add(s.getValue());
assertTrue(ins.contains(xor.getInputs().get(0)));
assertTrue(ins.contains(xor.getInputs().get(1)));
}
Aggregations