Commit a2d37666 authored by Peter's avatar Peter
Browse files

dev

parent b599e10b
Loading
Loading
Loading
Loading
Loading
+757 −139

File changed.

Preview size limit exceeded, changes collapsed.

+3 −3
Changes for nbactions.xml: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
		<properties>
			<exec.vmArgs></exec.vmArgs>
			<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
			<exec.appArgs>-t ../quantr-i/src/ex.v -o ../quantr-i/src-output</exec.appArgs>
			<exec.appArgs>-t ../quantr-i/src/id.v -o ../quantr-i/src-output</exec.appArgs>
			<exec.mainClass>hk.quantr.verilogcompiler.VerilogCompiler</exec.mainClass>
			<exec.executable>java</exec.executable>
		</properties>
@@ -29,7 +29,7 @@
		<properties>
			<exec.vmArgs>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</exec.vmArgs>
			<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
			<exec.appArgs>-t ../quantr-i/src/ex.v -o ../quantr-i/src-output</exec.appArgs>
			<exec.appArgs>-t ../quantr-i/src/id.v -o ../quantr-i/src-output</exec.appArgs>
			<exec.mainClass>hk.quantr.verilogcompiler.VerilogCompiler</exec.mainClass>
			<exec.executable>java</exec.executable>
			<jpda.listen>true</jpda.listen>
@@ -49,7 +49,7 @@
			<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
			<exec.mainClass>${packageClassName}</exec.mainClass>
			<exec.executable>java</exec.executable>
			<exec.appArgs>-t ../quantr-i/src/ex.v -o ../quantr-i/src-output</exec.appArgs>
			<exec.appArgs>-t ../quantr-i/src/id.v -o ../quantr-i/src-output</exec.appArgs>
		</properties>
	</action>
	<action>
+26 −11
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogHelper.java: 26 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -99,26 +99,35 @@ public class VerilogHelper {
							}

							// add to macroListing
							int currentLineNo = 0;
							for (int z = macroListing.size() - 1; z >= 0; z--) {
								if (macroListing.get(z).lineNo == token.getLine() - 1) {
									currentLineNo = z;
									break;
								}
							}

//									macroListing.add(z + 1, new MacroListing(token.getLine() - 1, macroBody, Type.MACRO));
							int r = 0;
									macroListing.get(z).secondLineNo = token.getLine();
							String uuid = UUID.randomUUID().toString();
							int macroLineNo = macroListing.get(currentLineNo).secondLineNo;
							for (String temp : macroBody.split("\r?\n")) {
										macroListing.add(z + 1 + r, new MacroListing(token.getLine() - 1, temp, Type.MACRO, uuid));
								macroListing.add(new MacroListing(token.getLine() - 1, macroLineNo + r, temp, Type.MACRO, uuid));
								r++;
							}
									break;

							for (int q = currentLineNo + 1; q < macroListing.size(); q++) {
								if (macroListing.get(q).type == Type.ORIGINAL) {
									macroListing.get(q).secondLineNo += r - 1;
								}
							}
							// end add to macroListing

							rewriter.replace(token, macroBody);
							rewriter.delete(token.getTokenIndex() - 1);
							if (verilogPreListener.macroUsageTypes.get(macroName)) {
								rewriter.delete(token.getTokenIndex() + 1); // remove last ';'
							}
							rewriter.delete(token.getTokenIndex() - 1); // delete `
