Commit f8df417c authored by Peter's avatar Peter
Browse files

dev

parent 91e3a5b4
Loading
Loading
Loading
Loading
Loading
+11 −2
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogCompiler.java: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -79,6 +79,12 @@ public class VerilogCompiler {
				.argName(".v file or folder")
				.desc("compile verilog file, post-process it for our debugger")
				.build());
		options.addOption(Option.builder("tm")
				.required(false)
				.hasArg()
				.argName("verilog statement")
				.desc("work with -t option to post-process and inject verilog statement")
				.build());
		options.addOption("h", "help", false, "help");

		if (args.length == 0 || Arrays.asList(args).contains("-h") || Arrays.asList(args).contains("--help")) {
@@ -118,6 +124,10 @@ public class VerilogCompiler {
			hk.quantr.verilogcompiler.structure.Module module = VerilogHelper.parseTopModule(temp.getParentFile(), temp.getName());
			System.out.println(CommonLib.objectToJson(module));
		} else if (cmd.hasOption("t")) {
			if (!cmd.hasOption("tm")) {
				logger.log(Level.SEVERE, "-tm option missing");
				System.exit(20);
			}
			String temp = cmd.getOptionValue("t");
			File file = new File(temp);
			File files[] = null;
@@ -131,7 +141,7 @@ public class VerilogCompiler {
			if (files != null) {
				for (File tempFile : files) {
					if (tempFile.isFile() && tempFile.getName().endsWith(".v")) {
						String newContent = VerilogHelper.preProcess(tempFile);
						String newContent = VerilogHelper.preProcess(tempFile, cmd.getOptionValue("tm"));
						if (cmd.hasOption("o")) {
							File dir = new File(cmd.getOptionValue("o"));
							if (!dir.exists()) {
@@ -146,7 +156,6 @@ public class VerilogCompiler {
					}
				}
			}
//			}
		} else if (cmd.hasOption("m")) {
			String temp = cmd.getOptionValue("m");
			File file = new File(temp);
+2 −2
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogHelper.java: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ public class VerilogHelper {
		return null;
	}

	public static String preProcess(File file) throws FileNotFoundException, FileNotFoundException, IOException {
	public static String preProcess(File file, String verilogStatement) throws FileNotFoundException, FileNotFoundException, IOException {
		ParseStructure ps = new ParseStructure();
		String content = IOUtils.toString(new FileInputStream(file), "utf-8");
		String sourceContent = VerilogHelper.getContentReplacedWithMacro(1, content, VerilogHelper.scanMacroDefinitions(file, file.getParentFile()), ps);
@@ -279,6 +279,6 @@ public class VerilogHelper {
			lines.add(temp.getTopParent().originalLineNo + 1, temp.line);
		}

		return "/* verilator lint_off UNOPTFLAT */\n" + String.join(System.lineSeparator(), lines) + "\n";
		return verilogStatement + "\n" + String.join(System.lineSeparator(), lines) + "\n";
	}
}