Search in sources :

Example 1 with HDLCircuit

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

the class ClockIntegratorARTIX7 method insertMMCMClock.

private void insertMMCMClock(HDLCircuit model, Params p, HDLPort clock) throws HDLException {
    ElementAttributes attr = new ElementAttributes().set(new Key<>("cascading", 0), p.isCascading()).set(new Key<>("D_PARAM", 0), p.d).set(new Key<>("M_PARAM", 0), p.m).set(new Key<>("DIV_PARAM", 0), p.divider).set(new Key<>("DIV4_PARAM", 0), p.divider4).set(new Key<>("PERIOD_PARAM", 0.0), clkInPeriod);
    model.integrateClockNode(clock, new HDLNodeBuildIn("MMCME2_BASE", attr, name -> 1));
}
Also used : de.neemann.digital.hdl.model2(de.neemann.digital.hdl.model2) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) ClockIntegratorGeneric(de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric) ClockInfo(de.neemann.digital.hdl.model2.clock.ClockInfo) HDLClockIntegrator(de.neemann.digital.hdl.model2.clock.HDLClockIntegrator) Key(de.neemann.digital.core.element.Key) ArrayList(java.util.ArrayList) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) Key(de.neemann.digital.core.element.Key)

Example 2 with HDLCircuit

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

the class MergeConstants method optimize.

@Override
public void optimize(HDLCircuit circuit) throws HDLException {
    this.circuit = circuit;
    ArrayList<HDLNode> nodes = circuit.getNodes();
    int n1 = 0;
    while (n1 < nodes.size()) {
        final HDLNode node1 = nodes.get(n1);
        ExprConstant con1 = ExprConstant.isConstant(node1);
        if (con1 != null) {
            // CHECKSTYLE.OFF: ModifiedControlVariable
            for (int n2 = n1 + 1; n2 < nodes.size(); n2++) {
                final HDLNode node2 = nodes.get(n2);
                ExprConstant con2 = ExprConstant.isConstant(node2);
                if (con2 != null) {
                    if (con1.isEqualTo(con2)) {
                        merge(node1, node2);
                        nodes.remove(n2);
                        n2--;
                    }
                }
            }
        // CHECKSTYLE.ON: ModifiedControlVariable
        }
        n1++;
    }
}
Also used : ExprConstant(de.neemann.digital.hdl.model2.expression.ExprConstant)

Example 3 with HDLCircuit

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

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

use of de.neemann.digital.hdl.model2.HDLCircuit 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)

Aggregations

HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)3 HDLModel (de.neemann.digital.hdl.model2.HDLModel)3 CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)3 ClockIntegratorGeneric (de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)2 HDLClockIntegrator (de.neemann.digital.hdl.model2.clock.HDLClockIntegrator)2 ExprConstant (de.neemann.digital.hdl.model2.expression.ExprConstant)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 ArrayList (java.util.ArrayList)2 NodeException (de.neemann.digital.core.NodeException)1 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 Key (de.neemann.digital.core.element.Key)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 HDLException (de.neemann.digital.hdl.model2.HDLException)1 HDLNet (de.neemann.digital.hdl.model2.HDLNet)1 HDLNode (de.neemann.digital.hdl.model2.HDLNode)1 HDLPort (de.neemann.digital.hdl.model2.HDLPort)1 ClockInfo (de.neemann.digital.hdl.model2.clock.ClockInfo)1 CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)1