public void getGlobalInfo(ModuleOne[] modules, List <RelationOperator.relation> relation, int[] rows, int[] columns) { foreach (RelationOperator.relation relationOne in relation) { ModuleOne moduleSource = modules[ModuleOne.GetIndex(modules, relationOne.sourceName)]; ModuleOne moduleTarget = modules[ModuleOne.GetIndex(modules, relationOne.targetName)]; int com = moduleSource.compareModuleAdd(moduleTarget); computeRowColumn(moduleSource, moduleTarget, com, rows, columns); } }
public ModuleOne[] readModule(List <Module> modulesList) { int len = modulesList.Count; ModuleOne[] modules = new ModuleOne[len - 2]; ///////////////////the first line and second line/////////////////// //level = Convert.ToInt32(modulesList[0].moduleName); ModuleOne.setWidth(Convert.ToInt32(modulesList[0].x)); ModuleOne.setHeight(Convert.ToInt32(modulesList[0].y)); ModuleOne.modx = Convert.ToInt32(modulesList[1].x); ModuleOne.mody = Convert.ToInt32(modulesList[1].y); for (int i = 2; i < len; i++) { modules[i - 2] = new ModuleOne(modulesList[i].moduleName, modulesList[i].x, modulesList[i].y); } return(modules); }
public int compareModuleAdd(ModuleOne gp)//比较两个模块的位置并范围对应的位置类型 { if (posx == gp.getPosx()) { if (posy > gp.getPosy()) { if (posy - gp.getPosy() > mody) { return(10);//up } else { return(1); } } if (posy < gp.getPosy()) { if (gp.getPosy() - posy > mody) { return(14); } else { return(5); } } } if (posx < gp.getPosx()) { if (posy > gp.getPosy()) { if (posy - gp.getPosy() > mody) { if (gp.getPosx() - posx > modx) { return(18); } else { return(11); } } else { return(2); } } if (posy == gp.getPosy()) { if (gp.getPosx() - posx > modx) { return(12); } else { return(3); } } if (posy < gp.getPosy()) { if (gp.getPosy() - posy > mody) { if (gp.getPosx() - posx > modx) { return(19); } else { return(13); } } else { return(4); } } } if (posx > gp.getPosx()) { if (posy < gp.getPosy()) { if (gp.getPosy() - posy > mody) { if (posx - gp.getPosx() > modx) { return(20); } else { return(15); } } else { return(6); } } if (posy == gp.getPosy()) { if (posx - gp.getPosx() > modx) { return(16); } else { return(7); } } if (posy > gp.getPosy()) { if (posy - gp.getPosy() > mody) { if (posx - gp.getPosx() > modx) { return(17); } else { return(9); } } else { return(8); } } } return(0); }
public GridPoint goEastStepVertex(ModuleOne m, int i, int step) { return(myGrid.gridPointAt(m.getPosx() + m.getWidth0() + ModuleOne.gapx - (i + 1) * step, posy)); }
public GridPoint goWestStepVertex(ModuleOne m, int i, int step) { return(myGrid.gridPointAt(m.getPosx() - (i + 1) * step, posy)); }
public void setRouteForModules(ModuleOne[] modules, List <RelationOperator.relation> relation, int[] rows, int[] columns, List <ModuleOne.LineInfo> allLine) { ModuleOne.gapy = ModuleOne.mody - ModuleOne.getHeight(); ModuleOne.gapx = ModuleOne.modx - ModuleOne.getWidth(); int[] step_column = new int[columns.Length]; //记录每个区域的划分间隔 int[] step_row = new int[rows.Length]; int[] r = new int[rows.Length]; //记录每个区域已被划分的线的数量 int[] c = new int[columns.Length]; for (int m = 0; m < rows.Length; m++) { step_column[m] = ModuleOne.gapy / (rows[m] + 1); step_row[m] = ModuleOne.gapx / (columns[m] + 1); } step_column[0] = ModuleOne.gapy / (2 * rows[0] + 1); //最上面区域的划分间隔适当减小 step_row[columns.Length - 1] = ModuleOne.gapx / (2 * columns[columns.Length - 1] + 1); //最右边区域的划分间隔减小 GridPoint start = null; GridPoint target = null; foreach (RelationOperator.relation relationOne in relation) { ModuleOne moduleSource = modules[ModuleOne.GetIndex(modules, relationOne.sourceName)]; ModuleOne moduleTarget = modules[ModuleOne.GetIndex(modules, relationOne.targetName)]; string bidirection = relationOne.bidirection; string relationName = relationOne.relationName; string comment = relationOne.comment; int show = relationOne.show; int com = moduleSource.compareModuleAdd(moduleTarget); int numMax = 0; //记录上下或左右有直连关系时,模块的引脚数量的最大值 //根据模块的位置关系分配引脚 switch (com) { case 1: numMax = Math.Max(moduleSource.getNumNorth(), moduleTarget.getNumSouth()); start = moduleSource.northPin(GridPoint.myGrid, com, numMax); target = moduleTarget.southPin(GridPoint.myGrid, com, numMax); break; case 2: case 8: start = moduleSource.northPin(GridPoint.myGrid, com, numMax); target = moduleTarget.southPin(GridPoint.myGrid, com, numMax); break; case 3: numMax = Math.Max(moduleSource.getNumEast(), moduleTarget.getNumWest()); start = moduleSource.eastPin(GridPoint.myGrid, com, numMax); target = moduleTarget.westPin(GridPoint.myGrid, com, numMax); break; case 11: case 13: start = moduleSource.eastPin(GridPoint.myGrid, com, numMax); target = moduleTarget.westPin(GridPoint.myGrid, com, numMax); break; case 5: numMax = Math.Max(moduleSource.getNumSouth(), moduleTarget.getNumNorth()); start = moduleSource.southPin(GridPoint.myGrid, com, numMax); target = moduleTarget.northPin(GridPoint.myGrid, com, numMax); break; case 6: case 4: start = moduleSource.southPin(GridPoint.myGrid, com, numMax); target = moduleTarget.northPin(GridPoint.myGrid, com, numMax); break; case 7: numMax = Math.Max(moduleSource.getNumWest(), moduleTarget.getNumEast()); start = moduleSource.westPin(GridPoint.myGrid, com, numMax); target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax); break; case 9: case 15: start = moduleSource.westPin(GridPoint.myGrid, com, numMax); target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax); break; case 10: case 14: start = moduleSource.eastPin(GridPoint.myGrid, com, numMax); target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax); break; case 12: case 16: start = moduleSource.northPin(GridPoint.myGrid, com, numMax); target = moduleTarget.northPin(GridPoint.myGrid, com, numMax); break; case 17: start = moduleSource.northPin(GridPoint.myGrid, com, numMax); target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax); break; case 18: start = moduleSource.northPin(GridPoint.myGrid, com, numMax); target = moduleTarget.westPin(GridPoint.myGrid, com, numMax); break; case 19: start = moduleSource.southPin(GridPoint.myGrid, com, numMax); target = moduleTarget.westPin(GridPoint.myGrid, com, numMax); break; case 20: start = moduleSource.southPin(GridPoint.myGrid, com, numMax); target = moduleTarget.eastPin(GridPoint.myGrid, com, numMax); break; default: Console.WriteLine("no left pin"); break; } List <int[]> lineOnePath = Route(start, target, com, rows, columns, r, c, step_row, step_column, moduleSource, moduleTarget, bidirection); saveLine(lineOnePath, allLine, relationName, comment, show); } }
public List <int[]> Route(GridPoint start, GridPoint target, int com, int[] rows, int[] columns, int[] r, int[] c, int[] step_row, int[] step_column, ModuleOne mi, ModuleOne mj, string bidirection) {//返回一条路径所对应的线段 //if (start == null || target == null) // return -1; GridPoint[] trace = new GridPoint[6]; //记录一条路径的拐点,根据已有的布线算法,拐点最多3个,点有5个,最后的记录为null int x = 0; //根据模块的位置求出模块所属区域 int y = 0; int delta_x = 0; int delta_y = 0; List <int[]> line = new List <int[]>(); if (start == target) { Console.WriteLine("start and target are the same!"); } else { trace[0] = start; switch (com) { case 1: case 3: case 5: case 7: trace[1] = target; break; case 2: case 8: y = start.getPosy() / ModuleOne.mody; trace[1] = start.northStepVertex(r[y], step_column[y]); r[y] += 1; delta_x = target.getPosx() - start.getPosx(); trace[2] = trace[1].horizontalStepVertex(delta_x); trace[3] = target; break; case 4: case 6: y = start.getPosy() / ModuleOne.mody + 1; trace[1] = start.southStepVertex(r[y], step_column[y]); r[y] += 1; delta_x = target.getPosx() - start.getPosx(); trace[2] = trace[1].horizontalStepVertex(delta_x); trace[3] = target; break; case 9: case 15: x = start.getPosx() / ModuleOne.modx - 1; trace[1] = trace[0].westStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = target.getPosy() - start.getPosy(); trace[2] = trace[1].verticalStepVertex(delta_y); trace[3] = target; break; case 10: case 14: x = start.getPosx() / ModuleOne.modx; trace[1] = start.eastStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = target.getPosy() - start.getPosy(); trace[2] = trace[1].verticalStepVertex(delta_y); trace[3] = target; break; case 12: case 16: y = start.getPosy() / ModuleOne.mody; trace[1] = start.northStepVertex(r[y], step_column[y]); r[y] += 1; delta_x = target.getPosx() - start.getPosx(); trace[2] = trace[1].horizontalStepVertex(delta_x); trace[3] = target; break; case 13: case 11: x = start.getPosx() / ModuleOne.modx; trace[1] = trace[0].eastStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = target.getPosy() - start.getPosy(); trace[2] = trace[1].verticalStepVertex(delta_y); trace[3] = target; break; case 17: y = start.getPosy() / ModuleOne.mody; trace[1] = start.northStepVertex(r[y], step_column[y]); r[y] += 1; trace[4] = target; x = target.getPosx() / ModuleOne.modx; trace[3] = trace[4].eastStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = trace[1].getPosy() - trace[3].getPosy(); trace[2] = trace[3].verticalStepVertex(delta_y); break; case 18: y = start.getPosy() / ModuleOne.mody; trace[1] = start.northStepVertex(r[y], step_column[y]); r[y] += 1; trace[4] = target; x = target.getPosx() / ModuleOne.modx - 1; trace[3] = trace[4].westStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = trace[1].getPosy() - trace[3].getPosy(); trace[2] = trace[3].verticalStepVertex(delta_y); break; case 19: y = start.getPosy() / ModuleOne.mody + 1; trace[1] = start.southStepVertex(r[y], step_column[y]); r[y] += 1; trace[4] = target; x = target.getPosx() / ModuleOne.modx - 1; trace[3] = trace[4].westStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = trace[1].getPosy() - trace[3].getPosy(); trace[2] = trace[3].verticalStepVertex(delta_y); break; case 20: y = start.getPosy() / ModuleOne.mody + 1; trace[1] = start.southStepVertex(r[y], step_column[y]); r[y] += 1; trace[4] = target; x = target.getPosx() / ModuleOne.modx; trace[3] = trace[4].eastStepVertex(c[x], step_row[x]); c[x] += 1; delta_y = trace[1].getPosy() - trace[3].getPosy(); trace[2] = trace[3].verticalStepVertex(delta_y); break; default: break; } //需要传入是否双向 line = plotOneTrace(trace, bidirection); } return(line); }
public void computeRowColumn(ModuleOne mi, ModuleOne mj, int com, int[] rows, int[] columns) //根据模块之间的位置关系,记录每个模块每条边的引脚数量,记录每个区域关系线的数量 { switch (com) { case 1: mi.addNumNorthOne(); mj.addNumSouthOne(); break; case 2: case 8: mi.addNumNorthOne(); mj.addNumSouthOne(); rows[mi.getPosy() / ModuleOne.mody] += 1; break; case 3: mi.addNumEastOne(); mj.addNumWestOne(); break; case 4: case 6: mi.addNumSouthOne(); mj.addNumNorthOne(); rows[mi.getPosy() / ModuleOne.mody + 1] += 1; break; case 5: mi.addNumSouthOne(); mj.addNumNorthOne(); break; case 7: mi.addNumWestOne(); mj.addNumEastOne(); break; case 9: case 15: mi.addNumWestOne(); mj.addNumEastOne(); columns[mi.getPosx() / ModuleOne.modx - 1] += 1; break; case 10: case 14: mi.addNumEastOne(); mj.addNumEastOne(); columns[mi.getPosx() / ModuleOne.modx] += 1; break; case 11: case 13: mi.addNumEastOne(); mj.addNumWestOne(); columns[mi.getPosx() / ModuleOne.modx] += 1; break; case 12: case 16: mi.addNumNorthOne(); mj.addNumNorthOne(); rows[mi.getPosy() / ModuleOne.mody] += 1; break; case 17: mi.addNumNorthOne(); mj.addNumEastOne(); rows[mi.getPosy() / ModuleOne.mody] += 1; columns[mj.getPosx() / ModuleOne.modx] += 1; break; case 18: mi.addNumNorthOne(); mj.addNumWestOne(); rows[mi.getPosy() / ModuleOne.mody] += 1; columns[mj.getPosx() / ModuleOne.modx - 1] += 1; break; case 19: mi.addNumSouthOne(); mj.addNumWestOne(); rows[mi.getPosy() / ModuleOne.mody + 1] += 1; columns[mj.getPosx() / ModuleOne.modx - 1] += 1; break; case 20: mi.addNumSouthOne(); mj.addNumEastOne(); rows[mi.getPosy() / ModuleOne.mody + 1] += 1; columns[mj.getPosx() / ModuleOne.modx] += 1; break; default: break; } }