Search in sources :

Example 1 with CodePrinter

use of de.neemann.digital.hdl.printer.CodePrinter 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 CodePrinter

use of de.neemann.digital.hdl.printer.CodePrinter in project Digital by hneemann.

the class Vivado method writeFiles.

@Override
public void writeFiles(File path, HDLModel model) throws IOException {
    String projectName = path.getName();
    if (projectName.endsWith(".vhdl"))
        projectName = projectName.substring(0, projectName.length() - 5);
    File constraints = new File(path.getParentFile(), projectName.replace('.', '_') + "_constraints.xdc");
    try (CodePrinter out = new CodePrinter(new FileOutputStream(constraints))) {
        writeConstraints(out, model);
    }
    createVivadoProject(path.getParentFile(), projectName, path, constraints);
}
Also used : CodePrinter(de.neemann.digital.hdl.printer.CodePrinter) SplitPinString(de.neemann.digital.analyse.SplitPinString)

Example 3 with CodePrinter

use of de.neemann.digital.hdl.printer.CodePrinter in project Digital by hneemann.

the class VHDLSimulatorTest method checkVHDLExport.

private void checkVHDLExport(File file) throws PinException, NodeException, ElementNotFoundException, IOException, FileScanner.SkipAllException, HDLException {
    ToBreakRunner br = new ToBreakRunner(file);
    File dir = Files.createTempDirectory("digital_vhdl_" + getTime() + "_").toFile();
    try {
        File vhdlFile = new File(dir, file.getName().replace('.', '_').replace('-', '_') + ".vhdl");
        CodePrinter out = new CodePrinter(vhdlFile);
        try (VHDLGenerator vhdl = new VHDLGenerator(br.getLibrary(), out)) {
            vhdl.disableClockIntegration().export(br.getCircuit());
            ArrayList<File> testFiles = vhdl.getTestBenches();
            out.close();
            runGHDL(vhdlFile, testFiles);
        }
        ProcessStarter.removeFolder(dir);
    } finally {
        br.close();
    }
}
Also used : CodePrinter(de.neemann.digital.hdl.printer.CodePrinter) ToBreakRunner(de.neemann.digital.integration.ToBreakRunner) File(java.io.File)

Example 4 with CodePrinter

use of de.neemann.digital.hdl.printer.CodePrinter 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

CodePrinter (de.neemann.digital.hdl.printer.CodePrinter)4 ToBreakRunner (de.neemann.digital.integration.ToBreakRunner)2 File (java.io.File)2 SplitPinString (de.neemann.digital.analyse.SplitPinString)1 ElementAttributes (de.neemann.digital.core.element.ElementAttributes)1 HDLCircuit (de.neemann.digital.hdl.model2.HDLCircuit)1 HDLException (de.neemann.digital.hdl.model2.HDLException)1 HDLModel (de.neemann.digital.hdl.model2.HDLModel)1 CodePrinterStr (de.neemann.digital.hdl.printer.CodePrinterStr)1 TestingDataException (de.neemann.digital.testing.TestingDataException)1 ParserException (de.neemann.digital.testing.parser.ParserException)1