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));
}
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++;
}
}
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());
}
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());
}
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();
}
Aggregations