Commit b99084f9 authored by Peter's avatar Peter
Browse files

dev

parent daf1fb1e
Loading
Loading
Loading
Loading
Loading
+10 −2
Changes for aaaa.v: 10 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -34,11 +34,19 @@ module a();

always @(*) begin

//`SET_INST(0, `EXE_RES_JUMP, 123, 3, 4, 5, 6, 7, 8)
alusel_o    = 0; 
        aluop_o     = 777; 
        reg1_read_o = 123; 
        reg2_read_o = 3; 
        reg1_addr_o = 4; 
        reg2_addr_o = 5; 
        wreg_o      = 6; 
        wd_o        = 7; 
        imm         = 8;

branch_flag = 11; 
        branch_target_address = 777; 
        link_address = 0;
        link_address = 777;

end

−2
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogCompiler.java: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@ package hk.quantr.verilogcompiler;

import hk.quantr.javalib.CommonLib;
import hk.quantr.javalib.PropertyUtil;
import hk.quantr.verilogcompiler.macro.MacroListing;
import hk.quantr.verilogcompiler.macro.ParseStructure;
import java.io.File;
import java.io.FileInputStream;
@@ -10,7 +9,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
+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
@@ -104,7 +104,7 @@ public class VerilogHelper {
//							}

							int lineNo = token.getLine() - 1;
							MacroListing parentMacro = ps.get(lineNo, parseNo > 0 ? parseNo - 1 : 0);
							MacroListing parentMacro = ps.get(lineNo, parseNo);

							if (parentMacro.lineNo == 194) {
								System.out.println("");
@@ -136,7 +136,7 @@ public class VerilogHelper {
				} else {
//				logger.info("\treplacing " + macroName);
					int lineNo = token.getLine() - 1;
					MacroListing parentMacro = ps.get(lineNo, parseNo > 0 ? parseNo - 1 : 0);
					MacroListing parentMacro = ps.get(lineNo, parseNo);
					if (parentMacro == null) {
						System.err.println("ERROR");
						System.exit(129);
+34 −35
Changes for src/main/java/hk/quantr/verilogcompiler/macro/ParseStructure.java: 34 added lines, 35 removed lines.
Original line number Diff line number Diff line
@@ -34,46 +34,45 @@ public class ParseStructure {
		return macroListingToString(macroListing, 0).getLeft();
	}

	public MacroListing get(int lineNo, int parseNo) {
		return get(macroListing, lineNo, parseNo);
	}

	public MacroListing get(ArrayList<MacroListing> temp, int lineNo, int parseNo) {
		for (int x = temp.size() - 1; x >= 0; x--) {
			System.out.println(">>>>>>> " + temp.get(x).lineNo + " = " + temp.get(x).parseNo + " : " + temp.get(x).line);
			if (temp.get(x).lineNo == lineNo && temp.get(x).parseNo == parseNo) {
				return temp.get(x);
			}
			if (!temp.get(x).children.isEmpty()) {
				MacroListing temp2 = get(temp.get(x).children, lineNo, parseNo);
				if (temp2 != null) {
					return temp2;
				}
			}
		}
		return null;
	}

//	public MacroListing get(int lineNo, int maxDeep) {
//		return get(lineNo, 0, macroListing, 0, maxDeep).getLeft();
//	public MacroListing get(int lineNo, int parseNo) {
//		return get(macroListing, lineNo, parseNo);
//	}
//
//	public Pair<MacroListing, Integer> get(int lineNo, int current, ArrayList<MacroListing> temp, int deep, int maxDeep) {
//		for (MacroListing m : temp) {
//			if (lineNo == current) {
//				return new ImmutablePair(m, current);
//	public MacroListing get(ArrayList<MacroListing> temp, int lineNo, int parseNo) {
//		for (int x = temp.size() - 1; x >= 0; x--) {
//			System.out.println(">>>>>>> " + temp.get(x).lineNo + " = " + temp.get(x).parseNo + " : " + temp.get(x).line);
//			if (temp.get(x).lineNo == lineNo && temp.get(x).parseNo == parseNo) {
//				return temp.get(x);
//			}
//			if (!m.children.isEmpty() & deep < maxDeep) {
//				Pair<MacroListing, Integer> p = get(lineNo, current, m.children, deep + 1, maxDeep);
//				MacroListing t = p.getLeft();
//				current = p.getRight();
//				if (t != null) {
//					return new ImmutablePair(t, current);
//			if (!temp.get(x).children.isEmpty()) {
//				MacroListing temp2 = get(temp.get(x).children, lineNo, parseNo);
//				if (temp2 != null) {
//					return temp2;
//				}
//			} else {
//				current++;
//			}
//		}
//		return new ImmutablePair(null, current);
//		return null;
//	}
	public MacroListing get(int lineNo, int maxDeep) {
		return get(lineNo, 0, macroListing, 0, maxDeep).getLeft();
	}

	public Pair<MacroListing, Integer> get(int lineNo, int current, ArrayList<MacroListing> temp, int deep, int maxDeep) {
		for (MacroListing m : temp) {
			if (lineNo == current) {
				return new ImmutablePair(m, current);
			}
			if (!m.children.isEmpty() & deep < maxDeep) {
				Pair<MacroListing, Integer> p = get(lineNo, current, m.children, deep + 1, maxDeep);
				MacroListing t = p.getLeft();
				current = p.getRight();
				if (t != null) {
					return new ImmutablePair(t, current);
				}
			} else {
				current++;
			}
		}
		return new ImmutablePair(null, current);
	}
}