Search in sources :

Example 1 with HDLPort

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

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

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

the class VHDLTestBenchCreator method writeTestBench.

private void writeTestBench(CodePrinter out, String testName, ElementAttributes tc) throws IOException, TestingDataException, ParserException {
    out.print("--  A testbench for ").println(testName);
    out.println("LIBRARY ieee;");
    out.println("USE ieee.std_logic_1164.all;");
    out.println("USE ieee.numeric_std.all;");
    out.println();
    out.print("entity ").print(testName).println(" is");
    out.print("end ").print(testName).println(";");
    out.println();
    out.print("architecture behav of ").print(testName).println(" is").inc();
    out.println("component main").inc();
    VHDLCreator.writePorts(out, main);
    out.dec().println("end component;");
    out.println();
    for (HDLPort p : main.getInputs()) out.print("signal ").print(p.getName()).print(" : ").print(VHDLCreator.getType(p.getBits())).println(";");
    for (HDLPort p : main.getOutputs()) out.print("signal ").print(p.getName()).print(" : ").print(VHDLCreator.getType(p.getBits())).println(";");
    out.dec().println("begin").inc();
    out.println("main_0 : main port map (").inc();
    Separator comma = new Separator(out, ",\n");
    for (HDLPort p : main.getInputs()) {
        comma.check();
        out.print(p.getName() + " => " + p.getName());
    }
    for (HDLPort p : main.getOutputs()) {
        comma.check();
        out.print(p.getName() + " => " + p.getName());
    }
    out.println(" );").dec();
    out.println("process").inc();
    TestCaseDescription testdata = tc.get(TESTDATA);
    ArrayList<HDLPort> dataOrder = new ArrayList<>();
    out.println("type pattern_type is record").inc();
    for (String name : testdata.getNames()) {
        String saveName = renaming.checkName(name);
        boolean found = false;
        for (HDLPort p : main.getPorts()) {
            if (p.getName().equals(saveName)) {
                out.print(p.getName()).print(" : ").print(VHDLCreator.getType(p.getBits())).println(";");
                dataOrder.add(p);
                found = true;
                break;
            }
        }
        if (!found)
            throw new TestingDataException(Lang.get("err_testSignal_N_notFound", name));
    }
    out.dec().println("end record;");
    out.println("type pattern_array is array (natural range <>) of pattern_type;");
    out.println("constant patterns : pattern_array := (").inc();
    LineListener parent = new LineListenerVHDL(out, dataOrder);
    testdata.getLines().emitLines(parent, new Context());
    out.println(");").dec();
    String loopVar = "i";
    int lv = 0;
    while (loopVarExists(loopVar, main.getPorts())) loopVar = "i" + (lv++);
    out.dec().println("begin").inc();
    out.print("for ").print(loopVar).println(" in patterns'range loop").inc();
    for (HDLPort p : main.getInputs()) out.print(p.getName()).print(" <= patterns(").print(loopVar).print(").").print(p.getName()).println(";");
    out.println("wait for 10 ns;");
    for (HDLPort p : main.getOutputs()) {
        out.print("assert std_match(").print(p.getName()).print(", patterns(").print(loopVar).print(").").print(p.getName()).print(")");
        out.print(" OR (").print(p.getName()).print(" = ").print(getSimpleValue(p.getBits(), 'Z')).print(" AND patterns(").print(loopVar).print(").").print(p.getName()).print(" = ").print(getSimpleValue(p.getBits(), 'Z')).print(")").eol();
        out.inc().print("report \"wrong value for ").print(p.getName()).print(" ").print(loopVar).print("=\" & integer'image(").print(loopVar).println(") severity error;").dec();
    }
    out.dec().println("end loop;");
    out.println("wait;");
    out.dec().println("end process;");
    out.dec().println("end behav;");
}
Also used : Context(de.neemann.digital.testing.parser.Context) TestingDataException(de.neemann.digital.testing.TestingDataException) LineListener(de.neemann.digital.testing.parser.LineListener) ArrayList(java.util.ArrayList) HDLPort(de.neemann.digital.hdl.model2.HDLPort) TestCaseDescription(de.neemann.digital.testing.TestCaseDescription)

Example 4 with HDLPort

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

the class Vivado method writeConstraints.

private void writeConstraints(CodePrinter out, HDLModel model) throws IOException {
    for (HDLPort p : model.getMain().getPorts()) {
        if (p.getBits() == 1) {
            writePin(out, p.getName(), p.getPinNumber());
            if (p.getPinNumber().equals(clockPin))
                out.print("create_clock -add -name sys_clk_pin -period ").print(periodns).print(" -waveform {0 5} [get_ports ").print(p.getName()).println("]");
        } else {
            SplitPinString pins = SplitPinString.create(p.getPinNumber());
            for (int i = 0; i < p.getBits(); i++) writePin(out, p.getName() + "[" + i + "]", pins.getPin(i));
        }
        out.println();
    }
    out.println("set_property CFGBVS VCCO  [current_design]");
    out.println("set_property CONFIG_VOLTAGE 3.3 [current_design]");
}
Also used : SplitPinString(de.neemann.digital.analyse.SplitPinString) HDLPort(de.neemann.digital.hdl.model2.HDLPort)

Example 5 with HDLPort

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

the class MergeAssignements method merge.

private HDLNodeAssignment merge(HDLNodeAssignment host, HDLNodeAssignment include) {
    final Expression expression = host.getExpression();
    final HDLNet obsoleteNet = include.getOutput().getNet();
    expression.replace(obsoleteNet, include.getExpression());
    HDLNodeAssignment node = new HDLNodeAssignment("merged expression", null, name -> host.getOutput().getBits());
    node.setExpression(expression);
    circuit.removeNet(obsoleteNet);
    node.addPort(host.getOutput());
    for (HDLPort i : host.getInputs()) if (i.getNet() != obsoleteNet)
        node.addPort(i);
    for (HDLPort i : include.getInputs()) if (!node.hasInput(i))
        node.addPort(i);
    else
        i.getNet().remove(i);
    return node;
}
Also used : Expression(de.neemann.digital.hdl.model2.expression.Expression)

Aggregations

HDLPort (de.neemann.digital.hdl.model2.HDLPort)3 ArrayList (java.util.ArrayList)3 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)2 SplitPinString (de.neemann.digital.analyse.SplitPinString)1 Key (de.neemann.digital.core.element.Key)1 Splitter (de.neemann.digital.core.wiring.Splitter)1 de.neemann.digital.hdl.model2 (de.neemann.digital.hdl.model2)1 HDLNet (de.neemann.digital.hdl.model2.HDLNet)1 HDLNode (de.neemann.digital.hdl.model2.HDLNode)1 ClockInfo (de.neemann.digital.hdl.model2.clock.ClockInfo)1 ClockIntegratorGeneric (de.neemann.digital.hdl.model2.clock.ClockIntegratorGeneric)1 HDLClockIntegrator (de.neemann.digital.hdl.model2.clock.HDLClockIntegrator)1 ExprNot (de.neemann.digital.hdl.model2.expression.ExprNot)1 ExprVar (de.neemann.digital.hdl.model2.expression.ExprVar)1 ExprVarRange (de.neemann.digital.hdl.model2.expression.ExprVarRange)1 Expression (de.neemann.digital.hdl.model2.expression.Expression)1 TestCaseDescription (de.neemann.digital.testing.TestCaseDescription)1 TestingDataException (de.neemann.digital.testing.TestingDataException)1 Context (de.neemann.digital.testing.parser.Context)1 LineListener (de.neemann.digital.testing.parser.LineListener)1