Search in sources :

Example 16 with ToBreakRunner

use of de.neemann.digital.integration.ToBreakRunner in project Digital by hneemann.

the class VHDLGeneratorTest method testSplitter3.

public void testSplitter3() throws PinException, NodeException, ElementNotFoundException, IOException {
    ToBreakRunner br = new ToBreakRunner("dig/hdl/model2/splitter3.dig");
    CodePrinterStr out = new CodePrinterStr();
    VHDLGenerator gen = new VHDLGenerator(br.getLibrary(), out).export(br.getCircuit());
    assertEquals("-- generated by Digital. Don't modify this file!\n" + "-- Any changes will be lost if this file is regenerated.\n" + "\n" + "LIBRARY ieee;\n" + "USE ieee.std_logic_1164.all;\n" + "USE ieee.numeric_std.all;\n" + "\n" + "entity main is\n" + "  port (\n" + "    A: in std_logic_vector(3 downto 0);\n" + "    B: in std_logic_vector(3 downto 0);\n" + "    S: out std_logic_vector(3 downto 0));\n" + "end main;\n" + "\n" + "architecture Behavioral of main is\n" + "begin\n" + "  S(1 downto 0) <= (A(1 downto 0) AND B(1 downto 0));\n" + "  S(3 downto 2) <= (A(3 downto 2) OR B(3 downto 2));\n" + "end Behavioral;\n", out.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 17 with ToBreakRunner

use of de.neemann.digital.integration.ToBreakRunner 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);
        }
    }
}
Also used : Model(de.neemann.digital.core.Model) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 18 with ToBreakRunner

use of de.neemann.digital.integration.ToBreakRunner in project Digital by hneemann.

the class DependencyAnalyserTest method testSplitter.

public void testSplitter() throws Exception {
    Model model = new ToBreakRunner("dig/backtrack/Splitter.dig").getModel();
    ModelAnalyser m = new ModelAnalyser(model);
    DependencyAnalyser da = new DependencyAnalyser(m);
    assertEquals(2, m.getOutputs().size());
    assertEquals(1, da.getInputs(m.getOutputs().get(0)).size());
    assertEquals(1, da.getInputs(m.getOutputs().get(1)).size());
}
Also used : ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 19 with ToBreakRunner

use of de.neemann.digital.integration.ToBreakRunner in project Digital by hneemann.

the class DependencyAnalyserTest method testBacktrackCompleteness.

public void testBacktrackCompleteness() throws Exception {
    ToBreakRunner toBreakRunner = new ToBreakRunner("dig/backtrack/AllComponents.dig", false);
    // create a set of all components used in the circuit
    Circuit circuit = toBreakRunner.getCircuit();
    Set<String> set = new HashSet<>();
    for (VisualElement e : circuit.getElements()) set.add(e.getElementName());
    // ensure all available components are included in test circuit
    for (ElementLibrary.ElementContainer c : toBreakRunner.getLibrary()) {
        if (!set.contains(c.getDescription().getName())) {
            // nodes with state are allowed to be missing
            Element n = c.getDescription().createElement(new ElementAttributes());
            boolean ok = (n instanceof Node) && ((Node) n).hasState();
            assertTrue("component " + c.getDescription().getName() + " is missing in test/resources/dig/backtrack/AllComponents.dig!", ok);
        }
    }
    // check if backtracking is ok at all components!
    ModelAnalyser m = new ModelAnalyser(toBreakRunner.getModel());
    new DependencyAnalyser(m);
}
Also used : VisualElement(de.neemann.digital.draw.elements.VisualElement) Element(de.neemann.digital.core.element.Element) Circuit(de.neemann.digital.draw.elements.Circuit) VisualElement(de.neemann.digital.draw.elements.VisualElement) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) ElementLibrary(de.neemann.digital.draw.library.ElementLibrary) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) HashSet(java.util.HashSet)

Example 20 with ToBreakRunner

use of de.neemann.digital.integration.ToBreakRunner in project Digital by hneemann.

the class DependencyAnalyserTest method testAnalyzer.

public void testAnalyzer() throws Exception {
    Model model = new ToBreakRunner("dig/backtrack/Plexer.dig").getModel();
    ModelAnalyser m = new ModelAnalyser(model);
    DependencyAnalyser da = new DependencyAnalyser(m);
    assertEquals(17, m.getInputs().size());
    assertEquals(26, m.getOutputs().size());
    for (int i = 0; i < m.getOutputs().size(); i++) assertEquals("" + i, VAL[i], da.getInputs(m.getOutputs().get(i)).size());
}
Also used : ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Aggregations

ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)29 Model (de.neemann.digital.core.Model)16 CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)6 VisualElement (de.neemann.digital.draw.elements.VisualElement)3 BoolTable (de.neemann.digital.analyse.quinemc.BoolTable)2 Signal (de.neemann.digital.core.Signal)2 Circuit (de.neemann.digital.draw.elements.Circuit)2 HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)2 HDLModel (de.neemann.digital.hdl.model2.HDLModel)2 CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)2 File (java.io.File)2 ModelAnalyser (de.neemann.digital.analyse.ModelAnalyser)1 TruthTable (de.neemann.digital.analyse.TruthTable)1 Element (de.neemann.digital.core.element.Element)1 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 ElementLibrary (de.neemann.digital.draw.library.ElementLibrary)1 BuilderExpressionCreator (de.neemann.digital.gui.components.table.BuilderExpressionCreator)1 ExpressionCreator (de.neemann.digital.gui.components.table.ExpressionCreator)1 ExpressionListenerStore (de.neemann.digital.gui.components.table.ExpressionListenerStore)1 TestCaseDescription (de.neemann.digital.testing.TestCaseDescription)1