Search in sources :

Example 1 with HDLModel

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

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

Example 3 with HDLModel

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

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

the class VHDLGenerator method export.

/**
 * Exports the given circuit
 *
 * @param circuit the circuit to export
 * @return this for chained calls
 * @throws IOException IOException
 */
public VHDLGenerator export(Circuit circuit) throws IOException {
    try {
        if (!circuit.getAttributes().get(Keys.ROMMANAGER).isEmpty())
            throw new HDLException(Lang.get("err_centralDefinedRomsAreNotSupported"));
        BoardInterface board = BoardProvider.getInstance().getBoard(circuit);
        HDLClockIntegrator clockIntegrator = null;
        if (board != null && useClockIntegration)
            clockIntegrator = board.getClockIntegrator();
        HDLModel model = new HDLModel(library).create(circuit, clockIntegrator);
        for (HDLCircuit hdlCircuit : model) hdlCircuit.applyDefaultOptimizations();
        model.renameLabels(new VHDLRenaming());
        out.println("-- generated by Digital. Don't modify this file!");
        out.println("-- Any changes will be lost if this file is regenerated.");
        new VHDLCreator(out).printHDLCircuit(model.getMain());
        File outFile = out.getFile();
        if (outFile != null) {
            testBenches = new VHDLTestBenchCreator(circuit, model).write(outFile).getTestFileWritten();
            if (board != null)
                board.writeFiles(outFile, model);
        }
        return this;
    } catch (PinException | NodeException | HDLException | HGSEvalException e) {
        throw new IOException(Lang.get("err_vhdlExporting"), e);
    }
}
Also used : HDLModel(de.neemann.digital.hdl.model2.HDLModel) NodeException(de.neemann.digital.core.NodeException) HDLCircuit(de.neemann.digital.hdl.model2.HDLCircuit) IOException(java.io.IOException) HDLClockIntegrator(de.neemann.digital.hdl.model2.clock.HDLClockIntegrator) BoardInterface(de.neemann.digital.hdl.vhdl2.boards.BoardInterface) HDLException(de.neemann.digital.hdl.model2.HDLException) PinException(de.neemann.digital.draw.elements.PinException) File(java.io.File) HGSEvalException(de.neemann.digital.hdl.hgs.HGSEvalException)

Aggregations

HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)3 HDLModel (de.neemann.digital.hdl.model2.HDLModel)3 CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)2 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 SplitPinString (de.neemann.digital.analyse.SplitPinString)1 NodeException (de.neemann.digital.core.NodeException)1 PinException (de.neemann.digital.draw.elements.PinException)1 HGSEvalException (de.neemann.digital.hdl.hgs.HGSEvalException)1 HDLException (de.neemann.digital.hdl.model2.HDLException)1 HDLPort (de.neemann.digital.hdl.model2.HDLPort)1 HDLClockIntegrator (de.neemann.digital.hdl.model2.clock.HDLClockIntegrator)1 CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)1 BoardInterface (de.neemann.digital.hdl.vhdl2.boards.BoardInterface)1 File (java.io.File)1 IOException (java.io.IOException)1