1
/* -*- tab-width: 4 -*-
3
* Electric(tm) VLSI Design System
5
* File: SoGWireQualityMetric.java
7
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9
* Electric(tm) is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 3 of the License, or
12
* (at your option) any later version.
14
* Electric(tm) is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
package com.sun.electric.tool.routing.seaOfGates;
24
import java.net.UnknownHostException;
26
import com.sun.electric.tool.Job;
27
import com.sun.electric.tool.routing.metrics.WireQualityMetric;
28
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.NeededRoute;
29
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.RouteBatch;
30
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.SearchVertex;
31
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.Wavefront;
33
public class SoGWireQualityMetric extends WireQualityMetric
35
public SoGWireQualityMetric(String s)
41
* Method to calculate net quality
42
* @param net Network to analyze
44
public QualityResults calculate(RouteBatch batch)
46
QualityResults result = null;
47
boolean atLeastOneSegment = false;
52
result = startLogging(batch.netName);
54
result.wireLength = new Double(0);
55
result.vias = new Integer(0);
56
double minX = Double.MAX_VALUE, maxX = -Double.MAX_VALUE;
57
double minY = Double.MAX_VALUE, maxY = -Double.MAX_VALUE;
59
for(NeededRoute nr : batch.routesInBatch)
61
if (nr.getRoutedSucess())
65
Wavefront winningWF = nr.getWavefront();
67
if (winningWF.vertices.size() < 2)
69
System.out.println("WARNING: Review net '" + batch.netName + "' - it has less than 2 vertices");
72
// ideal HPWL from start and end points
73
SearchVertex theFirst = winningWF.vertices.get(0);
74
SearchVertex theLast = winningWF.vertices.get(winningWF.vertices.size()-1);
75
double theSegMinX = Math.min(theFirst.getX(), theLast.getX());
76
double theSegMaxX = Math.max(theFirst.getX(), theLast.getX());
77
double theSegMinY = Math.min(theFirst.getY(), theLast.getY());
78
double theSegMaxY = Math.max(theFirst.getY(), theLast.getY());
79
result.addSegmentHPWL((theSegMaxX - theSegMinX) + (theSegMaxY - theSegMinY), false);
80
int startZ = theFirst.getZ();
81
int endZ = theLast.getZ();
82
int maxZ = Math.max(startZ, endZ);
85
// TODO: gather statistics for routeBatches[b].netName
86
for (int i=1; i<winningWF.vertices.size(); i++)
88
SearchVertex svLast = winningWF.vertices.get(i-1);
89
/// Collecting data for HPWL
92
minX = Math.min(minX, svLast.getX());
93
minY = Math.min(minY, svLast.getY());
94
maxX = Math.max(maxX, svLast.getX());
95
maxY = Math.max(maxY, svLast.getY());
98
SearchVertex sv = winningWF.vertices.get(i);
99
if (svLast.getZ() != sv.getZ())
101
// changed layer, count via
104
maxZ = Math.max(maxZ, sv.getZ());
107
/// Collecting data for HPWL
108
minX = Math.min(minX, sv.getX());
109
minY = Math.min(minY, sv.getY());
110
maxX = Math.max(maxX, sv.getX());
111
maxY = Math.max(maxY, sv.getY());
113
double dX = Math.abs(svLast.getX() - sv.getX());
114
double dY = Math.abs(svLast.getY() - sv.getY());
115
result.wireLength += Math.sqrt(dY*dY + dX*dX);
118
result.vias += countVias;
119
result.addSegmentViaValues(countVias, (maxZ-startZ) + (maxZ-endZ)); // zero value
120
atLeastOneSegment = true;
123
if (nr.getErrorMessage() != null)
130
// Only when routing was found
131
double avgWLHPWLReal = 0, avgWLHPWLIdeal = 0;
132
if (atLeastOneSegment)
134
result.addSegmentHPWL((maxX - minX) + (maxY - minY), true); //.hpwlOLD = (maxX - minX) + (maxY - minY);
135
avgHpwlReal += result.getSegmentHPWL(false, true);
136
avgHpwlIdeal += result.getSegmentHPWL(false, false);
137
totalWL += result.wireLength;
138
avgVias += result.vias;
139
avgWLHPWLReal = result.getWLDivHPWL(true);
140
avgWLHPWLIdeal = result.getWLDivHPWL(false);
141
addWLLengthToBucket(avgWLHPWLReal, result.resultName, true);
142
addWLLengthToBucket(avgWLHPWLIdeal, result.resultName, false);
143
addViaZeroBucket(result.getSegmentViaValue(), result.resultName);
144
avgWlDivHpwlReal += avgWLHPWLReal;
145
avgWlDivHpwlIdeal += avgWLHPWLIdeal;
146
numberOfRoutedNets++;
151
//logger.trace("calculate wire length");
152
info("wire length metric for net '" + batch.netName + "': " + result.wireLength);
154
// logger.trace("calculate unrouted nets");
155
// result.unroutedSegments = new UnroutedNetsMetric().calculate(cell);
156
// logger.debug("unrouted nets metric: " + result.unroutedSegments);
158
//logger.trace("calculate via amount metric...");
159
info("via amount metric for net '" + batch.netName + "': " + result.vias);
160
info("routed segment metric for net '" + batch.netName + "': " + result.numOfSegments(true));
161
info("via++ metric for net '" + batch.netName + "': " + result.getSegmentViaValue());
163
//logger.trace("calculate HPWL amount metric...");
164
info("Real HPWL amount metric for net '" + batch.netName + "': " + result.getSegmentHPWL(true, true));
165
info("Ideal HPWL amount metric for net '" + batch.netName + "': " + result.getSegmentHPWL(true, false));
167
info("Real WL v/s HPWL for net '" + batch.netName + "': " + avgWLHPWLReal);
168
info("Ideal WL v/s HPWL for net '" + batch.netName + "': " + avgWLHPWLIdeal);
170
info("============================");
171
} catch (UnknownHostException e) {
175
System.out.println("No name or service not known");