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