Search in sources :

Example 1 with ToBreakRunner

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

the class DescriptionTest method testDescription.

public void testDescription() throws PinException, NodeException, ElementNotFoundException, IOException, HDLException, HGSEvalException {
    ToBreakRunner br = new ToBreakRunner("dig/hdl/model2/naming.dig");
    HDLCircuit circuit = new HDLCircuit(br.getCircuit(), "main", new HDLModel(br.getLibrary()), null).applyDefaultOptimizations();
    CodePrinterStr out = new CodePrinterStr();
    new VHDLCreator(out).printHDLCircuit(circuit);
    assertEquals("\n" + "LIBRARY ieee;\n" + "USE ieee.std_logic_1164.all;\n" + "USE ieee.numeric_std.all;\n" + "\n" + "-- Simple test circuit\n" + "-- used to test comments.\n" + "entity main is\n" + "  port (\n" + "    S0: in std_logic; -- First input\n" + "                      -- This is a far longer text.\n" + "    S1: in std_logic; -- Second input\n" + "    S2: out std_logic; -- first output\n" + "    S3: out std_logic -- second output\n" + "                      -- also with a longer text\n" + "    );\n" + "end main;\n" + "\n" + "architecture Behavioral of main is\n" + "  signal s4: std_logic;\n" + "begin\n" + "  s4 <= NOT (S0 OR S1);\n" + "  S2 <= (S0 XOR s4);\n" + "  S3 <= (s4 XOR S1);\n" + "end Behavioral;\n", out.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr) HDLModel(de.neemann.digital.hdl.model2.HDLModel) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) HDLCircuit(de.neemann.digital.hdl.model2.HDLCircuit)

Example 2 with ToBreakRunner

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

the class VHDLGeneratorTest method testComb.

public void testComb() throws PinException, NodeException, ElementNotFoundException, IOException {
    ToBreakRunner br = new ToBreakRunner("dig/hdl/model2/comb.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" + "\n" + "entity DIG_D_FF is\n" + "  \n" + "  port ( D  : in std_logic;\n" + "         C  : in std_logic;\n" + "         Q  : out std_logic;\n" + "         notQ : out std_logic );\n" + "end DIG_D_FF;\n" + "\n" + "architecture Behavioral of DIG_D_FF is\n" + "   signal state : std_logic := '0';\n" + "begin\n" + "   Q    <= state;\n" + "   notQ <= NOT( state );\n" + "\n" + "   process(C)\n" + "   begin\n" + "      if rising_edge(C) then\n" + "        state  <= D;\n" + "      end if;\n" + "   end process;\n" + "end Behavioral;\n" + "\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;\n" + "    B: in std_logic;\n" + "    C: in std_logic;\n" + "    X: out std_logic;\n" + "    Y: out std_logic;\n" + "    Z: out std_logic;\n" + "    Aident: out std_logic);\n" + "end main;\n" + "\n" + "architecture Behavioral of main is\n" + "  signal Y_temp: std_logic;\n" + "  signal s0: std_logic;\n" + "  signal Z_temp: std_logic;\n" + "begin\n" + "  Y_temp <= (B OR NOT C);\n" + "  Z_temp <= NOT A;\n" + "  s0 <= ((A OR C) AND (Z_temp OR C) AND '1' AND NOT (B OR C) AND Y_temp);\n" + "  gate0: entity work.DIG_D_FF\n" + "    port map (\n" + "      D => s0,\n" + "      C => '1',\n" + "      Q => X);\n" + "  Y <= Y_temp;\n" + "  Z <= Z_temp;\n" + "  Aident <= A;\n" + "end Behavioral;\n", out.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 3 with ToBreakRunner

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

the class VHDLGeneratorTest method testSplitter2I.

public void testSplitter2I() throws PinException, NodeException, ElementNotFoundException, IOException {
    ToBreakRunner br = new ToBreakRunner("dig/hdl/splitter2.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" + "    inst: in std_logic_vector(15 downto 0);\n" + "    n9SD: out std_logic_vector(15 downto 0));\n" + "end main;\n" + "\n" + "architecture Behavioral of main is\n" + "  signal s0: std_logic;\n" + "begin\n" + "  s0 <= inst(8);\n" + "  n9SD(7 downto 0) <= inst(7 downto 0);\n" + "  n9SD(8) <= s0;\n" + "  n9SD(9) <= s0;\n" + "  n9SD(10) <= s0;\n" + "  n9SD(11) <= s0;\n" + "  n9SD(12) <= s0;\n" + "  n9SD(13) <= s0;\n" + "  n9SD(14) <= s0;\n" + "  n9SD(15) <= s0;\n" + "end Behavioral;\n", out.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner)

Example 4 with ToBreakRunner

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

the class VHDLSimulatorTest method checkVHDLExport.

private void checkVHDLExport(File file) throws PinException, NodeException, ElementNotFoundException, IOException, FileScanner.SkipAllException, HDLException {
    ToBreakRunner br = new ToBreakRunner(file);
    File dir = Files.createTempDirectory("digital_vhdl_" + getTime() + "_").toFile();
    try {
        File vhdlFile = new File(dir, file.getName().replace('.', '_').replace('-', '_') + ".vhdl");
        CodePrinter out = new CodePrinter(vhdlFile);
        try (VHDLGenerator vhdl = new VHDLGenerator(br.getLibrary(), out)) {
            vhdl.disableClockIntegration().export(br.getCircuit());
            ArrayList<File> testFiles = vhdl.getTestBenches();
            out.close();
            runGHDL(vhdlFile, testFiles);
        }
        ProcessStarter.removeFolder(dir);
    } finally {
        br.close();
    }
}
Also used : CodePrinter(de.neemann.digital.hdl.printer.CodePrinter) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) File(java.io.File)

Example 5 with ToBreakRunner

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

the class CycleDetectorTest method testCyclesOk.

public void testCyclesOk() throws Exception {
    for (String name : nameTableCombinatorial) {
        try {
            Model model = new ToBreakRunner("../../main/dig/combinatorial/" + name, false).getModel();
            new ModelAnalyser(model).analyse();
        } catch (CycleDetector.CycleException e) {
            fail("cycle detected in " + name);
        }
    }
}
Also used : Model(de.neemann.digital.core.Model) 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