Search in sources :

Example 6 with HDLException

use of de.neemann.digital.hdl.model2.HDLException in project Digital by hneemann.

the class HDLModelTest method testClock.

public void testClock() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
    HDLCircuit hdl = getCircuit("dig/hdl/model2/clock.dig", new ClockIntegratorGeneric(10)).applyDefaultOptimizations();
    CodePrinterStr cp = new CodePrinterStr();
    hdl.print(cp);
    assertEquals("circuit main\n" + "  in(A:1 defines (A->1), C:1 defines (C->1))\n" + "  out(X:1 reads (X->1))\n" + "  sig(s0->1)\n" + "\n" + "  node simpleClockDivider\n" + "    in(cin:1 reads (C->1))\n" + "    out(cout:1 defines (s0->1))\n" + "  node D_FF\n" + "    in(D:1 reads (A->1), C:1 reads (s0->1))\n" + "    out(Q:1 defines (X->1), ~Q:1 is not used)\n" + "\n" + "end circuit main\n", cp.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr) ClockIntegratorGeneric(de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)

Example 7 with HDLException

use of de.neemann.digital.hdl.model2.HDLException in project Digital by hneemann.

the class ClockTest method testGeneric.

public void testGeneric() throws PinException, NodeException, ElementNotFoundException, IOException, HDLException, HGSEvalException {
    String code = create(new ClockIntegratorGeneric(10));
    assertEquals("\n" + "LIBRARY ieee;\n" + "USE ieee.std_logic_1164.all;\n" + "USE ieee.numeric_std.all;\n" + "USE ieee.std_logic_unsigned.all;\n" + "\n" + "entity DIG_simpleClockDivider is\n" + "  generic (\n" + "    maxCounter : integer );  \n" + "  port (\n" + "    cout: out std_logic;\n" + "    cin: in std_logic );\n" + "end DIG_simpleClockDivider;\n" + "\n" + "architecture Behavioral of DIG_simpleClockDivider is\n" + "  -- Don't use a logic signal as clock source in a real world application!\n" + "  -- Use the on chip clock resources instead!\n" + "  signal counter: integer range 0 to maxCounter := 0;\n" + "  signal state: std_logic;\n" + "begin\n" + "  process (cin)\n" + "  begin\n" + "    if rising_edge(cin) then\n" + "       if counter = maxCounter then\n" + "          counter <= 0;\n" + "          state <= NOT (state);\n" + "       else\n" + "          counter <= counter+1;\n" + "       end if;\n" + "    end if;\n" + "  end process;\n" + "  cout <= state;\n" + "end Behavioral;\n" + "\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" + "    C: in std_logic;\n" + "    X: out std_logic);\n" + "end main;\n" + "\n" + "architecture Behavioral of main is\n" + "  signal s0: std_logic;\n" + "begin\n" + "  gate0: entity work.DIG_simpleClockDivider\n" + "    generic map (\n" + "      maxCounter => 50)\n" + "    port map (\n" + "      cin => C,\n" + "      cout => s0);\n" + "  gate1: entity work.DIG_D_FF\n" + "    port map (\n" + "      D => A,\n" + "      C => s0,\n" + "      Q => X);\n" + "end Behavioral;\n", code);
}
Also used : ClockIntegratorGeneric(de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)

Example 8 with HDLException

use of de.neemann.digital.hdl.model2.HDLException 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 9 with HDLException

use of de.neemann.digital.hdl.model2.HDLException in project Digital by hneemann.

the class ClockTest method create.

String create(HDLClockIntegrator ci) throws IOException, PinException, NodeException, ElementNotFoundException, HDLException, HGSEvalException {
    ToBreakRunner br = new ToBreakRunner("dig/hdl/model2/clock.dig");
    HDLCircuit c = new HDLCircuit(br.getCircuit(), "main", new HDLModel(br.getLibrary()), ci);
    c.applyDefaultOptimizations();
    CodePrinter out = new CodePrinterStr();
    new VHDLCreator(out).printHDLCircuit(c);
    return out.toString();
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr) HDLModel(de.neemann.digital.hdl.model2.HDLModel) CodePrinter(de.neemann.digital.hdl.printer.CodePrinter) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) HDLCircuit(de.neemann.digital.hdl.model2.HDLCircuit)

Example 10 with HDLException

use of de.neemann.digital.hdl.model2.HDLException in project Digital by hneemann.

the class VHDLSimulatorTest method runGHDL.

private void runGHDL(File vhdlFile, ArrayList<File> testFileWritten) throws IOException, FileScanner.SkipAllException, HDLException {
    checkWarn(vhdlFile, startProcess(vhdlFile.getParentFile(), GHDL, "-a", "--ieee=synopsys", vhdlFile.getName()));
    checkWarn(vhdlFile, startProcess(vhdlFile.getParentFile(), GHDL, "-e", "--ieee=synopsys", "main"));
    for (File testbench : testFileWritten) {
        String name = testbench.getName();
        checkWarn(testbench, startProcess(vhdlFile.getParentFile(), GHDL, "-a", "--ieee=synopsys", name));
        String module = name.substring(0, name.length() - 5);
        checkWarn(testbench, startProcess(vhdlFile.getParentFile(), GHDL, "-e", "--ieee=synopsys", module));
        String result = startProcess(vhdlFile.getParentFile(), GHDL, "-r", "--ieee=synopsys", module, "--vcd=" + module + ".vcd");
        if (result.contains("(assertion error)"))
            throw new HDLException("test bench " + name + " failed:\n" + result);
        checkWarn(testbench, result);
        testBenches++;
    }
}
Also used : HDLException(de.neemann.digital.hdl.model2.HDLException) File(java.io.File)

Aggregations

HDLException (de.neemann.digital.hdl.model2.HDLException)4 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)3 HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)3 HDLModel (de.neemann.digital.hdl.model2.HDLModel)3 ClockIntegratorGeneric (de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)3 CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)3 File (java.io.File)3 HDLClockIntegrator (de.neemann.digital.hdl.model2.clock.HDLClockIntegrator)2 CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 IOException (java.io.IOException)2 NodeException (de.neemann.digital.core.NodeException)1 Key (de.neemann.digital.core.element.Key)1 Splitter (de.neemann.digital.core.wiring.Splitter)1 PinException (de.neemann.digital.draw.elements.PinException)1 HGSEvalException (de.neemann.digital.hdl.hgs.HGSEvalException)1 de.neemann.digital.hdl.model2 (de.neemann.digital.hdl.model2)1 ClockInfo (de.neemann.digital.hdl.model2.clock.ClockInfo)1 ExprConstant (de.neemann.digital.hdl.model2.expression.ExprConstant)1 ExprNot (de.neemann.digital.hdl.model2.expression.ExprNot)1