Search in sources :

Example 11 with CodePrinterStr

use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.

the class SeparatorTest method testSeparator.

public void testSeparator() throws IOException {
    CodePrinterStr out = new CodePrinterStr();
    out.println("open (").inc();
    Separator sep = new Separator(out, ",\n");
    for (int i = 0; i < 4; i++) {
        sep.check();
        out.print("item").print(i);
    }
    out.println(")").dec();
    out.print("close");
    assertEquals("open (\n" + "  item0,\n" + "  item1,\n" + "  item2,\n" + "  item3)\n" + "close", out.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr)

Example 12 with CodePrinterStr

use of de.neemann.digital.hdl.printer.CodePrinterStr 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 13 with CodePrinterStr

use of de.neemann.digital.hdl.printer.CodePrinterStr 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 14 with CodePrinterStr

use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.

the class HDLModelTest method testInputInvert2.

public void testInputInvert2() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
    HDLCircuit hdl = getCircuit("dig/hdl/model2/inputInvert2.dig", null).applyDefaultOptimizations();
    CodePrinterStr cp = new CodePrinterStr();
    hdl.print(cp);
    assertEquals("circuit main\n" + "  in(A:1 defines (A->1), B:1 defines (B->1), C:1 defines (C->1))\n" + "  out(Y:1 reads (Y->1))\n" + "  sig()\n" + "\n" + "  node merged expression\n" + "    in(In_2:1 reads (C->1), In_1:1 reads (A->1), In_2:1 reads (B->1))\n" + "    out(out:1 defines (Y->1))\n" + "    Y->1 := (NOT (A AND B) OR C)\n" + "\n" + "end circuit main\n", cp.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr)

Example 15 with CodePrinterStr

use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.

the class HDLModelTest method testNaming.

public void testNaming() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
    HDLCircuit hdl = getCircuit("dig/hdl/model2/naming.dig", null).applyDefaultOptimizations();
    CodePrinterStr cp = new CodePrinterStr();
    hdl.print(cp);
    assertEquals("circuit main\n" + "  in(S0:1 defines (S0->2), S1:1 defines (S1->2))\n" + "  out(S2:1 reads (S2->1), S3:1 reads (S3->1))\n" + "  sig(s4->2)\n" + "\n" + "  node NOr\n" + "    in(In_1:1 reads (S0->2), In_2:1 reads (S1->2))\n" + "    out(out:1 defines (s4->2))\n" + "    s4->2 := NOT (S0 OR S1)\n" + "  node XOr\n" + "    in(In_1:1 reads (S0->2), In_2:1 reads (s4->2))\n" + "    out(out:1 defines (S2->1))\n" + "    S2->1 := (S0 XOR s4)\n" + "  node XOr\n" + "    in(In_1:1 reads (s4->2), In_2:1 reads (S1->2))\n" + "    out(out:1 defines (S3->1))\n" + "    S3->1 := (s4 XOR S1)\n" + "\n" + "end circuit main\n", cp.toString());
}
Also used : CodePrinterStr(de.neemann.digital.hdl.printer.CodePrinterStr)

Aggregations

CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)21 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)6 HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)2 HDLModel (de.neemann.digital.hdl.model2.HDLModel)2 ClockIntegratorGeneric (de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)1 CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)1