Commit 8cd36fc4 authored by Peter's avatar Peter
Browse files

dev

parent 83095441
Loading
Loading
Loading
Loading
Loading
+15 −5
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogCompiler.java: 15 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -79,10 +79,16 @@ public class VerilogCompiler {
				.argName(".v file or folder")
				.desc("compile verilog file, post-process it for our debugger")
				.build());
		options.addOption(Option.builder("tm")
		options.addOption(Option.builder("tvh")
				.required(false)
				.hasArg()
				.argName("verilog statement")
				.argName("verilog heading statements")
				.desc("work with -t option to post-process and inject verilog statement")
				.build());
		options.addOption(Option.builder("tvs")
				.required(false)
				.hasArg()
				.argName("verilog statements")
				.desc("work with -t option to post-process and inject verilog statement")
				.build());
		options.addOption("h", "help", false, "help");
@@ -124,10 +130,14 @@ 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");
			if (!cmd.hasOption("tvh")) {
				logger.log(Level.SEVERE, "-tvh, verilog heading statements option missing");
				System.exit(20);
			}
//			if (!cmd.hasOption("tvs")) {
//				logger.log(Level.SEVERE, "-tvs, verilog statements option missing");
//				System.exit(20);
//			}
			String temp = cmd.getOptionValue("t");
			File file = new File(temp);
			File files[] = null;
@@ -141,7 +151,7 @@ public class VerilogCompiler {
			if (files != null) {
				for (File tempFile : files) {
					if (tempFile.isFile() && tempFile.getName().endsWith(".v")) {
						String newContent = VerilogHelper.preProcess(tempFile, cmd.getOptionValue("tm"));
						String newContent = VerilogHelper.preProcess(tempFile, cmd.getOptionValue("tvh"), cmd.getOptionValue("tvs"));
						if (cmd.hasOption("o")) {
							File dir = new File(cmd.getOptionValue("o"));
							if (!dir.exists()) {
+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, String verilogStatement) throws FileNotFoundException, FileNotFoundException, IOException {
	public static String preProcess(File file, String verilogheadingStatements, String verilogStatements) 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 verilogStatement + "\n" + String.join(System.lineSeparator(), lines) + "\n";
		return verilogheadingStatements + "\n" + String.join(System.lineSeparator(), lines) + "\n";
	}
}
+5 −1
Changes for src/main/java/hk/quantr/verilogcompiler/listener/preprocess/VerilogPreProcessorListener.java: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -42,7 +42,11 @@ public class VerilogPreProcessorListener extends VerilogParserBaseListener {
			System.out.println("parentMacro is null, " + lineNo);
			System.exit(929);
		}
		parentMacro.children.add(new MacroListing(parentMacro, parentMacro.parseNo + 1, lineNo, parentMacro.originalLineNo, "$display(\"%x\", add(1,2)); profile(\"" + ctx.variable_lvalue().getText() + "\");", MacroListing.Type.PROFILING));
		String verilogStatements = "";
//		verilogStatements += "$display(\"%x\", add(1,2));\n";
//		verilogStatements += "profile(\"" + ctx.variable_lvalue().getText() + "\");\n";
		verilogStatements += "profile(\"" + ctx.variable_lvalue().getText() + "\");\n";
		parentMacro.children.add(new MacroListing(parentMacro, parentMacro.parseNo + 1, lineNo, parentMacro.originalLineNo, verilogStatements, MacroListing.Type.PROFILING));
	}

	@Override