Search in sources :

Example 1 with HDLException

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

the class VHDLTestBenchCreator method write.

/**
 * Writes the test benches
 *
 * @param file the original vhdl file
 * @return this for chained calls
 * @throws IOException  IOException
 * @throws HDLException HDLException
 */
public VHDLTestBenchCreator write(File file) throws IOException, HDLException {
    String filename = file.getName();
    int p = filename.indexOf('.');
    if (p > 0)
        filename = filename.substring(0, p);
    for (ElementAttributes tc : testCases) {
        String testName = tc.getCleanLabel();
        if (testName.length() > 0)
            testName = filename + "_" + testName + "_tb";
        else
            testName = filename + "_tb";
        File f = new File(file.getParentFile(), testName + ".vhdl");
        testFileWritten.add(f);
        try (CodePrinter out = new CodePrinter(f)) {
            try {
                writeTestBench(out, testName, tc);
            } catch (TestingDataException | ParserException | RuntimeException e) {
                throw new HDLException(Lang.get("err_vhdlErrorWritingTestBench"), e);
            }
        }
    }
    return this;
}
Also used : ParserException(de.neemann.digital.testing.parser.ParserException) TestingDataException(de.neemann.digital.testing.TestingDataException) CodePrinter(de.neemann.digital.hdl.printer.CodePrinter) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) HDLException(de.neemann.digital.hdl.model2.HDLException) File(java.io.File)

Example 2 with HDLException

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

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

the class HDLCircuit method createNot.

private HDLNode createNot(HDLPort p, HDLNode node) throws HDLException, NodeException, PinException {
    final ElementAttributes attr = new ElementAttributes().setBits(p.getBits());
    HDLNodeAssignment n = new HDLNodeAssignment(Not.DESCRIPTION.getName(), attr, name -> p.getBits());
    HDLNet outNet = new HDLNet(null);
    listOfNets.add(outNet);
    HDLNet inNet = p.getNet();
    inNet.remove(p);
    n.addPort(new HDLPort(Not.DESCRIPTION.getInputDescription(attr).get(0).getName(), inNet, HDLPort.Direction.IN, p.getBits()));
    n.addPort(new HDLPort(Not.DESCRIPTION.getOutputDescriptions(attr).get(0).getName(), outNet, HDLPort.Direction.OUT, p.getBits()));
    p.setNet(outNet);
    node.replaceNet(inNet, outNet);
    n.setExpression(new ExprNot(new ExprVar(n.getInputs().get(0).getNet())));
    return n;
}
Also used : ExprVar(de.neemann.digital.hdl.model2.expression.ExprVar) ElementAttributes(de.neemann.digital.core.element.ElementAttributes) ExprNot(de.neemann.digital.hdl.model2.expression.ExprNot)

Example 4 with HDLException

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

the class VHDLLibrary method getEntity.

/**
 * Gets the entity of the given node
 *
 * @param node the node
 * @return the entity
 * @throws HDLException HDLException
 */
public VHDLEntity getEntity(HDLNode node) throws HDLException {
    String elementName = node.getElementName();
    VHDLEntity e = map.get(elementName);
    if (e == null) {
        try {
            e = new VHDLTemplate(elementName);
            map.put(elementName, e);
        } catch (IOException ex) {
            ex.printStackTrace();
            LOGGER.info("could not load '" + VHDLTemplate.neededFileName(elementName) + "'");
        }
    }
    if (e == null)
        throw new HDLException(Lang.get("err_vhdlNoEntity_N", elementName));
    return e;
}
Also used : VHDLEntity(de.neemann.digital.hdl.vhdl2.entities.VHDLEntity) HDLException(de.neemann.digital.hdl.model2.HDLException) IOException(java.io.IOException) VHDLTemplate(de.neemann.digital.hdl.vhdl2.entities.VHDLTemplate)

Example 5 with HDLException

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

Aggregations

HDLException (de.neemann.digital.hdl.model2.HDLException)4 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)3 HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)3 HDLModel (de.neemann.digital.hdl.model2.HDLModel)3 ClockIntegratorGeneric (de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)3 CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)3 File (java.io.File)3 HDLClockIntegrator (de.neemann.digital.hdl.model2.clock.HDLClockIntegrator)2 CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 IOException (java.io.IOException)2 NodeException (de.neemann.digital.core.NodeException)1 Key (de.neemann.digital.core.element.Key)1 Splitter (de.neemann.digital.core.wiring.Splitter)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 ClockInfo (de.neemann.digital.hdl.model2.clock.ClockInfo)1 ExprConstant (de.neemann.digital.hdl.model2.expression.ExprConstant)1 ExprNot (de.neemann.digital.hdl.model2.expression.ExprNot)1