//							if (verilogPreListener.macroUsageTypes.get(macroName)) {
//								rewriter.delete(token.getTokenIndex() + 1); // remove last ';'
//							}
						} else {
							System.err.println("ERROR");
							System.exit(124);
@@ -285,6 +294,12 @@ public class VerilogHelper {
		VerilogParser parser = new VerilogParser(tokenStream);
		ParseTree tree = parser.source_text();

		Collections.sort(macroListing, (MacroListing o1, MacroListing o2) -> {
			if (o1.lineNo == o2.lineNo) {
				return Integer.valueOf(o1.secondLineNo).compareTo(Integer.valueOf(o2.secondLineNo));
			}
			return Integer.valueOf(o1.lineNo).compareTo(Integer.valueOf(o2.lineNo));
		});
		for (MacroListing m : macroListing) {
			System.out.println(m);
		}
@@ -297,11 +312,11 @@ public class VerilogHelper {

		StringBuilder sb = new StringBuilder();

		Collections.sort(macroListing, new Comparator<MacroListing>() {
			@Override
			public int compare(MacroListing o1, MacroListing o2) {
				return Integer.valueOf(o1.lineNo).compareTo(Integer.valueOf(o2.lineNo));
		Collections.sort(macroListing, (MacroListing o1, MacroListing o2) -> {
			if (o1.lineNo == o2.lineNo) {
				return Integer.valueOf(o1.secondLineNo).compareTo(Integer.valueOf(o2.secondLineNo));
			}
			return Integer.valueOf(o1.lineNo).compareTo(Integer.valueOf(o2.lineNo));
		});

		for (MacroListing m : macroListing) {
+22 −19
Changes for src/main/java/hk/quantr/verilogcompiler/listener/preprocess/VerilogPreProcessorListener.java: 22 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ public class VerilogPreProcessorListener extends VerilogParserBaseListener {

		int lineNo = ctx.stop.getLine() - 1;

		String prefix = null;
		String prefix = "";
		for (MacroListing temp : macroListing) {
			if (temp.lineNo == lineNo) {
			if (temp.secondLineNo == lineNo) {
				prefix = temp.line.replaceAll("[^\t]", " ");
				break;
			}
@@ -59,27 +59,30 @@ public class VerilogPreProcessorListener extends VerilogParserBaseListener {
//		}
//
//		// find macro uuid
//		int macroLastLineNo = -1;
//		for (int z = macroListing.size() - 1; z >= 0; z--) {
//			if (macroListing.get(z).type == Type.MACRO && macroListing.get(z).lineNo == lineNo) {
//				macroLastLineNo = macroListing.get(z).lineNo;
//				break;
//			}
//		}
		int macroLastLineNo = -1;
		int macroLastSecondLineNo = -1;
		for (int z = macroListing.size() - 1; z >= 0; z--) {
			if (macroListing.get(z).secondLineNo == lineNo) {
				macroLastLineNo = macroListing.get(z).lineNo;
				macroLastSecondLineNo = macroListing.get(z).secondLineNo;
				break;
			}
		}
		if (macroLastLineNo == -1) {
			System.out.println("shit");
		}
		// end find macro uuid
		// find original

		if (ctx.variable_lvalue().getText().equals("logicout")){
			System.out.println("");
		}
		
		int temp = lineNo;
		while (macroListing.get(temp).type != Type.ORIGINAL) {
			temp--;
		}
//		if (ctx.variable_lvalue().getText().equals("logicout")){
//			System.out.println("");
//		}
//		int temp = lineNo;
//		while (macroListing.get(temp).type != Type.ORIGINAL) {
//			temp--;
//		}
		// end find original

		macroListing.add(new MacroListing(macroListing.get(temp).lineNo, prefix + "$display(" + ctx.variable_lvalue().getText() + ");", MacroListing.Type.PROFILING, null));
		macroListing.add(new MacroListing(macroLastLineNo, macroLastSecondLineNo, prefix + "$display(" + ctx.variable_lvalue().getText() + ");", MacroListing.Type.PROFILING, null));

//		// add to macroListing
//		for (int z = macroListing.size() - 1; z >= 0; z--) {
+8 −2
Changes for src/main/java/hk/quantr/verilogcompiler/macro/MacroListing.java: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -19,13 +19,19 @@ public class MacroListing {
	public String line;
	public String uuid;

	public MacroListing(int lineNo, String line, Type t, String uuid) {
	public MacroListing(int lineNo, String line, Type type, String uuid) {
		this.lineNo = lineNo;
		this.secondLineNo = lineNo;
		this.line = line;
		this.type = t;
		this.type = type;
		this.uuid = uuid;
	}

	public MacroListing(int lineNo, int secondLineNo, String line, Type type, String uuid) {
		this(lineNo, line, type, uuid);
		this.secondLineNo = secondLineNo;
	}

	@Override
	public String toString() {
		if (type == Type.MACRO) {