use of de.neemann.digital.hdl.printer.CodePrinterStr 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());
}
use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.
the class HDLModelTest method testSplitter4.
public void testSplitter4() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
HDLCircuit hdl = getCircuit("dig/hdl/model2/splitter4.dig", null).apply(new ReplaceOneToMany()).apply(new MergeAssignements()).apply(new NodeSorterExpressionBased()).nameUnnamedSignals();
CodePrinterStr cp = new CodePrinterStr();
hdl.print(cp);
assertEquals("circuit main\n" + " in(A:4 defines (A->2))\n" + " out(S:2 reads (S->1))\n" + " sig(s0->1, s1->1)\n" + "\n" + " node splitter\n" + " in(in:4 reads (A->2))\n" + " out(0,1:2 defines (s0->1))\n" + " s0->1 := A(1-0)\n" + " node splitter\n" + " in(in:4 reads (A->2))\n" + " out(2,3:2 defines (s1->1))\n" + " s1->1 := A(3-2)\n" + " node s-inc.dig\n" + " in(A:2 reads (s0->1), B:2 reads (s1->1))\n" + " out(C:2 defines (S->1))\n" + "\n" + "end circuit main\n", cp.toString());
}
use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.
the class HDLModelTest method testSimple.
public void testSimple() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
HDLCircuit hdl = getCircuit("dig/hdl/model2/comb.dig", null).apply(new MergeAssignements()).apply(new NodeSorterExpressionBased()).nameUnnamedSignals();
CodePrinterStr cp = new CodePrinterStr();
hdl.print(cp);
assertEquals("circuit main\n" + " in(A:1 defines (A->3), B:1 defines (B->2), C:1 defines (C->2))\n" + " out(X:1 reads (X->1), Y:1 reads (Y_temp->2), Z:1 reads (Z_temp->2), Aident:1 reads (A->3))\n" + " sig(Y_temp->2, s0->1, Z_temp->2, s1->1)\n" + "\n" + " node Const\n" + " in()\n" + " out(out:1 defines (s1->1))\n" + " s1->1 := 1:1\n" + " node merged expression\n" + " in(In_1:1 reads (B->2), in:1 reads (C->2))\n" + " out(out:1 defines (Y_temp->2))\n" + " Y_temp->2 := (B OR NOT C)\n" + " node Not\n" + " in(in:1 reads (A->3))\n" + " out(out:1 defines (Z_temp->2))\n" + " Z_temp->2 := NOT A\n" + " node merged expression\n" + " in(In_5:1 reads (Y_temp->2), In_1:1 reads (A->3), In_2:1 reads (C->2), In_1:1 reads (Z_temp->2), In_1:1 reads (B->2))\n" + " out(out:1 defines (s0->1))\n" + " s0->1 := ((A OR C) AND (Z_temp OR C) AND 1:1 AND NOT (B OR C) AND Y_temp)\n" + " node D_FF\n" + " in(D:1 reads (s0->1), C:1 reads (s1->1))\n" + " out(Q:1 defines (X->1), ~Q:1 is not used)\n" + "\n" + " Y:1 reads (Y_temp->2) := Y_temp->2\n" + " Z:1 reads (Z_temp->2) := Z_temp->2\n" + " Aident:1 reads (A->3) := A->3\n" + "end circuit main\n", cp.toString());
}
use of de.neemann.digital.hdl.printer.CodePrinterStr 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());
}
use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.
the class SeparatorTest method testSeparator2.
public void testSeparator2() 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);
String ic = "item" + i + " comment";
sep.setLineFinalizer(o -> o.printComment(" \\\\ ", ic));
}
sep.close();
out.println(")").dec();
out.print("close");
assertEquals("open (\n" + " item0, \\\\ item0 comment\n" + " item1, \\\\ item1 comment\n" + " item2, \\\\ item2 comment\n" + " item3 \\\\ item3 comment\n" + " )\n" + "close", out.toString());
}
Aggregations