use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.
the class HDLModelTest method testCircular.
public void testCircular() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
HDLCircuit hdl = getCircuit("dig/hdl/model2/circular.dig", null).applyDefaultOptimizations();
CodePrinterStr cp = new CodePrinterStr();
hdl.print(cp);
assertEquals("circuit main\n" + " in(A:1 defines (A->1), C:1 defines (C->3))\n" + " out(X:1 reads (X->1))\n" + " sig(s0->1, s1->1, Q_B->1, s2->1, s3->1, Q_A->1, s4->1, s5->1)\n" + "\n" + " node XOr\n" + " in(In_1:1 reads (s5->1), In_2:1 reads (A->1))\n" + " out(out:1 defines (s4->1))\n" + " s4->1 := (s5 XOR A)\n" + " node D_FF\n" + " in(D:1 reads (s4->1), C:1 reads (C->3))\n" + " out(Q:1 defines (Q_A->1), ~Q:1 defines (s5->1))\n" + " node XOr\n" + " in(In_1:1 reads (s3->1), In_2:1 reads (Q_A->1))\n" + " out(out:1 defines (s2->1))\n" + " s2->1 := (s3 XOR Q_A)\n" + " node D_FF\n" + " in(D:1 reads (s2->1), C:1 reads (C->3))\n" + " out(Q:1 defines (Q_B->1), ~Q:1 defines (s3->1))\n" + " node XOr\n" + " in(In_1:1 reads (s1->1), In_2:1 reads (Q_B->1))\n" + " out(out:1 defines (s0->1))\n" + " s0->1 := (s1 XOR Q_B)\n" + " node D_FF\n" + " in(D:1 reads (s0->1), C:1 reads (C->3))\n" + " out(Q:1 defines (X->1), ~Q:1 defines (s1->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 testConstantMerge.
public void testConstantMerge() throws IOException, PinException, HDLException, NodeException, ElementNotFoundException {
HDLCircuit hdl = getCircuit("dig/hdl/model2/constMerge.dig", null).apply(new MergeAssignements()).apply(new MergeConstants()).apply(new NameConstantSignals()).apply(new NodeSorterExpressionBased()).nameUnnamedSignals();
CodePrinterStr cp = new CodePrinterStr();
hdl.print(cp);
assertEquals("circuit main\n" + " in(A:1 defines (A->1), B:1 defines (B->1))\n" + " out(Y:2 reads (Y->1), X:1 reads (X->1), Z:2 reads (Z->1))\n" + " sig(const2b1->1, const1b1->3, const1b0->1)\n" + "\n" + " node Const\n" + " in()\n" + " out(out:2 defines (const2b1->1))\n" + " const2b1->1 := 1:2\n" + " node Const\n" + " in()\n" + " out(out:1 defines (const1b1->3))\n" + " const1b1->3 := 1:1\n" + " node Ground\n" + " in()\n" + " out(out:1 defines (const1b0->1))\n" + " const1b0->1 := 0:1\n" + " node D_FF\n" + " in(D:2 reads (const2b1->1), C:1 reads (B->1))\n" + " out(Q:2 defines (Y->1), ~Q:2 is not used)\n" + " node D_FF\n" + " in(D:1 reads (A->1), C:1 reads (const1b1->3))\n" + " out(Q:1 defines (X->1), ~Q:1 is not used)\n" + " node Counter\n" + " in(en:1 reads (const1b1->3), C:1 reads (const1b1->3), clr:1 reads (const1b0->1))\n" + " out(out:2 defines (Z->1), ovf: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 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();
}
use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.
the class SeparatorTest method testSeparator3.
public void testSeparator3() throws IOException {
CodePrinterStr out = new CodePrinterStr();
out.println("open (").inc();
Separator sep = new Separator(out, ",");
for (int i = 0; i < 4; i++) {
sep.check();
out.print("item").print(i);
if ((i & 1) == 0) {
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,item2, \\\\ item2 comment\n" + " item3)\n" + "close", out.toString());
}
use of de.neemann.digital.hdl.printer.CodePrinterStr in project Digital by hneemann.
the class VHDLGeneratorTest method testSplitter2.
public void testSplitter2() throws PinException, NodeException, ElementNotFoundException, IOException {
ToBreakRunner br = new ToBreakRunner("dig/hdl/model2/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" + " A: in std_logic_vector(1 downto 0);\n" + " B: in std_logic_vector(1 downto 0);\n" + " X: out std_logic;\n" + " Y: out std_logic_vector(2 downto 0));\n" + "end main;\n" + "\n" + "architecture Behavioral of main is\n" + " signal s0: std_logic_vector(3 downto 0);\n" + "begin\n" + " s0(1 downto 0) <= A;\n" + " s0(3 downto 2) <= B;\n" + " X <= s0(0);\n" + " Y <= s0(3 downto 1);\n" + "end Behavioral;\n", out.toString());
}
Aggregations